author | zautrix <zautrix> | 2004-10-05 09:22:20 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-10-05 09:22:20 (UTC) |
commit | aed6a774c2938b284d6cbc5026e3285c9c6ad24b (patch) (side-by-side diff) | |
tree | f05eefae589ae58b1d07d62c0c3d216ffb8d4f95 | |
parent | 701cd3c2b2b713c12797f5bda24c35d3a7889539 (diff) | |
download | kdepimpi-aed6a774c2938b284d6cbc5026e3285c9c6ad24b.zip kdepimpi-aed6a774c2938b284d6cbc5026e3285c9c6ad24b.tar.gz kdepimpi-aed6a774c2938b284d6cbc5026e3285c9c6ad24b.tar.bz2 |
sync fixes
-rw-r--r-- | korganizer/koprefs.cpp | 1 | ||||
-rw-r--r-- | korganizer/koprefs.h | 1 | ||||
-rw-r--r-- | korganizer/mainwindow.cpp | 36 | ||||
-rw-r--r-- | korganizer/mainwindow.h | 1 |
4 files changed, 23 insertions, 16 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index e0623d5..c28da9a 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp @@ -1,449 +1,450 @@ /* This file is part of KOrganizer. Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. As a special exception, permission is given to link this program with any edition of Qt, and distribute the resulting executable, without including the source code for Qt in the source distribution. */ #include <time.h> #ifndef _WIN32_ #include <unistd.h> #endif #include <qdir.h> #include <qtextstream.h> #include <qtextcodec.h> #include <qstring.h> #include <qregexp.h> #include <qfont.h> #include <qcolor.h> #include <qstringlist.h> #include <stdlib.h> #include <kglobal.h> #include <kconfig.h> #include <klocale.h> #include <kdebug.h> #include <kemailsettings.h> #include <kstaticdeleter.h> #include <libkdepim/kpimglobalprefs.h> #include "koprefs.h" #include "mainwindow.h" const char *germanwords[][2] = { #include "wordsgerman.h" "", "" }; KOPrefs *KOPrefs::mInstance = 0; static KStaticDeleter<KOPrefs> insd; KOPrefs::KOPrefs() : KPimPrefs("korganizerrc") { mCategoryColors.setAutoDelete(true); mLocaleDict = 0; fillMailDefaults(); mDefaultCategoryColor = QColor(175,210,255);//196,196,196); QColor defaultHolidayColor = QColor(255,0,0); QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); QColor defaultTodoDueTodayColor = QColor(255,220,100); QColor defaultTodoOverdueColor = QColor(255,153,125); mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); mDefaultViewFont = QFont("helvetica",10); mDefaultMonthViewFont = QFont("helvetica",8); mMarcusBainsFont= QFont("helvetica",10); mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); mEditBoxFont = QFont("helvetica",12); mJornalViewFont = QFont("helvetica",12); KPrefs::setCurrentGroup("General"); addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); addItemBool("ShowIconSearch",&mShowIconSearch,true); addItemBool("ShowIconList",&mShowIconList,true); addItemBool("ShowIconDay1",&mShowIconDay1,true); addItemBool("ShowIconDay5",&mShowIconDay5,true); addItemBool("ShowIconDay7",&mShowIconDay7,true); addItemBool("ShowIconMonth",&mShowIconMonth,true); addItemBool("ShowIconTodoview",&mShowIconTodoview,true); addItemBool("ShowIconBackFast",&mShowIconBackFast,true); addItemBool("ShowIconBack",&mShowIconBack,true); addItemBool("ShowIconToday",&mShowIconToday,true); addItemBool("ShowIconForward",&mShowIconForward,true); addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); addItemBool("ShowIconNextDays",&mShowIconNextDays,true); addItemBool("ShowIconNext",&mShowIconNext,true); addItemBool("ShowIconJournal",&mShowIconJournal,true); addItemBool("ShowIconStretch",&mShowIconStretch,true); addItemBool("LanguageChanged",&mLanguageChanged,false); addItemBool("AskForQuit",&mAskForQuit,false); #ifndef DESKTOP_VERSION addItemBool("ShowFullMenu",&mShowFullMenu,false); #else addItemBool("ShowFullMenu",&mShowFullMenu,true); #endif addItemBool("ToolBarHor",&mToolBarHor, true ); addItemBool("ToolBarUp",&mToolBarUp, false ); addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); addItemInt("Whats Next Days",&mWhatsNextDays,3); addItemInt("Whats Next Prios",&mWhatsNextPrios,1); addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); addItemInt("AllDay Size",&mAllDaySize,28); QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); addItemStringList("LocationDefaults",&mLocationDefaults ); addItemStringList("EventSummary User",&mEventSummaryUser); addItemStringList("TodoSummary User",&mTodoSummaryUser); addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); addItemBool("Enable Project View",&mEnableProjectView,false); addItemBool("Auto Save",&mAutoSave,false); addItemInt("Auto Save Interval",&mAutoSaveInterval,3); addItemBool("Confirm Deletes",&mConfirm,true); addItemString("Archive File",&mArchiveFile); addItemString("Html Export File",&mHtmlExportFile, QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); addItemBool("Html With Save",&mHtmlWithSave,false); KPrefs::setCurrentGroup("Personal Settings"); addItemInt("Mail Client",&mMailClient,MailClientKMail); addItemBool("Use Control Center Email",&mEmailControlCenter,false); addItemBool("Bcc",&mBcc,false); KPrefs::setCurrentGroup("Time & Date"); // addItemString("Time Zone",&mTimeZone,"+0100"); addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); addItemInt("Default Start Time",&mStartTime,10); addItemInt("Default Duration",&mDefaultDuration,2); addItemInt("Default Alarm Time",&mAlarmTime,3); addItemInt("Daylight Savings",&mDaylightSavings,0); KPrefs::setCurrentGroup("AlarmSettings"); addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); KPrefs::setCurrentGroup("Calendar"); addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); KPrefs::setCurrentGroup("Fonts"); // qDebug(" KPrefs::setCurrentGroup(Fonts); "); addItemFont("TimeBar Font",&mTimeBarFont); addItemFont("MonthView Font",&mMonthViewFont); addItemFont("AgendaView Font",&mAgendaViewFont); addItemFont("MarcusBains Font",&mMarcusBainsFont); addItemFont("TimeLabels Font",&mTimeLabelsFont); addItemFont("TodoView Font",&mTodoViewFont); addItemFont("ListView Font",&mListViewFont); addItemFont("DateNavigator Font",&mDateNavigatorFont); addItemFont("EditBox Font",&mEditBoxFont); addItemFont("JournalView Font",&mJornalViewFont); addItemFont("WhatsNextView Font",&mWhatsNextFont); addItemFont("EventView Font",&mEventViewFont); // KPrefs::setCurrentGroup("SyncProfiles"); // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); // addItemStringList("SyncProfileNames",&mSyncProfileNames); // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); KPrefs::setCurrentGroup("RemoteSyncing"); // addItemBool("UsePasswd",&mUsePassWd,false); // addItemBool("WriteBackFile",&mWriteBackFile,true); // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); // addItemBool("AskForPreferences",&mAskForPreferences,true); // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); addItemString("PassiveSyncPort",&mPassiveSyncPort,"9197" ); + addItemString("PassiveSyncPw",&mPassiveSyncPw,"abc" ); addItemString("ActiveSyncPort",&mActiveSyncPort,"9197" ); addItemString("ActiveSyncIP",&mActiveSyncIP,"192.168.0.40" ); addItemBool("ShowSyncEvents",&mShowSyncEvents,false); addItemInt("LastSyncTime",&mLastSyncTime,0); addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); #ifdef _WIN32_ QString hdp= locateLocal("data","korganizer")+"\\\\"; #else QString hdp= locateLocal("data","korganizer")+"/"; #endif // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); // addItemString("RemoteUser",&mRemoteUser, "zaurus"); // addItemString("RemotePassWd",&mRemotePassWd, ""); // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); KPrefs::setCurrentGroup("LoadSaveFileNames"); addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); KPrefs::setCurrentGroup("Locale"); addItemInt("PreferredLanguage",&mPreferredLanguage,0); addItemInt("PreferredTime",&mPreferredTime,0); addItemInt("PreferredDate",&mPreferredDate,0); addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); addItemBool("ShortDateInViewer",&mShortDateInViewer,false); addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); KPrefs::setCurrentGroup("Colors"); addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); addItemBool("UseAppColors",&mUseAppColors,false); KPrefs::setCurrentGroup("Views"); addItemInt("Hour Size",&mHourSize,8); addItemBool("Show Daily Recurrences",&mDailyRecur,true); addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); addItemBool("ShowShortMonthName",&mMonthShowShort,false); addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); addItemBool("Enable ToolTips",&mEnableToolTips,false); addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); #ifdef DESKTOP_VERSION addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); #else addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); #endif addItemInt("Day Begins",&mDayBegins,7); addItemInt("Working Hours Start",&mWorkingHoursStart,8); addItemInt("Working Hours End",&mWorkingHoursEnd,17); addItemBool("Exclude Holidays",&mExcludeHolidays,true); addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); addItemBool("Full View Month",&mFullViewMonth,true); addItemBool("Full View Todo",&mFullViewTodo,true); addItemBool("Quick Todo",&mEnableQuickTodo,false); addItemInt("Next X Days",&mNextXDays,3); KPrefs::setCurrentGroup("Printer"); KPrefs::setCurrentGroup("Layout"); addItemBool("CompactDialogs",&mCompactDialogs,false); addItemBool("VerticalScreen",&mVerticalScreen,true); KPrefs::setCurrentGroup("KOrganizer Plugins"); addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); KPrefs::setCurrentGroup("Group Scheduling"); addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); addItemStringList("AdditionalMails",&mAdditionalMails,""); addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); KPrefs::setCurrentGroup( "Editors" ); addItemStringList( "EventTemplates", &mEventTemplates ); addItemStringList( "TodoTemplates", &mTodoTemplates ); addItemInt("DestinationPolicy",&mDestination,standardDestination); } KOPrefs::~KOPrefs() { if (mInstance == this) mInstance = insd.setObject(0); setLocaleDict( 0 ); if ( mLocaleDict ) delete mLocaleDict; //qDebug("KOPrefs::~KOPrefs() "); } KOPrefs *KOPrefs::instance() { if (!mInstance) { mInstance = insd.setObject(new KOPrefs()); mInstance->readConfig(); } return mInstance; } void KOPrefs::usrSetDefaults() { } void KOPrefs::fillMailDefaults() { if (mName.isEmpty()) mName = i18n("Anonymous"); if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); } void KOPrefs::setTimeZoneIdDefault() { mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); } void KOPrefs::setCategoryDefaults() { mCustomCategories.clear(); mCustomCategories = getDefaultList(); QStringList::Iterator it; for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { setCategoryColor(*it,mDefaultCategoryColor); } } QStringList KOPrefs::getDefaultList() { QStringList retval ; retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; retval.sort(); return retval; } void KOPrefs::usrReadConfig() { mPreferredLanguage = KPimGlobalPrefs::instance()->mPreferredLanguage; mLocaleDict = 0; // pending LR fix translation // qDebug("KOPrefs::usrReadConfig() fix translation "); if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { if ( mPreferredLanguage == 1 ) { mLocaleDict = new QDict<QString>; int i = 0; QString fw ( germanwords[i] [0]); while ( !fw.isEmpty() ) { mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); ++i; fw = germanwords[i] [0]; } setLocaleDict( mLocaleDict ); } else { QString fileName ; if ( mPreferredLanguage == 3 ) fileName = MainWindow::resourcePath()+"usertranslation.txt"; else if ( mPreferredLanguage == 2 ) fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; QFile file( fileName ); if (file.open( IO_ReadOnly ) ) { QTextStream ts( &file ); ts.setEncoding( QTextStream::Latin1 ); //ts.setCodec( QTextCodec::latin1 ); QString text = ts.read(); file.close(); text.replace( QRegExp("\\\\n"), "\n" ); QString line; QString we; QString wt; int br = 0; int nbr; nbr = text.find ( "},", br ); line = text.mid( br, nbr - br ); br = nbr+1; int se, ee, st, et; mLocaleDict = new QDict<QString>; QString end = "{ \"\",\"\" }"; while ( (line != end) && (br > 1) ) { //qDebug("%d *%s* ", br, line.latin1()); se = line.find("\"")+1; et = line.findRev("\"",-1); ee = line.find("\",\""); st = ee+3; we = line.mid( se, ee-se ); wt = line.mid( st, et-st ); //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); mLocaleDict->insert( we, new QString (wt) ); nbr = text.find ( "}", br ); line = text.mid( br, nbr - br ); br = nbr+1; diff --git a/korganizer/koprefs.h b/korganizer/koprefs.h index 7abd741..d9ac851 100644 --- a/korganizer/koprefs.h +++ b/korganizer/koprefs.h @@ -26,287 +26,288 @@ #include <qdict.h> #include <libkdepim/kpimprefs.h> class KConfig; class QFont; class QColor; class QStringList; class KOPrefs : public KPimPrefs { public: enum { FormatVCalendar, FormatICalendar }; enum { MailClientKMail, MailClientSendmail }; enum { IMIPDummy, IMIPKMail }; enum { IMIPOutbox, IMIPdirectsend }; enum { neverAuto, addressbookAuto, selectedAuto }; enum { standardDestination, askDestination }; virtual ~KOPrefs(); /** Get instance of KOPrefs. It is made sure that there is only one instance. */ static KOPrefs *instance(); /** Set preferences to default values */ void usrSetDefaults(); /** Read preferences from config file */ void usrReadConfig(); /** Write preferences to config file */ void usrWriteConfig(); void setCategoryDefaults(); protected: void setTimeZoneIdDefault(); /** Fill empty mail fields with default values. */ void fillMailDefaults(); private: /** Constructor disabled for public. Use instance() to create a KOPrefs object. */ KOPrefs(); static KOPrefs *mInstance; QDict<QString> *mLocaleDict; QStringList getDefaultList(); public: // preferences data KConfig* getConfig(); void setFullName(const QString &); QString fullName(); void setEmail(const QString &); QString email(); QString mAdditional; bool mEmailControlCenter; bool mBcc; bool mAutoSave; int mAutoSaveInterval; bool mConfirm; bool mEnableGroupScheduling; bool mEnableProjectView; int mDefaultFormat; int mMailClient; QString mTimeZone; //QString mTimeZoneName; // e.g. +00:04:00 Indian/Mauritius //int mTimeZoneOffset; // e.g. -240 min int mStartTime; int mDefaultDuration; int mAlarmTime; int mDaylightSavings; int mWorkingHoursStart; int mWorkingHoursEnd; bool mExcludeHolidays; bool mExcludeSaturdays; bool mMarcusBainsShowSeconds; QFont mTimeBarFont; QFont mMonthViewFont; QFont mAgendaViewFont; QFont mMarcusBainsFont; QFont mTimeLabelsFont; QFont mTodoViewFont; QFont mListViewFont; QFont mDateNavigatorFont; QFont mEditBoxFont; QFont mJornalViewFont; QFont mWhatsNextFont; QFont mEventViewFont; QColor mHolidayColor; QColor mHighlightColor; QColor mEventColor; QColor mAgendaBgColor; QColor mWorkingHoursColor; QColor mTodoDueTodayColor; QColor mTodoOverdueColor; QColor mMonthViewEvenColor; QColor mMonthViewOddColor; QColor mMonthViewHolidayColor; bool mMonthViewUsesDayColors; bool mMonthViewSatSunTog; QColor mAppColor1; QColor mAppColor2; bool mUseAppColors; int mDayBegins; int mHourSize; int mAllDaySize; bool mShowFullMenu; bool mDailyRecur; bool mWeeklyRecur; bool mMonthDailyRecur; bool mMonthWeeklyRecur; bool mMonthShowIcons; bool mMonthShowShort; bool mEnableToolTips; bool mEnableMonthScroll; bool mFullViewMonth; bool mMonthViewUsesCategoryColor; bool mFullViewTodo; bool mShowCompletedTodo; bool mMarcusBainsEnabled; int mNextXDays; int mWhatsNextDays; int mWhatsNextPrios; bool mEnableQuickTodo; bool mLanguageChanged; bool mCompactDialogs; bool mVerticalScreen; bool mShowIconNewTodo; bool mShowIconNewEvent; bool mShowIconSearch; bool mShowIconList; bool mShowIconDay1; bool mShowIconDay5; bool mShowIconDay7; bool mShowIconMonth; bool mShowIconTodoview; bool mShowIconBackFast; bool mShowIconBack; bool mShowIconToday; bool mShowIconForward; bool mShowIconForwardFast; bool mShowIconWhatsThis; bool mShowIconNextDays; bool mShowIconNext; bool mShowIconJournal; bool mShowIconStretch; bool mToolBarHor; bool mToolBarUp; bool mToolBarMiniIcons; bool mAskForQuit; bool mUsePassWd; bool mWriteBackFile; int mWriteBackInFuture; bool mAskForPreferences; bool mShowSyncSummary; bool mShowSyncEvents; bool mShowTodoInAgenda; bool mWriteBackExistingOnly; QString mRemoteIP; QString mRemoteUser; QString mRemotePassWd; QString mRemoteFile; QString mLocalTempFile; QString mPhoneDevice; QString mPhoneConnection; QString mPhoneModel; int mLastSyncTime; int mSyncAlgoPrefs; int mRingSyncAlgoPrefs; QStringList mSyncProfileNames; QStringList mExternSyncProfiles; QString mLocalMachineName; void setCategoryColor(QString cat,const QColor & color); QColor *categoryColor(QString cat); QString mArchiveFile; QString mHtmlExportFile; bool mHtmlWithSave; QStringList mSelectedPlugins; QString mLastImportFile; QString mLastVcalFile; QString mLastSaveFile; QString mLastLoadFile; QString mLastSyncedLocalFile; QString mDefaultAlarmFile; int mIMIPScheduler; int mIMIPSend; QStringList mAdditionalMails; int mIMIPAutoRefresh; int mIMIPAutoInsertReply; int mIMIPAutoInsertRequest; int mIMIPAutoFreeBusy; int mIMIPAutoFreeBusyReply; QStringList mTodoTemplates; QStringList mEventTemplates; int mDestination; bool mEditOnDoubleClick; bool mViewChangeHoldFullscreen; bool mViewChangeHoldNonFullscreen; bool mCenterOnCurrentTime; bool mSetTimeToDayStartAt; bool mHighlightCurrentDay; bool mUseHighlightLightColor; bool mListViewMonthTimespan; bool mWNViewShowsParents; bool mWNViewShowLocation; bool mTodoViewShowsPercentage; bool mTodoViewUsesCatColors; bool mTodoViewUsesSmallFont; bool mTodoViewUsesForegroundColor; bool mMonthViewUsesForegroundColor; bool mHightlightDateTimeEdit; bool mShortDateInViewer; QStringList mLocationDefaults; QStringList mEventSummaryUser; QStringList mTodoSummaryUser; bool mUseInternalAlarmNotification; int mAlarmPlayBeeps; int mAlarmSuspendTime; int mAlarmSuspendCount; int mAlarmBeepInterval; QString mPassiveSyncPort; + QString mPassiveSyncPw; QString mActiveSyncPort; QString mActiveSyncIP; //US I copied the following settings into KPimGlobalPrefs // that allows us later to easily remove the settings from here. int mPreferredDate; QString mUserDateFormatLong; QString mUserDateFormatShort; int mPreferredLanguage; int mPreferredTime; bool mWeekStartsOnSunday; QString mTimeZoneId; bool mUseDaylightsaving; int mDaylightsavingStart; int mDaylightsavingEnd; private: QDict<QColor> mCategoryColors; QColor mDefaultCategoryColor; QFont mDefaultTimeBarFont; QFont mDefaultViewFont; QFont mDefaultMonthViewFont; QString mName; QString mEmail; }; #endif diff --git a/korganizer/mainwindow.cpp b/korganizer/mainwindow.cpp index 7b666d1..de94b8c 100644 --- a/korganizer/mainwindow.cpp +++ b/korganizer/mainwindow.cpp @@ -1639,862 +1639,866 @@ void MainWindow::fillFilterMenu() } else { selectFilterMenu->insertItem(i18n ( "Turn filter on" ), 0 ); disable = true; } selectFilterMenu->insertSeparator(); QPtrList<CalFilter> fili = mView->filters(); CalFilter *curfilter = mView->filterView()->selectedFilter(); CalFilter *filter = fili.first(); int iii = 1; while(filter) { selectFilterMenu->insertItem( filter->name(), iii ); if ( filter == curfilter) selectFilterMenu->setItemChecked( iii, true ); if ( disable ) selectFilterMenu->setItemEnabled( iii, false ); filter = fili.next(); ++iii; } } void MainWindow::selectFilter( int fil ) { if ( fil == 0 ) { mView->toggleFilerEnabled( ); } else { mView->selectFilter( fil-1 ); } } void MainWindow::configureToolBar( int item ) { configureToolBarMenu->setItemChecked( item, !configureToolBarMenu-> isItemChecked ( item ) ); KOPrefs *p = KOPrefs::instance(); p-> mShowIconStretch= configureToolBarMenu->isItemChecked( 5 ); p-> mShowIconNewEvent= configureToolBarMenu->isItemChecked( 10 ); p->mShowIconNewTodo = configureToolBarMenu->isItemChecked( 20 ); p-> mShowIconSearch= configureToolBarMenu->isItemChecked( 120 ); p-> mShowIconList= configureToolBarMenu->isItemChecked( 30 ); p-> mShowIconDay1= configureToolBarMenu->isItemChecked( 40 ); p-> mShowIconDay5= configureToolBarMenu->isItemChecked( 50 ); p-> mShowIconDay7= configureToolBarMenu->isItemChecked( 60 ); p-> mShowIconMonth= configureToolBarMenu->isItemChecked( 70 ); p-> mShowIconTodoview= configureToolBarMenu->isItemChecked( 80 ); p-> mShowIconBackFast= configureToolBarMenu->isItemChecked( 200 ); p-> mShowIconBack = configureToolBarMenu->isItemChecked( 210 ); p-> mShowIconToday= configureToolBarMenu->isItemChecked( 130 ); p-> mShowIconForward= configureToolBarMenu->isItemChecked( 220 ); p-> mShowIconForwardFast= configureToolBarMenu->isItemChecked( 230 ); p-> mShowIconNextDays= configureToolBarMenu->isItemChecked( 100 ); p-> mShowIconNext= configureToolBarMenu->isItemChecked( 110 ); p-> mShowIconJournal= configureToolBarMenu->isItemChecked( 90 ); p-> mShowIconWhatsThis= configureToolBarMenu->isItemChecked( 300 ); // initActions(); } void MainWindow::setCaptionToDates() { QString selDates; selDates = KGlobal::locale()->formatDate(mView->startDate(), true); if (mView->startDate() < mView->endDate() ) selDates += " - " + KGlobal::locale()->formatDate(mView->endDate(), true); setCaption( i18n("Dates: ") + selDates ); } // parameter item == 0: reinit void MainWindow::configureAgenda( int item ) { KOPrefs *p = KOPrefs::instance(); int i; if ( item == 1 ) { mView->toggleAllDaySize(); return; } // do not allow 4 for widgets higher than 480 // if ( QApplication::desktop()->height() > 480 ) { // if ( item == 4 ) // item = 6; // } for ( i = 4; i <= 18; i= i+2 ) configureAgendaMenu->setItemChecked( i, false ); configureAgendaMenu->setItemChecked( item, true ); if ( p->mHourSize == item ) return; p->mHourSize=item; mView->viewManager()->agendaView()->updateConfig(); } void MainWindow::saveCalendar() { QString fn = KOPrefs::instance()->mLastSaveFile; fn = KFileDialog::getSaveFileName( fn, i18n("Save backup filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("Backup file\nalready exists!\nOld backup file from:\n%1\nOverwrite?\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )) ; int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { mView->saveCalendar( fn ); mes = i18n("KO/Pi:Saved %1").arg(fn); KOPrefs::instance()->mLastSaveFile = fn; setCaption(mes); } } void MainWindow::loadCalendar() { QString fn = KOPrefs::instance()->mLastLoadFile; fn = KFileDialog::getOpenFileName( fn, i18n("Load backup filename"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( info. exists() ) { mess = i18n("Backup file from:\n%1\nLoading backup\nfile will delete\nyour current Data!\n").arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); int result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, i18n("Load!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { loadbup = false; } } else { QMessageBox::warning( this, i18n("KO/Pi: Warning!"), i18n("Backup file\ndoes not exist!\nNothing loaded!"), 0, 0, 0, 1 ); return; } if ( loadbup ) { mView->openCalendar( fn ); KOPrefs::instance()->mLastLoadFile = fn; mess = i18n("KO/Pi:Loaded %1").arg(fn) ; setCaption(mess); } } void MainWindow::quickImportIcal() { importFile( KOPrefs::instance()->mLastImportFile, false ); } void MainWindow::importFile( QString fn, bool quick ) { QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n("Import file \n...%1\ndoes not exist!\nNothing imported!\n").arg(fn.right( 30)); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess ); return; } int result = 0; if ( !quick ) { mess = i18n( "Import file \n...%1\nfrom:\n%2\nDuplicated entries\nwill not be imported!\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( this, "KO/Pi: Warning!", mess, "Import", "Cancel", 0, 0, 1 ); } if ( result == 0 ) { if ( mView->openCalendar( fn, true )) { KOPrefs::instance()->mLastImportFile = fn; setCaption(i18n("Imported file successfully")); } else { setCaption(i18n("Error importing file")); } } } void MainWindow::importIcal() { QString fn =KOPrefs::instance()->mLastImportFile; fn =KFileDialog:: getOpenFileName( fn, i18n("Import filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; importFile( fn, true ); } void MainWindow::exportVCalendar() { QString fn = KOPrefs::instance()->mLastVcalFile; fn = KFileDialog::getSaveFileName( fn, i18n("Export vcal filename(*.vcs)"), this ); if ( fn == "" ) return; QFileInfo info; info.setFile( fn ); QString mes; bool createbup = true; if ( info. exists() ) { mes = i18n("Save file\nalready exists!\nOld save file from:\n%1\nOverwrite?\n").arg (KGlobal::locale()->formatDateTime(info.lastModified (), true, false ) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"),mes, i18n("Overwrite!"), i18n("Cancel"), 0, 0, 1 ); if ( result != 0 ) { createbup = false; } } if ( createbup ) { if ( mView->exportVCalendar( fn ) ) { KOPrefs::instance()->mLastVcalFile = fn; if ( fn.length() > 20 ) mes = i18n("KO/Pi:Exported to ...%1").arg(fn.right(20)) ; else mes = i18n("KO/Pi:Exported to %1").arg(fn ); setCaption(mes); } } } QString MainWindow::getPassword( ) { QString retfile = ""; QDialog dia ( this, "input-dialog", true ); QLineEdit lab ( &dia ); lab.setEchoMode( QLineEdit::Password ); QVBoxLayout lay( &dia ); lay.setMargin(7); lay.setSpacing(7); lay.addWidget( &lab); dia.setFixedSize( 230,50 ); dia.setCaption( i18n("Enter password") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); int res = dia.exec(); if ( res ) retfile = lab.text(); dia.hide(); qApp->processEvents(); return retfile; } void MainWindow::enableQuick() { - QString passWordPiSync = "bhdrvmk"; - QString retfile = ""; QDialog dia ( this, "input-dialog", true ); QLineEdit lab ( &dia ); QVBoxLayout lay( &dia ); lab.setText( KOPrefs::instance()->mPassiveSyncPort ); lay.setMargin(7); lay.setSpacing(7); QLabel label ( i18n("Port number (Default: 9197)"), &dia ); lay.addWidget( &label); lay.addWidget( &lab); QLineEdit lepw ( &dia ); - lepw.setText( "abc" ); + lepw.setText( KOPrefs::instance()->mPassiveSyncPw ); QLabel label2 ( i18n("Password to enable\naccess from remote:"), &dia ); lay.addWidget( &label2); lay.addWidget( &lepw); dia.setFixedSize( 230,80 ); dia.setCaption( i18n("Enter port for Pi-Sync") ); QPushButton pb ( "OK", &dia); lay.addWidget( &pb ); connect(&pb, SIGNAL( clicked() ), &dia, SLOT ( accept() ) ); dia.show(); - int res = dia.exec(); - if ( res ) - retfile = lab.text(); - else + if ( ! dia.exec() ) return; dia.hide(); - passWordPiSync = lepw.text(); qApp->processEvents(); - KOPrefs::instance()->mPassiveSyncPort = retfile; + KOPrefs::instance()->mPassiveSyncPw = lepw.text(); + KOPrefs::instance()->mPassiveSyncPort = lab.text(); bool ok; - Q_UINT16 port = retfile.toUInt(&ok); + Q_UINT16 port = KOPrefs::instance()->mPassiveSyncPort.toUInt(&ok); if ( ! ok ) { KMessageBox::information( this, i18n("No valid port")); return; } //qDebug("port %d ", port); - mServerSocket = new KServerSocket ( passWordPiSync, port ,1 ); + mServerSocket = new KServerSocket ( KOPrefs::instance()->mPassiveSyncPw, port ,1 ); mServerSocket->setFileName( defaultFileName() ); //qDebug("connected "); if ( !mServerSocket->ok() ) { - qWarning("Failed to bind to port %d", port); + KMessageBox::information( this, i18n("Failed to bind or\nlisten to the port!")); delete mServerSocket; mServerSocket = 0; return; } connect( mServerSocket, SIGNAL ( saveFile() ), this, SLOT ( save() ) ); connect( mServerSocket, SIGNAL ( file_received( bool ) ), this, SLOT ( getFile( bool ) ) ); } void MainWindow::getFile( bool success ) { if ( ! success ) { setCaption( i18n("Error receiving file. Nothing changed!") ); return; } mView->watchSavedFile(); mView->openCalendar( defaultFileName() ); setCaption( i18n("Pi-Sync successful!") ); } void MainWindow::syncPi() { qApp->processEvents(); bool ok; Q_UINT16 port = KOPrefs::instance()->mActiveSyncPort.toUInt(&ok); if ( ! ok ) { setCaption( i18n("Sorry, no valid port.Syncing cancelled.") ); return; } KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, port, KOPrefs::instance()->mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int )), this, SLOT(deleteCommandSocket(KCommandSocket*, int)) ); setCaption( i18n("Sending request for remote file ...") ); commandSocket->readFile( syncFileName() ); } void MainWindow::deleteCommandSocket(KCommandSocket*s, int state) { qDebug("MainWindow::deleteCommandSocket %d", state); //enum { success, errorW, errorR, quiet }; if ( state == KCommandSocket::errorR ) { setCaption( i18n("ERROR: Receiving remote file failed.") ); delete s; KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); commandSocket->sendStop(); return; } else if ( state == KCommandSocket::errorW ) { setCaption( i18n("ERROR:Writing back file failed.") ); } else if ( state == KCommandSocket::successR ) { QTimer::singleShot( 1, this , SLOT ( readFileFromSocket())); } else if ( state == KCommandSocket::successW ) { setCaption( i18n("Pi-Sync succesful!") ); } delete s; } void MainWindow::readFileFromSocket() { QString fileName = syncFileName(); setCaption( i18n("Remote file saved to temp file.") ); if ( ! syncWithFile( fileName , true ) ) { setCaption( i18n("Syncing failed.") ); qDebug("Syncing failed "); return; } KCommandSocket* commandSocket = new KCommandSocket( mPassWordPiSync, KOPrefs::instance()->mActiveSyncPort.toUInt(), KOPrefs::instance()->mActiveSyncIP, this ); connect( commandSocket, SIGNAL(commandFinished( KCommandSocket*, int)), this, SLOT(deleteCommandSocket(KCommandSocket*, int )) ); if ( KOPrefs::instance()->mWriteBackFile ) commandSocket->writeFile( fileName ); else { commandSocket->sendStop(); setCaption( i18n("Pi-Sync succesful!") ); } } void MainWindow::syncLocalFile() { QString fn =KOPrefs::instance()->mLastSyncedLocalFile; fn =KFileDialog:: getOpenFileName( fn, i18n("Sync filename(*.ics/*.vcs)"), this ); if ( fn == "" ) return; //mView->setSyncDevice("local-file" ); if ( syncWithFile( fn, false ) ) { // Event* e = mView->getLastSyncEvent(); // e->setReadOnly( false ); // e->setLocation( i18n("Local file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); // e->setReadOnly( true ); } } bool MainWindow::syncWithFile( QString fn , bool quick ) { bool ret = false; QFileInfo info; info.setFile( fn ); QString mess; bool loadbup = true; if ( !info. exists() ) { mess = i18n( "Sync file \n...%1\ndoes not exist!\nNothing synced!\n").arg(fn.right( 30) ); int result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess ); return ret; } int result = 0; if ( !quick ) { mess = i18n("Sync with file \n...%1\nfrom:\n%2\n").arg(fn.right( 25)).arg(KGlobal::locale()->formatDateTime(info.lastModified (), true, false )); result = QMessageBox::warning( this, i18n("KO/Pi: Warning!"), mess, i18n("Sync"), i18n("Cancel"), 0, 0, 1 ); if ( result ) return false; } if ( KOPrefs::instance()->mAskForPreferences ) mView->edit_sync_options(); if ( result == 0 ) { //qDebug("Now sycing ... "); if ( ret = mView->syncCalendar( fn, KOPrefs::instance()->mSyncAlgoPrefs ) ) setCaption( i18n("Synchronization successful") ); else setCaption( i18n("Sync cancelled or failed. Nothing synced.") ); if ( ! quick ) KOPrefs::instance()->mLastSyncedLocalFile = fn; slotModifiedChanged( true ); } return ret; } void MainWindow::quickSyncLocalFile() { //mView->setSyncDevice("local-file" ); //qDebug("quickSyncLocalFile() "); if ( syncWithFile( KOPrefs::instance()->mLastSyncedLocalFile, false ) ) { // Event* e = mView->getLastSyncEvent(); // e->setReadOnly( false ); // e->setLocation( i18n("Quick with file: ")+ KOPrefs::instance()->mLastSyncedLocalFile); // e->setReadOnly( true ); } } void MainWindow::confSync() { mView->confSync(); fillSyncMenu(); } void MainWindow::syncRemote( KSyncProfile* prof, bool ask) { QString question; if ( ask ) { question = i18n("Do you really want\nto remote sync\nwith profile \n")+ prof->getName()+" ?\n"; if ( QMessageBox::information( this, i18n("KO/Pi Sync"), question, i18n("Yes"), i18n("No"), 0, 0 ) != 0 ) return; } QString command = prof->getPreSyncCommand(); int fi; if ( (fi = command.find("$PWD$")) > 0 ) { QString pwd = getPassword(); command = command.left( fi )+ pwd + command.mid( fi+5 ); } int maxlen = 30; if ( QApplication::desktop()->width() > 320 ) maxlen += 25; setCaption ( i18n( "Copy remote file to local machine..." ) ); int fileSize = 0; int result = system ( command ); // 0 : okay // 256: no such file or dir // qDebug("KO: Remote copy result(0 = okay): %d ",result ); if ( result != 0 ) { int len = maxlen; while ( len < command.length() ) { command.insert( len , "\n" ); len += maxlen +2; } question = i18n("Sorry, the copy command failed!\nCommand was:\n%1\n \nTry command on console to get more\ndetailed info about the reason.\n").arg (command) ; QMessageBox::information( this, i18n("KO/Pi Sync - ERROR"), question, i18n("Okay!")) ; setCaption ("KO/Pi"); return; } setCaption ( i18n( "Copying succeed." ) ); //qDebug(" file **%s** ",prof->getLocalTempFile().latin1() ); if ( syncWithFile( prof->getLocalTempFile(), true ) ) { // Event* e = mView->getLastSyncEvent(); // e->setReadOnly( false ); // e->setLocation( KOPrefs::instance()->mSyncProfileNames[mCurrentSyncProfile]); // e->setReadOnly( true ); if ( KOPrefs::instance()->mWriteBackFile ) { command = prof->getPostSyncCommand(); int fi; if ( (fi = command.find("$PWD$")) > 0 ) { QString pwd = getPassword(); command = command.left( fi )+ pwd + command.mid( fi+5 ); } setCaption ( i18n( "Writing back file ..." ) ); result = system ( command ); qDebug("KO: Writing back file result: %d ", result); if ( result != 0 ) { setCaption ( i18n( "Writing back file result: " )+QString::number( result ) ); return; } else { setCaption ( i18n( "Syncronization sucessfully completed" ) ); } } } return; } void MainWindow::syncSharp() { if ( mCalendarModifiedFlag ) save(); mView->syncSharp(); slotModifiedChanged( true ); } void MainWindow::syncPhone() { if ( mCalendarModifiedFlag ) save(); mView->syncPhone(); slotModifiedChanged( true ); } void MainWindow::printSel( ) { mView->viewManager()->agendaView()->agenda()->printSelection(); } void MainWindow::printCal() { mView->print();//mCp->showDialog(); } KServerSocket:: KServerSocket ( QString pw, Q_UINT16 port, int backlog, QObject * parent, const char * name ) : QServerSocket( port, backlog, parent, name ) { mPassWord = pw; mSocket = 0; mSyncActionDialog = 0; + blockRC = false; }; void KServerSocket::newConnection ( int socket ) { // qDebug("KServerSocket:New connection %d ", socket); if ( mSocket ) { qDebug("KServerSocket::newConnection Socket deleted! "); delete mSocket; mSocket = 0; } mSocket = new QSocket( this ); connect( mSocket , SIGNAL(readyRead()), this, SLOT(readClient()) ); connect( mSocket , SIGNAL(delayedCloseFinished()), this, SLOT(discardClient()) ); mSocket->setSocket( socket ); } void KServerSocket::discardClient() { //qDebug(" KServerSocket::discardClient()"); if ( mSocket ) { delete mSocket; mSocket = 0; } //emit endConnect(); } void KServerSocket::readClient() { + if ( blockRC ) + return; if ( mSocket == 0 ) { qDebug("ERROR::KServerSocket::readClient(): mSocket == 0 "); return; } - //qDebug("KServerSocket readClient()"); + qDebug("KServerSocket readClient()"); if ( mSocket->canReadLine() ) { - QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), mSocket->readLine() ); + QString line = mSocket->readLine(); + qDebug("KServerSocket readline: %s ", line.latin1()); + QStringList tokens = QStringList::split( QRegExp("[ \r\n][ \r\n]*"), line ); if ( tokens[0] == "GET" ) { if ( tokens[1] == mPassWord ) //emit sendFile( mSocket ); send_file(); else { KMessageBox::information( 0, i18n("ERROR:\nGot send file request\nwith invalid password")); qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "PUT" ) { - if ( tokens[1] == mPassWord ) + if ( tokens[1] == mPassWord ) { //emit getFile( mSocket ); + blockRC = true; get_file(); + } else { KMessageBox::information( 0, i18n("ERROR:\nGot receive file request\nwith invalid password")); qDebug("password %s, invalid password %s ",mPassWord.latin1(), tokens[1].latin1() ); } } if ( tokens[0] == "STOP" ) { //emit endConnect(); end_connect(); } } } void KServerSocket::end_connect() { delete mSyncActionDialog; mSyncActionDialog = 0; } void KServerSocket::send_file() { //qDebug("MainWindow::sendFile(QSocket* s) "); if ( mSyncActionDialog ) delete mSyncActionDialog; mSyncActionDialog = new QDialog ( 0, "input-dialog", true ); mSyncActionDialog->setCaption(i18n("Received sync request")); - QLabel* label = new QLabel( i18n("Synchronizing...\nDo not use this application!\n\nIf syncing fails you can close this dialog."), mSyncActionDialog ); + QLabel* label = new QLabel( i18n("Synchronizing from remote ...\n\nDo not use this application!\n\nIf syncing fails\nyou can close this dialog."), mSyncActionDialog ); QVBoxLayout* lay = new QVBoxLayout( mSyncActionDialog ); lay->addWidget( label); lay->setMargin(7); lay->setSpacing(7); mSyncActionDialog->setFixedSize( 230, 120); mSyncActionDialog->show(); qDebug("KSS::saving ... "); emit saveFile(); qApp->processEvents(); QString fileName = mFileName; QFile file( fileName ); if (!file.open( IO_ReadOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("KSS::error open file "); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); return ; } mSyncActionDialog->setCaption( i18n("Sending file...") ); QTextStream ts( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); QTextStream os( mSocket ); os.setCodec( QTextCodec::codecForName("utf8") ); //os.setEncoding( QTextStream::UnicodeUTF8 ); while ( ! ts.atEnd() ) { os << ts.readLine() << "\n"; } //os << ts.read(); file.close(); mSyncActionDialog->setCaption( i18n("Waiting for synced file...") ); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); } void KServerSocket::get_file() { mSyncActionDialog->setCaption( i18n("Receiving synced file...") ); piTime.start(); piFileString = ""; QTimer::singleShot( 1, this , SLOT (readBackFileFromSocket( ) )); } void KServerSocket::readBackFileFromSocket() { //qDebug("readBackFileFromSocket() %d ", piTime.elapsed ()); while ( mSocket->canReadLine () ) { piTime.restart(); QString line = mSocket->readLine (); piFileString += line; //qDebug("readline: %s ", line.latin1()); mSyncActionDialog->setCaption( i18n("Received %1 bytes").arg( piFileString.length() ) ); } if ( piTime.elapsed () < 3000 ) { // wait for more //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readBackFileFromSocket( ) )); return; } QString fileName = mFileName; QFile file ( fileName ); if (!file.open( IO_WriteOnly ) ) { delete mSyncActionDialog; mSyncActionDialog = 0; qDebug("error open cal file "); piFileString = ""; emit file_received( false ); + blockRC = false; return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); mSyncActionDialog->setCaption( i18n("Writing file to disk...") ); ts << piFileString; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( discardClient())); file.close(); delete mSyncActionDialog; mSyncActionDialog = 0; piFileString = ""; + blockRC = false; emit file_received( true ); } KCommandSocket::KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent, const char * name ): QObject( parent, name ) { mPassWord = password; mSocket = 0; mPort = port; mHost = host; mRetVal = quiet; mTimerSocket = new QTimer ( this ); connect( mTimerSocket, SIGNAL ( timeout () ), this, SLOT ( deleteSocket() ) ); } void KCommandSocket::readFile( QString fn ) { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(readyRead()), this, SLOT(startReadFileFromSocket()) ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } mFileString = ""; mFileName = fn; mFirst = true; mSocket->connectToHost( mHost, mPort ); QTextStream os( mSocket ); os.setEncoding( QTextStream::UnicodeUTF8 ); os << "GET " << mPassWord << "\r\n"; mTimerSocket->start( 10000 ); } void KCommandSocket::writeFile( QString fileName ) { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); connect( mSocket, SIGNAL(connected ()), this, SLOT(writeFileToSocket()) ); } mFileName = fileName ; mSocket->connectToHost( mHost, mPort ); } void KCommandSocket::writeFileToSocket() { QFile file2( mFileName ); if (!file2.open( IO_ReadOnly ) ) { mRetVal= errorW; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); return ; } QTextStream ts2( &file2 ); ts2.setCodec( QTextCodec::codecForName("utf8") ); QTextStream os2( mSocket ); os2.setCodec( QTextCodec::codecForName("utf8") ); os2 << "PUT " << mPassWord << "\r\n";; while ( ! ts2.atEnd() ) { os2 << ts2.readLine() << "\n"; } mRetVal= successW; file2.close(); mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KCommandSocket::sendStop() { if ( !mSocket ) { mSocket = new QSocket( this ); connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); } mSocket->connectToHost( mHost, mPort ); QTextStream os2( mSocket ); os2.setCodec( QTextCodec::codecForName("utf8") ); os2 << "STOP\r\n"; mSocket->close(); if ( mSocket->state() == QSocket::Idle ) QTimer::singleShot( 10, this , SLOT ( deleteSocket())); } void KCommandSocket::startReadFileFromSocket() { if ( ! mFirst ) return; mFirst = false; mTimerSocket->stop(); mFileString = ""; mTime.start(); QTimer::singleShot( 1, this , SLOT (readFileFromSocket( ) )); } void KCommandSocket::readFileFromSocket() { //qDebug("readBackFileFromSocket() %d ", mTime.elapsed ()); while ( mSocket->canReadLine () ) { mTime.restart(); QString line = mSocket->readLine (); mFileString += line; //qDebug("readline: %s ", line.latin1()); } if ( mTime.elapsed () < 3000 ) { // wait for more //qDebug("waitformore "); QTimer::singleShot( 100, this , SLOT (readFileFromSocket( ) )); return; } QString fileName = mFileName; QFile file ( fileName ); if (!file.open( IO_WriteOnly ) ) { mFileString = ""; mRetVal = errorR; qDebug("Error open temp calender file for writing: %s",fileName.latin1() ); deleteSocket(); return ; } // mView->setLoadedFileVersion(QDateTime::currentDateTime().addSecs( -1)); QTextStream ts ( &file ); ts.setCodec( QTextCodec::codecForName("utf8") ); ts << mFileString; file.close(); mFileString = ""; mRetVal = successR; mSocket->close(); // if state is not idle, deleteSocket(); is called via // connect( mSocket, SIGNAL(delayedCloseFinished ()), this, SLOT(deleteSocket()) ); if ( mSocket->state() == QSocket::Idle ) deleteSocket(); } void KCommandSocket::deleteSocket() { if ( mTimerSocket->isActive () ) { mTimerSocket->stop(); KMessageBox::information( 0, i18n("ERROR:\nConnection to remote host timed out!\nDid you forgot to enable\nsyncing on remote host? ")); mRetVal = errorR; } //qDebug("KCommandSocket::deleteSocket() %d", mRetVal ); if ( mSocket) delete mSocket; mSocket = 0; emit commandFinished( this, mRetVal ); } diff --git a/korganizer/mainwindow.h b/korganizer/mainwindow.h index ba627b9..7b24b88 100644 --- a/korganizer/mainwindow.h +++ b/korganizer/mainwindow.h @@ -1,208 +1,209 @@ #ifndef KORGE_MAINWINDOW_H #define KORGE_MAINWINDOW_H #include <qmainwindow.h> #include <qtimer.h> #include <qdict.h> #include <qfile.h> #include <qsocket.h> #include <qtextstream.h> #include <qregexp.h> #include <libkcal/incidence.h> #include "simplealarmclient.h" class QAction; class CalendarView; class KSyncProfile; #ifdef DESKTOP_VERSION #define QPEToolBar QToolBar #define QPEMenuBar QMenuBar #endif class QPEToolBar; #include <qserversocket.h> #include <qsocket.h> #include <qnetworkprotocol.h> class KServerSocket : public QServerSocket { Q_OBJECT public: KServerSocket ( QString password, Q_UINT16 port, int backlog = 0, QObject * parent=0, const char * name=0 ); void newConnection ( int socket ) ; void setFileName( QString fn ) {mFileName = fn;}; signals: //void sendFile(QSocket*); //void getFile(QSocket*); void file_received( bool ); //void file_sent(); void saveFile(); void endConnect(); private slots: void discardClient(); void readClient(); void readBackFileFromSocket(); private : + bool blockRC; void send_file(); void get_file(); void end_connect(); QDialog* mSyncActionDialog; QSocket* mSocket; QString mPassWord; QString mFileName; QTime piTime; QString piFileString; }; class KCommandSocket : public QObject { Q_OBJECT public: enum state { successR, errorR, successW, errorW, quiet }; KCommandSocket ( QString password, Q_UINT16 port, QString host, QObject * parent=0, const char * name=0 ); void readFile( QString ); void writeFile( QString ); void sendStop(); signals: void commandFinished( KCommandSocket*, int ); private slots: void startReadFileFromSocket(); void readFileFromSocket(); void deleteSocket(); void writeFileToSocket(); private : QSocket* mSocket; QString mPassWord; Q_UINT16 mPort; QString mHost; QString mFileName; QTimer* mTimerSocket; int mRetVal; QTime mTime; QString mFileString; bool mFirst; }; namespace KCal { class CalendarLocal; } using namespace KCal; class MainWindow : public QMainWindow { Q_OBJECT public: MainWindow( QWidget *parent = 0, const char *name = 0, QString command = ""); ~MainWindow(); public slots: virtual void showMaximized (); void configureAgenda( int ); void recieve( const QCString& msg, const QByteArray& data ); static QString defaultFileName(); static QString syncFileName(); static QString resourcePath(); protected slots: void setCaptionToDates(); int ringSync(); void multiSync( bool askforPrefs = false ); void about(); void licence(); void faq(); void usertrans(); void features(); void synchowto(); void whatsNew(); void keyBindings(); void aboutAutoSaving();; void aboutKnownBugs(); void processIncidenceSelection( Incidence * ); void importQtopia(); void importBday(); void importOL(); void importIcal(); void importFile( QString, bool ); void quickImportIcal(); void slotModifiedChanged( bool ); void save(); void configureToolBar( int ); void printSel(); void printCal(); void saveCalendar(); void loadCalendar(); void exportVCalendar(); void fillFilterMenu(); void selectFilter( int ); void slotSyncMenu( int ); void confSync(); void syncSharp(); void syncPhone(); void syncPi(); void syncLocalFile(); bool syncWithFile( QString, bool ); void quickSyncLocalFile(); protected: void displayText( QString, QString); void displayFile( QString, QString); void enableIncidenceActions( bool ); private slots: QSocket* piSocket; QString piFileString; QTime piTime; void deleteCommandSocket(KCommandSocket* s, int state ); void fillSyncMenu(); void getFile( bool ); void readFileFromSocket(); private: //QTimer* mTimerCommandSocket; QString mPassWordPiSync; KServerSocket * mServerSocket; bool mClosed; void saveOnClose(); int mCurrentSyncProfile; void enableQuick(); void syncRemote( KSyncProfile* , bool ask = true); bool mFlagKeyPressed; bool mBlockAtStartup; QPEToolBar *iconToolBar; void initActions(); void setDefaultPreferences(); void keyPressEvent ( QKeyEvent * ) ; void keyReleaseEvent ( QKeyEvent * ) ; QPopupMenu *configureToolBarMenu; QPopupMenu *selectFilterMenu; QPopupMenu *configureAgendaMenu, *syncMenu; CalendarLocal *mCalendar; CalendarView *mView; QString getPassword(); QAction *mNewSubTodoAction; QAction *mShowAction; QAction *mEditAction; QAction *mDeleteAction; void closeEvent( QCloseEvent* ce ); SimpleAlarmClient mAlarmClient; QTimer mSaveTimer; bool mBlockSaveFlag; bool mCalendarModifiedFlag; QPixmap loadPixmap( QString ); QDialog * mSyncActionDialog; }; #endif |