author | zautrix <zautrix> | 2004-08-20 23:53:07 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-20 23:53:07 (UTC) |
commit | ab07441b413dff6d478e2c3a39b823b4269931c5 (patch) (unidiff) | |
tree | 5de6576a6c0e20e4af2db7baa5019aa983e2195a | |
parent | bc33238f8038a03e04f25ea608c53e784616fee6 (diff) | |
download | kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.zip kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.tar.gz kdepimpi-ab07441b413dff6d478e2c3a39b823b4269931c5.tar.bz2 |
Sync fixes and fix of config loading bug
-rw-r--r-- | korganizer/koprefs.cpp | 118 | ||||
-rw-r--r-- | libkcal/phoneformat.cpp | 44 | ||||
-rw-r--r-- | libkcal/vcalformat.cpp | 19 | ||||
-rw-r--r-- | libkcal/vcalformat.h | 5 |
4 files changed, 115 insertions, 71 deletions
diff --git a/korganizer/koprefs.cpp b/korganizer/koprefs.cpp index 0db8e6d..dd978bf 100644 --- a/korganizer/koprefs.cpp +++ b/korganizer/koprefs.cpp | |||
@@ -1,566 +1,568 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of KOrganizer. | 2 | This file is part of KOrganizer. |
3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 3 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
4 | 4 | ||
5 | This program is free software; you can redistribute it and/or modify | 5 | This program is free software; you can redistribute it and/or modify |
6 | it under the terms of the GNU General Public License as published by | 6 | it under the terms of the GNU General Public License as published by |
7 | the Free Software Foundation; either version 2 of the License, or | 7 | the Free Software Foundation; either version 2 of the License, or |
8 | (at your option) any later version. | 8 | (at your option) any later version. |
9 | 9 | ||
10 | This program is distributed in the hope that it will be useful, | 10 | This program is distributed in the hope that it will be useful, |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
13 | GNU General Public License for more details. | 13 | GNU General Public License for more details. |
14 | 14 | ||
15 | You should have received a copy of the GNU General Public License | 15 | You should have received a copy of the GNU General Public License |
16 | along with this program; if not, write to the Free Software | 16 | along with this program; if not, write to the Free Software |
17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
18 | 18 | ||
19 | As a special exception, permission is given to link this program | 19 | As a special exception, permission is given to link this program |
20 | with any edition of Qt, and distribute the resulting executable, | 20 | with any edition of Qt, and distribute the resulting executable, |
21 | without including the source code for Qt in the source distribution. | 21 | without including the source code for Qt in the source distribution. |
22 | */ | 22 | */ |
23 | 23 | ||
24 | #include <time.h> | 24 | #include <time.h> |
25 | #ifndef _WIN32_ | 25 | #ifndef _WIN32_ |
26 | #include <unistd.h> | 26 | #include <unistd.h> |
27 | #endif | 27 | #endif |
28 | #include <qdir.h> | 28 | #include <qdir.h> |
29 | #include <qtextstream.h> | 29 | #include <qtextstream.h> |
30 | #include <qtextcodec.h> | 30 | #include <qtextcodec.h> |
31 | #include <qstring.h> | 31 | #include <qstring.h> |
32 | #include <qregexp.h> | 32 | #include <qregexp.h> |
33 | #include <qfont.h> | 33 | #include <qfont.h> |
34 | #include <qcolor.h> | 34 | #include <qcolor.h> |
35 | #include <qstringlist.h> | 35 | #include <qstringlist.h> |
36 | #include <stdlib.h> | 36 | #include <stdlib.h> |
37 | 37 | ||
38 | #include <kglobal.h> | 38 | #include <kglobal.h> |
39 | #include <kconfig.h> | 39 | #include <kconfig.h> |
40 | #include <klocale.h> | 40 | #include <klocale.h> |
41 | #include <kdebug.h> | 41 | #include <kdebug.h> |
42 | #include <kemailsettings.h> | 42 | #include <kemailsettings.h> |
43 | #include <kstaticdeleter.h> | 43 | #include <kstaticdeleter.h> |
44 | 44 | ||
45 | #include "koprefs.h" | 45 | #include "koprefs.h" |
46 | #include "mainwindow.h" | 46 | #include "mainwindow.h" |
47 | 47 | ||
48 | const char *germanwords[][2] = { | 48 | const char *germanwords[][2] = { |
49 | #include "wordsgerman.h" | 49 | #include "wordsgerman.h" |
50 | "", "" | 50 | "", "" |
51 | }; | 51 | }; |
52 | 52 | ||
53 | KOPrefs *KOPrefs::mInstance = 0; | 53 | KOPrefs *KOPrefs::mInstance = 0; |
54 | static KStaticDeleter<KOPrefs> insd; | 54 | static KStaticDeleter<KOPrefs> insd; |
55 | 55 | ||
56 | KOPrefs::KOPrefs() : | 56 | KOPrefs::KOPrefs() : |
57 | KPimPrefs("korganizerrc") | 57 | KPimPrefs("korganizerrc") |
58 | { | 58 | { |
59 | mCategoryColors.setAutoDelete(true); | 59 | mCategoryColors.setAutoDelete(true); |
60 | mLocaleDict = 0; | 60 | mLocaleDict = 0; |
61 | fillMailDefaults(); | 61 | fillMailDefaults(); |
62 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); | 62 | mDefaultCategoryColor = QColor(175,210,255);//196,196,196); |
63 | QColor defaultHolidayColor = QColor(255,0,0); | 63 | QColor defaultHolidayColor = QColor(255,0,0); |
64 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); | 64 | QColor defaultHighlightColor = QColor(129,112,255);//64,64,255); |
65 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); | 65 | QColor defaultAgendaBgColor = QColor(239,241,169);//128,128,128); |
66 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); | 66 | QColor defaultWorkingHoursColor = QColor(170,223,150);//160,160,160); |
67 | QColor defaultTodoDueTodayColor = QColor(255,220,100); | 67 | QColor defaultTodoDueTodayColor = QColor(255,220,100); |
68 | QColor defaultTodoOverdueColor = QColor(255,153,125); | 68 | QColor defaultTodoOverdueColor = QColor(255,153,125); |
69 | 69 | ||
70 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); | 70 | mTimeBarFont = QFont("helvetica",10);//,QFont::Bold); |
71 | mDefaultViewFont = QFont("helvetica",10); | 71 | mDefaultViewFont = QFont("helvetica",10); |
72 | mDefaultMonthViewFont = QFont("helvetica",8); | 72 | mDefaultMonthViewFont = QFont("helvetica",8); |
73 | mMarcusBainsFont= QFont("helvetica",10); | 73 | mMarcusBainsFont= QFont("helvetica",10); |
74 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); | 74 | mDateNavigatorFont= QFont("helvetica",10, QFont::Bold); |
75 | mEditBoxFont = QFont("helvetica",12); | 75 | mEditBoxFont = QFont("helvetica",12); |
76 | mJornalViewFont = QFont("helvetica",12); | 76 | mJornalViewFont = QFont("helvetica",12); |
77 | 77 | ||
78 | KPrefs::setCurrentGroup("General"); | 78 | KPrefs::setCurrentGroup("General"); |
79 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 79 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
80 | 80 | ||
81 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); | 81 | addItemBool("ShowIconNewTodo",&mShowIconNewTodo,true); |
82 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); | 82 | addItemBool("ShowIconNewEvent",&mShowIconNewEvent,true); |
83 | addItemBool("ShowIconSearch",&mShowIconSearch,true); | 83 | addItemBool("ShowIconSearch",&mShowIconSearch,true); |
84 | addItemBool("ShowIconList",&mShowIconList,true); | 84 | addItemBool("ShowIconList",&mShowIconList,true); |
85 | addItemBool("ShowIconDay1",&mShowIconDay1,true); | 85 | addItemBool("ShowIconDay1",&mShowIconDay1,true); |
86 | addItemBool("ShowIconDay5",&mShowIconDay5,true); | 86 | addItemBool("ShowIconDay5",&mShowIconDay5,true); |
87 | addItemBool("ShowIconDay7",&mShowIconDay7,true); | 87 | addItemBool("ShowIconDay7",&mShowIconDay7,true); |
88 | addItemBool("ShowIconMonth",&mShowIconMonth,true); | 88 | addItemBool("ShowIconMonth",&mShowIconMonth,true); |
89 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); | 89 | addItemBool("ShowIconTodoview",&mShowIconTodoview,true); |
90 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); | 90 | addItemBool("ShowIconBackFast",&mShowIconBackFast,true); |
91 | addItemBool("ShowIconBack",&mShowIconBack,true); | 91 | addItemBool("ShowIconBack",&mShowIconBack,true); |
92 | addItemBool("ShowIconToday",&mShowIconToday,true); | 92 | addItemBool("ShowIconToday",&mShowIconToday,true); |
93 | addItemBool("ShowIconForward",&mShowIconForward,true); | 93 | addItemBool("ShowIconForward",&mShowIconForward,true); |
94 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); | 94 | addItemBool("ShowIconForwardFast",&mShowIconForwardFast,true); |
95 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); | 95 | addItemBool("ShowIconWhatsThis",&mShowIconWhatsThis,false); |
96 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); | 96 | addItemBool("ShowIconNextDays",&mShowIconNextDays,true); |
97 | addItemBool("ShowIconNext",&mShowIconNext,true); | 97 | addItemBool("ShowIconNext",&mShowIconNext,true); |
98 | addItemBool("ShowIconJournal",&mShowIconJournal,true); | 98 | addItemBool("ShowIconJournal",&mShowIconJournal,true); |
99 | addItemBool("ShowIconStretch",&mShowIconStretch,true); | 99 | addItemBool("ShowIconStretch",&mShowIconStretch,true); |
100 | addItemBool("LanguageChanged",&mLanguageChanged,false); | 100 | addItemBool("LanguageChanged",&mLanguageChanged,false); |
101 | 101 | ||
102 | addItemBool("AskForQuit",&mAskForQuit,false); | 102 | addItemBool("AskForQuit",&mAskForQuit,false); |
103 | 103 | ||
104 | #ifndef DESKTOP_VERSION | 104 | #ifndef DESKTOP_VERSION |
105 | addItemBool("ShowFullMenu",&mShowFullMenu,false); | 105 | addItemBool("ShowFullMenu",&mShowFullMenu,false); |
106 | #else | 106 | #else |
107 | addItemBool("ShowFullMenu",&mShowFullMenu,true); | 107 | addItemBool("ShowFullMenu",&mShowFullMenu,true); |
108 | #endif | 108 | #endif |
109 | addItemBool("ToolBarHor",&mToolBarHor, true ); | 109 | addItemBool("ToolBarHor",&mToolBarHor, true ); |
110 | addItemBool("ToolBarUp",&mToolBarUp, false ); | 110 | addItemBool("ToolBarUp",&mToolBarUp, false ); |
111 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); | 111 | addItemBool("ToolBarMiniIcons",&mToolBarMiniIcons, false ); |
112 | addItemInt("Whats Next Days",&mWhatsNextDays,3); | 112 | addItemInt("Whats Next Days",&mWhatsNextDays,3); |
113 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); | 113 | addItemInt("Whats Next Prios",&mWhatsNextPrios,1); |
114 | 114 | ||
115 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); | 115 | addItemBool("ShowTodoInAgenda",&mShowTodoInAgenda,true); |
116 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); | 116 | addItemBool("ShowCompletedTodo",&mShowCompletedTodo,true); |
117 | addItemInt("AllDay Size",&mAllDaySize,28); | 117 | addItemInt("AllDay Size",&mAllDaySize,28); |
118 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; | 118 | QString defAlarm = KGlobal::iconLoader()->iconPath()+"koalarm.wav"; |
119 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); | 119 | addItemString("DefaultAlarmFile",&mDefaultAlarmFile,defAlarm ); |
120 | 120 | ||
121 | addItemStringList("LocationDefaults",&mLocationDefaults ); | 121 | addItemStringList("LocationDefaults",&mLocationDefaults ); |
122 | addItemStringList("EventSummary User",&mEventSummaryUser); | 122 | addItemStringList("EventSummary User",&mEventSummaryUser); |
123 | addItemStringList("TodoSummary User",&mTodoSummaryUser); | 123 | addItemStringList("TodoSummary User",&mTodoSummaryUser); |
124 | 124 | ||
125 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); | 125 | addItemBool("Enable Group Scheduling",&mEnableGroupScheduling,false); |
126 | addItemBool("Enable Project View",&mEnableProjectView,false); | 126 | addItemBool("Enable Project View",&mEnableProjectView,false); |
127 | addItemBool("Auto Save",&mAutoSave,false); | 127 | addItemBool("Auto Save",&mAutoSave,false); |
128 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); | 128 | addItemInt("Auto Save Interval",&mAutoSaveInterval,3); |
129 | addItemBool("Confirm Deletes",&mConfirm,true); | 129 | addItemBool("Confirm Deletes",&mConfirm,true); |
130 | addItemString("Archive File",&mArchiveFile); | 130 | addItemString("Archive File",&mArchiveFile); |
131 | addItemString("Html Export File",&mHtmlExportFile, | 131 | addItemString("Html Export File",&mHtmlExportFile, |
132 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); | 132 | QDir::homeDirPath() + "/" + i18n("Default export file", "calendar.html")); |
133 | addItemBool("Html With Save",&mHtmlWithSave,false); | 133 | addItemBool("Html With Save",&mHtmlWithSave,false); |
134 | 134 | ||
135 | KPrefs::setCurrentGroup("Personal Settings"); | 135 | KPrefs::setCurrentGroup("Personal Settings"); |
136 | 136 | ||
137 | addItemInt("Mail Client",&mMailClient,MailClientKMail); | 137 | addItemInt("Mail Client",&mMailClient,MailClientKMail); |
138 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); | 138 | addItemBool("Use Control Center Email",&mEmailControlCenter,false); |
139 | addItemBool("Bcc",&mBcc,false); | 139 | addItemBool("Bcc",&mBcc,false); |
140 | 140 | ||
141 | KPrefs::setCurrentGroup("Time & Date"); | 141 | KPrefs::setCurrentGroup("Time & Date"); |
142 | 142 | ||
143 | // addItemString("Time Zone",&mTimeZone,"+0100"); | 143 | // addItemString("Time Zone",&mTimeZone,"+0100"); |
144 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); | 144 | addItemString("TimeZoneName",&mTimeZoneId,i18n ("+01:00 Europe/Oslo(CET)") ); |
145 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); | 145 | // addItemInt("TimeZoneOffset",&mTimeZoneOffset,60); |
146 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); | 146 | addItemBool("UseDaylightsaving",&mUseDaylightsaving,true); |
147 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); | 147 | addItemInt("DaylightsavingStart",&mDaylightsavingStart,90); |
148 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); | 148 | addItemInt("DaylightsavingEnd",&mDaylightsavingEnd,304); |
149 | 149 | ||
150 | 150 | ||
151 | addItemInt("Default Start Time",&mStartTime,10); | 151 | addItemInt("Default Start Time",&mStartTime,10); |
152 | addItemInt("Default Duration",&mDefaultDuration,2); | 152 | addItemInt("Default Duration",&mDefaultDuration,2); |
153 | addItemInt("Default Alarm Time",&mAlarmTime,3); | 153 | addItemInt("Default Alarm Time",&mAlarmTime,3); |
154 | addItemInt("Daylight Savings",&mDaylightSavings,0); | 154 | addItemInt("Daylight Savings",&mDaylightSavings,0); |
155 | KPrefs::setCurrentGroup("AlarmSettings"); | 155 | KPrefs::setCurrentGroup("AlarmSettings"); |
156 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); | 156 | addItemInt("AlarmPlayBeeps",&mAlarmPlayBeeps,20); |
157 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); | 157 | addItemInt("AlarmSuspendTime",&mAlarmSuspendTime,7); |
158 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); | 158 | addItemInt("AlarmSuspendCount",&mAlarmSuspendCount,5); |
159 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); | 159 | addItemInt("AlarmBeepInterval",&mAlarmBeepInterval,3); |
160 | 160 | ||
161 | 161 | ||
162 | KPrefs::setCurrentGroup("Calendar"); | 162 | KPrefs::setCurrentGroup("Calendar"); |
163 | 163 | ||
164 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); | 164 | addItemInt("Default Calendar Format",&mDefaultFormat,FormatICalendar); |
165 | 165 | ||
166 | KPrefs::setCurrentGroup("Fonts"); | 166 | KPrefs::setCurrentGroup("Fonts"); |
167 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); | 167 | // qDebug(" KPrefs::setCurrentGroup(Fonts); "); |
168 | addItemFont("TimeBar Font",&mTimeBarFont); | 168 | addItemFont("TimeBar Font",&mTimeBarFont); |
169 | addItemFont("MonthView Font",&mMonthViewFont); | 169 | addItemFont("MonthView Font",&mMonthViewFont); |
170 | addItemFont("AgendaView Font",&mAgendaViewFont); | 170 | addItemFont("AgendaView Font",&mAgendaViewFont); |
171 | addItemFont("MarcusBains Font",&mMarcusBainsFont); | 171 | addItemFont("MarcusBains Font",&mMarcusBainsFont); |
172 | addItemFont("TimeLabels Font",&mTimeLabelsFont); | 172 | addItemFont("TimeLabels Font",&mTimeLabelsFont); |
173 | addItemFont("TodoView Font",&mTodoViewFont); | 173 | addItemFont("TodoView Font",&mTodoViewFont); |
174 | addItemFont("ListView Font",&mListViewFont); | 174 | addItemFont("ListView Font",&mListViewFont); |
175 | addItemFont("DateNavigator Font",&mDateNavigatorFont); | 175 | addItemFont("DateNavigator Font",&mDateNavigatorFont); |
176 | addItemFont("EditBox Font",&mEditBoxFont); | 176 | addItemFont("EditBox Font",&mEditBoxFont); |
177 | addItemFont("JournalView Font",&mJornalViewFont); | 177 | addItemFont("JournalView Font",&mJornalViewFont); |
178 | addItemFont("WhatsNextView Font",&mWhatsNextFont); | 178 | addItemFont("WhatsNextView Font",&mWhatsNextFont); |
179 | addItemFont("EventView Font",&mEventViewFont); | 179 | addItemFont("EventView Font",&mEventViewFont); |
180 | 180 | ||
181 | // KPrefs::setCurrentGroup("SyncProfiles"); | 181 | // KPrefs::setCurrentGroup("SyncProfiles"); |
182 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); | 182 | // addItemString("LocalMachineName",&mLocalMachineName, "undefined"); |
183 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); | 183 | // addItemStringList("SyncProfileNames",&mSyncProfileNames); |
184 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); | 184 | // addItemStringList("ExternSyncProfiles",&mExternSyncProfileNames); |
185 | 185 | ||
186 | KPrefs::setCurrentGroup("RemoteSyncing"); | 186 | KPrefs::setCurrentGroup("RemoteSyncing"); |
187 | // addItemBool("UsePasswd",&mUsePassWd,false); | 187 | // addItemBool("UsePasswd",&mUsePassWd,false); |
188 | // addItemBool("WriteBackFile",&mWriteBackFile,true); | 188 | // addItemBool("WriteBackFile",&mWriteBackFile,true); |
189 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); | 189 | // addItemBool("WriteBackExistingOnly",&mWriteBackExistingOnly,false); |
190 | // addItemBool("AskForPreferences",&mAskForPreferences,true); | 190 | // addItemBool("AskForPreferences",&mAskForPreferences,true); |
191 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); | 191 | // addItemBool("ShowSyncSummary",&mShowSyncSummary,true); |
192 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); | 192 | addItemBool("ShowSyncEvents",&mShowSyncEvents,false); |
193 | addItemInt("LastSyncTime",&mLastSyncTime,0); | 193 | addItemInt("LastSyncTime",&mLastSyncTime,0); |
194 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); | 194 | addItemInt("SyncAlgoPrefs",&mSyncAlgoPrefs,3); |
195 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); | 195 | addItemInt("RingSyncAlgoPrefs",&mRingSyncAlgoPrefs,3); |
196 | 196 | ||
197 | #ifdef _WIN32_ | 197 | #ifdef _WIN32_ |
198 | QString hdp= locateLocal("data","korganizer")+"\\\\"; | 198 | QString hdp= locateLocal("data","korganizer")+"\\\\"; |
199 | #else | 199 | #else |
200 | QString hdp= locateLocal("data","korganizer")+"/"; | 200 | QString hdp= locateLocal("data","korganizer")+"/"; |
201 | #endif | 201 | #endif |
202 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); | 202 | // addItemString("RemoteIP",&mRemoteIP, "192.168.0.65"); |
203 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); | 203 | // addItemString("RemoteUser",&mRemoteUser, "zaurus"); |
204 | // addItemString("RemotePassWd",&mRemotePassWd, ""); | 204 | // addItemString("RemotePassWd",&mRemotePassWd, ""); |
205 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); | 205 | // addItemString("RemoteFile", &mRemoteFile, hdp+"mycalendar.ics"); |
206 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); | 206 | // addItemString("LocalTempFile",&mLocalTempFile, "/tmp/tempsyncfile.ics" ); |
207 | 207 | ||
208 | 208 | ||
209 | KPrefs::setCurrentGroup("LoadSaveFileNames"); | 209 | KPrefs::setCurrentGroup("LoadSaveFileNames"); |
210 | 210 | ||
211 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); | 211 | addItemString("LastImportFile", &mLastImportFile ,hdp +"import.ics" ); |
212 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); | 212 | addItemString("LastVcalFile", &mLastVcalFile ,hdp +"export.vcs" ); |
213 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); | 213 | addItemString("LastSaveFile", &mLastSaveFile ,hdp +"mybackup.ics" ); |
214 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); | 214 | addItemString("LastLoadFile", &mLastLoadFile ,hdp +"mybackup.ics" ); |
215 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); | 215 | addItemString("LastSyncedLocalFile", &mLastSyncedLocalFile ,hdp +"lastsync.ics" ); |
216 | 216 | ||
217 | 217 | ||
218 | KPrefs::setCurrentGroup("Locale"); | 218 | KPrefs::setCurrentGroup("Locale"); |
219 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); | 219 | addItemInt("PreferredLanguage",&mPreferredLanguage,0); |
220 | addItemInt("PreferredTime",&mPreferredTime,0); | 220 | addItemInt("PreferredTime",&mPreferredTime,0); |
221 | addItemInt("PreferredDate",&mPreferredDate,0); | 221 | addItemInt("PreferredDate",&mPreferredDate,0); |
222 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); | 222 | addItemBool("WeekStartsOnSunday",&mWeekStartsOnSunday,false); |
223 | addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); | 223 | addItemBool("QuickSavingWOUnicode",&mUseQuicksave,false); |
224 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); | 224 | addItemBool("ShortDateInViewer",&mShortDateInViewer,false); |
225 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); | 225 | addItemString("UserDateFormatLong", &mUserDateFormatLong, "%A %d %b %y"); |
226 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); | 226 | addItemString("UserDateFormatShort", &mUserDateFormatShort, "%aK %d.%m.%y"); |
227 | 227 | ||
228 | 228 | ||
229 | KPrefs::setCurrentGroup("Colors"); | 229 | KPrefs::setCurrentGroup("Colors"); |
230 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); | 230 | addItemColor("Holiday Color",&mHolidayColor,defaultHolidayColor); |
231 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); | 231 | addItemColor("Highlight Color",&mHighlightColor,defaultHighlightColor); |
232 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); | 232 | addItemColor("Event Color",&mEventColor,mDefaultCategoryColor); |
233 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); | 233 | addItemColor("Agenda Background Color",&mAgendaBgColor,defaultAgendaBgColor); |
234 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); | 234 | addItemColor("WorkingHours Color",&mWorkingHoursColor,defaultWorkingHoursColor); |
235 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); | 235 | addItemColor("Todo due today Color",&mTodoDueTodayColor,defaultTodoDueTodayColor); |
236 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); | 236 | addItemColor("Todo overdue Color",&mTodoOverdueColor,defaultTodoOverdueColor); |
237 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); | 237 | addItemColor("MonthViewEvenColor",&mMonthViewEvenColor,QColor( 160,160,255 )); |
238 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); | 238 | addItemColor("MonthViewOddColor",&mMonthViewOddColor,QColor( 160,255,160 )); |
239 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); | 239 | addItemColor("MonthViewHolidayColor",&mMonthViewHolidayColor,QColor( 255,160,160 )); |
240 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); | 240 | addItemBool("MonthViewUsesDayColors",&mMonthViewUsesDayColors,true); |
241 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); | 241 | addItemBool("MonthViewSatSunTog",&mMonthViewSatSunTog,true); |
242 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); | 242 | addItemBool("HightlightDateTimeEdit",&mHightlightDateTimeEdit,false); |
243 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); | 243 | addItemColor("AppColor1",&mAppColor1,QColor( 130,170,255 )); |
244 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); | 244 | addItemColor("AppColor2",&mAppColor2,QColor( 174,216,255 )); |
245 | addItemBool("UseAppColors",&mUseAppColors,false); | 245 | addItemBool("UseAppColors",&mUseAppColors,false); |
246 | 246 | ||
247 | 247 | ||
248 | 248 | ||
249 | KPrefs::setCurrentGroup("Views"); | 249 | KPrefs::setCurrentGroup("Views"); |
250 | addItemInt("Hour Size",&mHourSize,8); | 250 | addItemInt("Hour Size",&mHourSize,8); |
251 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); | 251 | addItemBool("Show Daily Recurrences",&mDailyRecur,true); |
252 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); | 252 | addItemBool("Show Weekly Recurrences",&mWeeklyRecur,true); |
253 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); | 253 | addItemBool("Show Month Daily Recurrences",&mMonthDailyRecur,true); |
254 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); | 254 | addItemBool("Show Month Weekly Recurrences",&mMonthWeeklyRecur,true); |
255 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); | 255 | addItemBool("ShowShortMonthName",&mMonthShowShort,false); |
256 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); | 256 | addItemBool("ShowIconsInMonthCell",&mMonthShowIcons,true); |
257 | addItemBool("Enable ToolTips",&mEnableToolTips,false); | 257 | addItemBool("Enable ToolTips",&mEnableToolTips,false); |
258 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); | 258 | addItemBool("Enable MonthView ScrollBars",&mEnableMonthScroll,false); |
259 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); | 259 | addItemBool("Marcus Bains shows seconds",&mMarcusBainsShowSeconds,false); |
260 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); | 260 | addItemBool("Show Marcus Bains",&mMarcusBainsEnabled,true); |
261 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); | 261 | addItemBool("EditOnDoubleClick",&mEditOnDoubleClick,true); |
262 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); | 262 | addItemBool("ViewChangeHoldFullscreen",&mViewChangeHoldFullscreen,false); |
263 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); | 263 | addItemBool("ViewChangeHoldNonFullscreen",&mViewChangeHoldNonFullscreen,false); |
264 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); | 264 | addItemBool("CenterOnCurrentTime",&mCenterOnCurrentTime,false); |
265 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); | 265 | addItemBool("SetTimeToDayStartAt",&mSetTimeToDayStartAt,true); |
266 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); | 266 | addItemBool("HighlightCurrentDay",&mHighlightCurrentDay,true); |
267 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); | 267 | addItemBool("WNViewShowsParents",&mWNViewShowsParents,true); |
268 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); | 268 | addItemBool("WNViewShowLocation",&mWNViewShowLocation,false); |
269 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); | 269 | addItemBool("UseHighlightLightColor",&mUseHighlightLightColor,false); |
270 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); | 270 | addItemBool("ListViewMonthTimespan",&mListViewMonthTimespan,true); |
271 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); | 271 | addItemBool("TodoViewUsesCatColors",&mTodoViewUsesCatColors,false); |
272 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); | 272 | addItemBool("TodoViewShowsPercentage",&mTodoViewShowsPercentage,false); |
273 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); | 273 | addItemBool("TodoViewUsesSmallFont",&mTodoViewUsesSmallFont,false); |
274 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); | 274 | addItemBool("TodoViewUsesForegroundColor",&mTodoViewUsesForegroundColor,false); |
275 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); | 275 | addItemBool("MonthViewUsesForegroundColor",&mMonthViewUsesForegroundColor,false); |
276 | #ifdef DESKTOP_VERSION | 276 | #ifdef DESKTOP_VERSION |
277 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); | 277 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,true); |
278 | #else | 278 | #else |
279 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); | 279 | addItemBool("UseInternalAlarmNotification",&mUseInternalAlarmNotification,false); |
280 | #endif | 280 | #endif |
281 | addItemInt("Day Begins",&mDayBegins,7); | 281 | addItemInt("Day Begins",&mDayBegins,7); |
282 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); | 282 | addItemInt("Working Hours Start",&mWorkingHoursStart,8); |
283 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); | 283 | addItemInt("Working Hours End",&mWorkingHoursEnd,17); |
284 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); | 284 | addItemBool("Exclude Holidays",&mExcludeHolidays,true); |
285 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); | 285 | addItemBool("Exclude Saturdays",&mExcludeSaturdays,true); |
286 | 286 | ||
287 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); | 287 | addItemBool("Month View Uses Category Color",&mMonthViewUsesCategoryColor,false); |
288 | addItemBool("Full View Month",&mFullViewMonth,true); | 288 | addItemBool("Full View Month",&mFullViewMonth,true); |
289 | addItemBool("Full View Todo",&mFullViewTodo,true); | 289 | addItemBool("Full View Todo",&mFullViewTodo,true); |
290 | addItemBool("Quick Todo",&mEnableQuickTodo,false); | 290 | addItemBool("Quick Todo",&mEnableQuickTodo,false); |
291 | 291 | ||
292 | addItemInt("Next X Days",&mNextXDays,3); | 292 | addItemInt("Next X Days",&mNextXDays,3); |
293 | 293 | ||
294 | KPrefs::setCurrentGroup("Printer"); | 294 | KPrefs::setCurrentGroup("Printer"); |
295 | 295 | ||
296 | KPrefs::setCurrentGroup("Layout"); | 296 | KPrefs::setCurrentGroup("Layout"); |
297 | 297 | ||
298 | addItemBool("CompactDialogs",&mCompactDialogs,false); | 298 | addItemBool("CompactDialogs",&mCompactDialogs,false); |
299 | addItemBool("VerticalScreen",&mVerticalScreen,true); | 299 | addItemBool("VerticalScreen",&mVerticalScreen,true); |
300 | 300 | ||
301 | KPrefs::setCurrentGroup("KOrganizer Plugins"); | 301 | KPrefs::setCurrentGroup("KOrganizer Plugins"); |
302 | 302 | ||
303 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); | 303 | addItemStringList("SelectedPlugins",&mSelectedPlugins,"holidays"); |
304 | 304 | ||
305 | KPrefs::setCurrentGroup("Group Scheduling"); | 305 | KPrefs::setCurrentGroup("Group Scheduling"); |
306 | 306 | ||
307 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); | 307 | addItemInt("IMIPScheduler",&mIMIPScheduler,IMIPKMail); |
308 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); | 308 | addItemInt("IMIPSend",&mIMIPSend,IMIPdirectsend); |
309 | addItemStringList("AdditionalMails",&mAdditionalMails,""); | 309 | addItemStringList("AdditionalMails",&mAdditionalMails,""); |
310 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); | 310 | addItemInt("IMIP auto refresh",&mIMIPAutoRefresh,neverAuto); |
311 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); | 311 | addItemInt("IMIP auto insert request",&mIMIPAutoInsertRequest,neverAuto); |
312 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); | 312 | addItemInt("IMIP auto insert reply",&mIMIPAutoInsertReply,neverAuto); |
313 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); | 313 | addItemInt("IMIP auto FreeBusy",&mIMIPAutoFreeBusy,neverAuto); |
314 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); | 314 | addItemInt("IMIP auto save FreeBusy",&mIMIPAutoFreeBusyReply,neverAuto); |
315 | 315 | ||
316 | KPrefs::setCurrentGroup( "Editors" ); | 316 | KPrefs::setCurrentGroup( "Editors" ); |
317 | 317 | ||
318 | addItemStringList( "EventTemplates", &mEventTemplates ); | 318 | addItemStringList( "EventTemplates", &mEventTemplates ); |
319 | addItemStringList( "TodoTemplates", &mTodoTemplates ); | 319 | addItemStringList( "TodoTemplates", &mTodoTemplates ); |
320 | 320 | ||
321 | addItemInt("DestinationPolicy",&mDestination,standardDestination); | 321 | addItemInt("DestinationPolicy",&mDestination,standardDestination); |
322 | 322 | ||
323 | 323 | ||
324 | 324 | ||
325 | } | 325 | } |
326 | 326 | ||
327 | 327 | ||
328 | KOPrefs::~KOPrefs() | 328 | KOPrefs::~KOPrefs() |
329 | { | 329 | { |
330 | if (mInstance == this) | 330 | if (mInstance == this) |
331 | mInstance = insd.setObject(0); | 331 | mInstance = insd.setObject(0); |
332 | setLocaleDict( 0 ); | 332 | setLocaleDict( 0 ); |
333 | if ( mLocaleDict ) | 333 | if ( mLocaleDict ) |
334 | delete mLocaleDict; | 334 | delete mLocaleDict; |
335 | //qDebug("KOPrefs::~KOPrefs() "); | 335 | //qDebug("KOPrefs::~KOPrefs() "); |
336 | } | 336 | } |
337 | 337 | ||
338 | 338 | ||
339 | KOPrefs *KOPrefs::instance() | 339 | KOPrefs *KOPrefs::instance() |
340 | { | 340 | { |
341 | if (!mInstance) { | 341 | if (!mInstance) { |
342 | mInstance = insd.setObject(new KOPrefs()); | 342 | mInstance = insd.setObject(new KOPrefs()); |
343 | mInstance->readConfig(); | 343 | mInstance->readConfig(); |
344 | } | 344 | } |
345 | 345 | ||
346 | return mInstance; | 346 | return mInstance; |
347 | } | 347 | } |
348 | 348 | ||
349 | void KOPrefs::usrSetDefaults() | 349 | void KOPrefs::usrSetDefaults() |
350 | { | 350 | { |
351 | 351 | ||
352 | } | 352 | } |
353 | 353 | ||
354 | void KOPrefs::fillMailDefaults() | 354 | void KOPrefs::fillMailDefaults() |
355 | { | 355 | { |
356 | if (mName.isEmpty()) mName = i18n("Anonymous"); | 356 | if (mName.isEmpty()) mName = i18n("Anonymous"); |
357 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); | 357 | if (mEmail.isEmpty()) mEmail = i18n("nobody@nowhere"); |
358 | } | 358 | } |
359 | 359 | ||
360 | void KOPrefs::setTimeZoneIdDefault() | 360 | void KOPrefs::setTimeZoneIdDefault() |
361 | { | 361 | { |
362 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); | 362 | mTimeZoneId = i18n("+01:00 Europe/Oslo(CET)"); |
363 | } | 363 | } |
364 | 364 | ||
365 | void KOPrefs::setCategoryDefaults() | 365 | void KOPrefs::setCategoryDefaults() |
366 | { | 366 | { |
367 | mCustomCategories.clear(); | 367 | mCustomCategories.clear(); |
368 | mCustomCategories = getDefaultList(); | 368 | mCustomCategories = getDefaultList(); |
369 | 369 | ||
370 | QStringList::Iterator it; | 370 | QStringList::Iterator it; |
371 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 371 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
372 | setCategoryColor(*it,mDefaultCategoryColor); | 372 | setCategoryColor(*it,mDefaultCategoryColor); |
373 | } | 373 | } |
374 | } | 374 | } |
375 | 375 | ||
376 | QStringList KOPrefs::getDefaultList() | 376 | QStringList KOPrefs::getDefaultList() |
377 | { | 377 | { |
378 | QStringList retval ; | 378 | QStringList retval ; |
379 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") | 379 | retval << i18n("Anniversary") << i18n("Appointment") << i18n("Birthday") << i18n("Business") << i18n("Business Travel") << i18n("Cinema") << i18n("Customer") |
380 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") | 380 | << i18n("Break")<< i18n("Breakfast")<< i18n("Competition")<< i18n("Dinner") |
381 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") | 381 | << i18n("Education")<< i18n("Family") << i18n("Favorites") << i18n("Festival")<< i18n("Fishing")<< i18n("Flight") << i18n("Gifts") |
382 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") | 382 | << i18n("Holiday") << i18n("Holiday Cards")<< i18n("Hot Contacts") << i18n("Hiking") << i18n("Hunting") << i18n("Key Customer") << i18n("Kids") |
383 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") | 383 | << i18n("Lunch") << i18n("Meeting") << i18n("Miscellaneous") << i18n("Partner")<< i18n("Party") << i18n("Personal") << i18n("Personal Travel") |
384 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") | 384 | << i18n("PHB") << i18n("Phone Calls") << i18n("Projects") << i18n("Recurring") << i18n("School") << i18n("Shopping") |
385 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") | 385 | << i18n("Speach") << i18n("Special Occasion") << i18n("Sports") << i18n("Talk") << i18n("Travel") << i18n("TV")<< i18n("University") |
386 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; | 386 | << i18n("Vacation") << i18n("VIP") << i18n("SyncEvent") ; |
387 | retval.sort(); | 387 | retval.sort(); |
388 | return retval; | 388 | return retval; |
389 | } | 389 | } |
390 | 390 | ||
391 | void KOPrefs::usrReadConfig() | 391 | void KOPrefs::usrReadConfig() |
392 | { | 392 | { |
393 | mLocaleDict = 0; | 393 | mLocaleDict = 0; |
394 | // pending LR fix translation | 394 | // pending LR fix translation |
395 | // qDebug("KOPrefs::usrReadConfig() fix translation "); | 395 | // qDebug("KOPrefs::usrReadConfig() fix translation "); |
396 | if ( mPreferredLanguage == 1 ) { | 396 | if ( mPreferredLanguage > 0 && mPreferredLanguage < 4 ) { |
397 | mLocaleDict = new QDict<QString>; | 397 | if ( mPreferredLanguage == 1 ) { |
398 | int i = 0; | ||
399 | QString fw ( germanwords[i] [0]); | ||
400 | while ( !fw.isEmpty() ) { | ||
401 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); | ||
402 | ++i; | ||
403 | fw = germanwords[i] [0]; | ||
404 | } | ||
405 | |||
406 | setLocaleDict( mLocaleDict ); | ||
407 | } else { | ||
408 | QString fileName ; | ||
409 | if ( mPreferredLanguage == 3 ) | ||
410 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | ||
411 | else if ( mPreferredLanguage == 2 ) | ||
412 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | ||
413 | else return; | ||
414 | QFile file( fileName ); | ||
415 | if (file.open( IO_ReadOnly ) ) { | ||
416 | QTextStream ts( &file ); | ||
417 | ts.setCodec( QTextCodec::codecForLocale() ); | ||
418 | QString text = ts.read(); | ||
419 | file.close(); | ||
420 | text.replace( QRegExp("\\\\n"), "\n" ); | ||
421 | QString line; | ||
422 | QString we; | ||
423 | QString wt; | ||
424 | int br = 0; | ||
425 | int nbr; | ||
426 | nbr = text.find ( "},", br ); | ||
427 | line = text.mid( br, nbr - br ); | ||
428 | br = nbr+1; | ||
429 | int se, ee, st, et; | ||
430 | mLocaleDict = new QDict<QString>; | 398 | mLocaleDict = new QDict<QString>; |
431 | QString end = "{ \"\",\"\" }"; | 399 | int i = 0; |
432 | while ( (line != end) && (br > 1) ) { | 400 | QString fw ( germanwords[i] [0]); |
433 | //qDebug("%d *%s* ", br, line.latin1()); | 401 | while ( !fw.isEmpty() ) { |
434 | se = line.find("\"")+1; | 402 | mLocaleDict->insert( fw, new QString (germanwords[i] [1] )); |
435 | et = line.findRev("\"",-1); | 403 | ++i; |
436 | ee = line.find("\",\""); | 404 | fw = germanwords[i] [0]; |
437 | st = ee+3; | ||
438 | we = line.mid( se, ee-se ); | ||
439 | wt = line.mid( st, et-st ); | ||
440 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | ||
441 | mLocaleDict->insert( we, new QString (wt) ); | ||
442 | nbr = text.find ( "}", br ); | ||
443 | line = text.mid( br, nbr - br ); | ||
444 | br = nbr+1; | ||
445 | } | 405 | } |
446 | //qDebug("end *%s* ", end.latin1()); | 406 | |
447 | |||
448 | setLocaleDict( mLocaleDict ); | 407 | setLocaleDict( mLocaleDict ); |
449 | } else { | 408 | } else { |
450 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | 409 | QString fileName ; |
451 | } | 410 | if ( mPreferredLanguage == 3 ) |
411 | fileName = MainWindow::resourcePath()+"usertranslation.txt"; | ||
412 | else if ( mPreferredLanguage == 2 ) | ||
413 | fileName = MainWindow::resourcePath()+"frenchtranslation.txt"; | ||
414 | QFile file( fileName ); | ||
415 | if (file.open( IO_ReadOnly ) ) { | ||
416 | QTextStream ts( &file ); | ||
417 | ts.setEncoding( QTextStream::Latin1 ); | ||
418 | //ts.setCodec( QTextCodec::latin1 ); | ||
419 | QString text = ts.read(); | ||
420 | file.close(); | ||
421 | text.replace( QRegExp("\\\\n"), "\n" ); | ||
422 | QString line; | ||
423 | QString we; | ||
424 | QString wt; | ||
425 | int br = 0; | ||
426 | int nbr; | ||
427 | nbr = text.find ( "},", br ); | ||
428 | line = text.mid( br, nbr - br ); | ||
429 | br = nbr+1; | ||
430 | int se, ee, st, et; | ||
431 | mLocaleDict = new QDict<QString>; | ||
432 | QString end = "{ \"\",\"\" }"; | ||
433 | while ( (line != end) && (br > 1) ) { | ||
434 | //qDebug("%d *%s* ", br, line.latin1()); | ||
435 | se = line.find("\"")+1; | ||
436 | et = line.findRev("\"",-1); | ||
437 | ee = line.find("\",\""); | ||
438 | st = ee+3; | ||
439 | we = line.mid( se, ee-se ); | ||
440 | wt = line.mid( st, et-st ); | ||
441 | //qDebug("*%s* *%s* ", we.latin1(), wt.latin1()); | ||
442 | mLocaleDict->insert( we, new QString (wt) ); | ||
443 | nbr = text.find ( "}", br ); | ||
444 | line = text.mid( br, nbr - br ); | ||
445 | br = nbr+1; | ||
446 | } | ||
447 | //qDebug("end *%s* ", end.latin1()); | ||
448 | |||
449 | setLocaleDict( mLocaleDict ); | ||
450 | } else { | ||
451 | qDebug("KO: Cannot find translation file %s",fileName.latin1() ); | ||
452 | } | ||
452 | 453 | ||
453 | } | 454 | } |
455 | } | ||
454 | config()->setGroup("General"); | 456 | config()->setGroup("General"); |
455 | 457 | ||
456 | mCustomCategories = config()->readListEntry("Custom Categories"); | 458 | mCustomCategories = config()->readListEntry("Custom Categories"); |
457 | if ( KOPrefs::instance()->mLanguageChanged ) { | 459 | if ( KOPrefs::instance()->mLanguageChanged ) { |
458 | mLocationDefaults.clear(); | 460 | mLocationDefaults.clear(); |
459 | mEventSummaryUser.clear(); | 461 | mEventSummaryUser.clear(); |
460 | mTodoSummaryUser.clear(); | 462 | mTodoSummaryUser.clear(); |
461 | } | 463 | } |
462 | if (mLocationDefaults.isEmpty()) { | 464 | if (mLocationDefaults.isEmpty()) { |
463 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Libary") << i18n("School") << i18n("Doctor") << i18n("Beach") | 465 | mLocationDefaults << i18n("Home") << i18n("Office") << i18n("Library") << i18n("School") << i18n("Doctor") << i18n("Beach") |
464 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarden") | 466 | << i18n("University") << i18n("Restaurant") << i18n("Bar") << i18n("Conference room") << i18n("Cinema") << i18n("Lake") << i18n("Kindergarten") |
465 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; | 467 | << i18n("Germany") << i18n("Sweden") << i18n("Forest") << i18n("Desert") << i18n("Kitchen") ; |
466 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") | 468 | // << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") << i18n("") |
467 | mLocationDefaults.sort(); | 469 | mLocationDefaults.sort(); |
468 | } | 470 | } |
469 | 471 | ||
470 | if (mEventSummaryUser.isEmpty()) { | 472 | if (mEventSummaryUser.isEmpty()) { |
471 | mEventSummaryUser = getDefaultList() ; | 473 | mEventSummaryUser = getDefaultList() ; |
472 | } | 474 | } |
473 | if (mTodoSummaryUser.isEmpty()) { | 475 | if (mTodoSummaryUser.isEmpty()) { |
474 | mTodoSummaryUser = getDefaultList() ; | 476 | mTodoSummaryUser = getDefaultList() ; |
475 | } | 477 | } |
476 | 478 | ||
477 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); | 479 | if (mCustomCategories.isEmpty()) setCategoryDefaults(); |
478 | 480 | ||
479 | config()->setGroup("Personal Settings"); | 481 | config()->setGroup("Personal Settings"); |
480 | mName = config()->readEntry("user_name",""); | 482 | mName = config()->readEntry("user_name",""); |
481 | mEmail = config()->readEntry("user_email",""); | 483 | mEmail = config()->readEntry("user_email",""); |
482 | fillMailDefaults(); | 484 | fillMailDefaults(); |
483 | 485 | ||
484 | config()->setGroup("Category Colors"); | 486 | config()->setGroup("Category Colors"); |
485 | QStringList::Iterator it; | 487 | QStringList::Iterator it; |
486 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { | 488 | for (it = mCustomCategories.begin();it != mCustomCategories.end();++it ) { |
487 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); | 489 | setCategoryColor(*it,config()->readColorEntry(*it,&mDefaultCategoryColor)); |
488 | 490 | ||
489 | } | 491 | } |
490 | 492 | ||
491 | if (mTimeZoneId.isEmpty()) { | 493 | if (mTimeZoneId.isEmpty()) { |
492 | setTimeZoneIdDefault(); | 494 | setTimeZoneIdDefault(); |
493 | } | 495 | } |
494 | KPimPrefs::usrReadConfig(); | 496 | KPimPrefs::usrReadConfig(); |
495 | } | 497 | } |
496 | 498 | ||
497 | 499 | ||
498 | void KOPrefs::usrWriteConfig() | 500 | void KOPrefs::usrWriteConfig() |
499 | { | 501 | { |
500 | config()->setGroup("General"); | 502 | config()->setGroup("General"); |
501 | config()->writeEntry("Custom Categories",mCustomCategories); | 503 | config()->writeEntry("Custom Categories",mCustomCategories); |
502 | 504 | ||
503 | config()->setGroup("Personal Settings"); | 505 | config()->setGroup("Personal Settings"); |
504 | config()->writeEntry("user_name",mName); | 506 | config()->writeEntry("user_name",mName); |
505 | config()->writeEntry("user_email",mEmail); | 507 | config()->writeEntry("user_email",mEmail); |
506 | 508 | ||
507 | config()->setGroup("Category Colors"); | 509 | config()->setGroup("Category Colors"); |
508 | QDictIterator<QColor> it(mCategoryColors); | 510 | QDictIterator<QColor> it(mCategoryColors); |
509 | while (it.current()) { | 511 | while (it.current()) { |
510 | config()->writeEntry(it.currentKey(),*(it.current())); | 512 | config()->writeEntry(it.currentKey(),*(it.current())); |
511 | ++it; | 513 | ++it; |
512 | } | 514 | } |
513 | 515 | ||
514 | 516 | ||
515 | KPimPrefs::usrWriteConfig(); | 517 | KPimPrefs::usrWriteConfig(); |
516 | } | 518 | } |
517 | 519 | ||
518 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) | 520 | void KOPrefs::setCategoryColor(QString cat,const QColor & color) |
519 | { | 521 | { |
520 | mCategoryColors.replace(cat,new QColor(color)); | 522 | mCategoryColors.replace(cat,new QColor(color)); |
521 | } | 523 | } |
522 | 524 | ||
523 | QColor *KOPrefs::categoryColor(QString cat) | 525 | QColor *KOPrefs::categoryColor(QString cat) |
524 | { | 526 | { |
525 | QColor *color = 0; | 527 | QColor *color = 0; |
526 | 528 | ||
527 | if (!cat.isEmpty()) color = mCategoryColors[cat]; | 529 | if (!cat.isEmpty()) color = mCategoryColors[cat]; |
528 | 530 | ||
529 | if (color) return color; | 531 | if (color) return color; |
530 | else return &mDefaultCategoryColor; | 532 | else return &mDefaultCategoryColor; |
531 | } | 533 | } |
532 | 534 | ||
533 | void KOPrefs::setFullName(const QString &name) | 535 | void KOPrefs::setFullName(const QString &name) |
534 | { | 536 | { |
535 | mName = name; | 537 | mName = name; |
536 | } | 538 | } |
537 | 539 | ||
538 | void KOPrefs::setEmail(const QString &email) | 540 | void KOPrefs::setEmail(const QString &email) |
539 | { | 541 | { |
540 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); | 542 | //qDebug(" KOPrefs::setEmai*********** %s",email.latin1() ); |
541 | mEmail = email; | 543 | mEmail = email; |
542 | } | 544 | } |
543 | 545 | ||
544 | QString KOPrefs::fullName() | 546 | QString KOPrefs::fullName() |
545 | { | 547 | { |
546 | if (mEmailControlCenter) { | 548 | if (mEmailControlCenter) { |
547 | KEMailSettings settings; | 549 | KEMailSettings settings; |
548 | return settings.getSetting(KEMailSettings::RealName); | 550 | return settings.getSetting(KEMailSettings::RealName); |
549 | } else { | 551 | } else { |
550 | return mName; | 552 | return mName; |
551 | } | 553 | } |
552 | } | 554 | } |
553 | 555 | ||
554 | QString KOPrefs::email() | 556 | QString KOPrefs::email() |
555 | { | 557 | { |
556 | if (mEmailControlCenter) { | 558 | if (mEmailControlCenter) { |
557 | KEMailSettings settings; | 559 | KEMailSettings settings; |
558 | return settings.getSetting(KEMailSettings::EmailAddress); | 560 | return settings.getSetting(KEMailSettings::EmailAddress); |
559 | } else { | 561 | } else { |
560 | return mEmail; | 562 | return mEmail; |
561 | } | 563 | } |
562 | } | 564 | } |
563 | KConfig* KOPrefs::getConfig() | 565 | KConfig* KOPrefs::getConfig() |
564 | { | 566 | { |
565 | return config(); | 567 | return config(); |
566 | } | 568 | } |
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index 6276498..1769b37 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,1659 +1,1691 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | 3 | ||
4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2003 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qdatetime.h> | 22 | #include <qdatetime.h> |
23 | #include <qstring.h> | 23 | #include <qstring.h> |
24 | #include <qapplication.h> | 24 | #include <qapplication.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qmessagebox.h> | 27 | #include <qmessagebox.h> |
28 | #include <qclipboard.h> | 28 | #include <qclipboard.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | #include <qtextstream.h> | 30 | #include <qtextstream.h> |
31 | #include <qtextcodec.h> | 31 | #include <qtextcodec.h> |
32 | #include <qxml.h> | 32 | #include <qxml.h> |
33 | #include <qlabel.h> | 33 | #include <qlabel.h> |
34 | 34 | ||
35 | #include <kdebug.h> | 35 | #include <kdebug.h> |
36 | #include <klocale.h> | 36 | #include <klocale.h> |
37 | #include <kglobal.h> | 37 | #include <kglobal.h> |
38 | 38 | ||
39 | #include "calendar.h" | 39 | #include "calendar.h" |
40 | #include "alarm.h" | 40 | #include "alarm.h" |
41 | #include "recurrence.h" | 41 | #include "recurrence.h" |
42 | #include "calendarlocal.h" | 42 | #include "calendarlocal.h" |
43 | 43 | ||
44 | #include "phoneformat.h" | 44 | #include "phoneformat.h" |
45 | #include "syncdefines.h" | 45 | #include "syncdefines.h" |
46 | 46 | ||
47 | using namespace KCal; | 47 | using namespace KCal; |
48 | 48 | ||
49 | class PhoneParser : public QObject | 49 | class PhoneParser : public QObject |
50 | { | 50 | { |
51 | public: | 51 | public: |
52 | PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { | 52 | PhoneParser( Calendar *calendar, QString profileName ) : mCalendar( calendar ), mProfileName ( profileName ) { |
53 | ; | 53 | ; |
54 | } | 54 | } |
55 | bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) | 55 | bool readTodo( Calendar *existingCalendar,GSM_ToDoEntry *ToDo, GSM_StateMachine* s) |
56 | { | 56 | { |
57 | 57 | ||
58 | int id = ToDo->Location; | 58 | int id = ToDo->Location; |
59 | Todo *todo; | 59 | Todo *todo; |
60 | todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); | 60 | todo = existingCalendar->todo( mProfileName ,QString::number( id ) ); |
61 | if (todo ) | 61 | if (todo ) |
62 | todo = (Todo *)todo->clone(); | 62 | todo = (Todo *)todo->clone(); |
63 | else | 63 | else |
64 | todo = new Todo; | 64 | todo = new Todo; |
65 | todo->setID( mProfileName,QString::number( id ) ); | 65 | todo->setID( mProfileName,QString::number( id ) ); |
66 | todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 66 | todo->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
67 | int priority; | 67 | int priority; |
68 | switch (ToDo->Priority) { | 68 | switch (ToDo->Priority) { |
69 | case GSM_Priority_Low : priority = 5; break; | 69 | case GSM_Priority_Low : priority = 5; break; |
70 | case GSM_Priority_Medium : priority = 3; break; | 70 | case GSM_Priority_Medium : priority = 3; break; |
71 | case GSM_Priority_High : priority = 1; break; | 71 | case GSM_Priority_High : priority = 1; break; |
72 | default :priority = 3 ;break; | 72 | default :priority = 3 ;break; |
73 | } | 73 | } |
74 | todo->setPriority( priority ); | 74 | todo->setPriority( priority ); |
75 | GSM_Phone_Functions*Phone; | 75 | GSM_Phone_Functions*Phone; |
76 | Phone=s->Phone.Functions; | 76 | Phone=s->Phone.Functions; |
77 | int j; | 77 | int j; |
78 | GSM_DateTime* dtp; | 78 | GSM_DateTime* dtp; |
79 | bool alarm = false; | 79 | bool alarm = false; |
80 | QDateTime alarmDt; | 80 | QDateTime alarmDt; |
81 | GSM_Category Category; | 81 | GSM_Category Category; |
82 | int error; | 82 | int error; |
83 | for (j=0;j<ToDo->EntriesNum;j++) { | 83 | for (j=0;j<ToDo->EntriesNum;j++) { |
84 | 84 | ||
85 | //qDebug(" for todo %d",ToDo->Location ); | 85 | //qDebug(" for todo %d",ToDo->Location ); |
86 | switch (ToDo->Entries[j].EntryType) { | 86 | switch (ToDo->Entries[j].EntryType) { |
87 | case TODO_END_DATETIME: | 87 | case TODO_END_DATETIME: |
88 | dtp = &ToDo->Entries[j].Date ; | 88 | dtp = &ToDo->Entries[j].Date ; |
89 | todo->setDtDue (fromGSM ( dtp )); | 89 | todo->setDtDue (fromGSM ( dtp )); |
90 | break; | 90 | break; |
91 | case TODO_COMPLETED: | 91 | case TODO_COMPLETED: |
92 | if ( ToDo->Entries[j].Number == 1 ) { | 92 | if ( ToDo->Entries[j].Number == 1 ) { |
93 | todo->setCompleted( true ); | 93 | todo->setCompleted( true ); |
94 | } | 94 | } |
95 | else { | 95 | else { |
96 | todo->setCompleted( false ); | 96 | todo->setCompleted( false ); |
97 | } | 97 | } |
98 | break; | 98 | break; |
99 | case TODO_ALARM_DATETIME: | 99 | case TODO_ALARM_DATETIME: |
100 | dtp = &ToDo->Entries[j].Date ; | 100 | dtp = &ToDo->Entries[j].Date ; |
101 | alarm = true; | 101 | alarm = true; |
102 | alarmDt = fromGSM ( dtp ); | 102 | alarmDt = fromGSM ( dtp ); |
103 | break; | 103 | break; |
104 | case TODO_SILENT_ALARM_DATETIME: | 104 | case TODO_SILENT_ALARM_DATETIME: |
105 | dtp = &ToDo->Entries[j].Date ; | 105 | dtp = &ToDo->Entries[j].Date ; |
106 | alarm = true; | 106 | alarm = true; |
107 | alarmDt = fromGSM ( dtp ); | 107 | alarmDt = fromGSM ( dtp ); |
108 | break; | 108 | break; |
109 | case TODO_TEXT: | 109 | case TODO_TEXT: |
110 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); | 110 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); |
111 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); | 111 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); |
112 | break; | 112 | break; |
113 | case TODO_PRIVATE: | 113 | case TODO_PRIVATE: |
114 | if ( ToDo->Entries[j].Number == 1 ) | 114 | if ( ToDo->Entries[j].Number == 1 ) |
115 | todo->setSecrecy( Incidence::SecrecyPrivate ); | 115 | todo->setSecrecy( Incidence::SecrecyPrivate ); |
116 | else | 116 | else |
117 | todo->setSecrecy( Incidence::SecrecyPublic ); | 117 | todo->setSecrecy( Incidence::SecrecyPublic ); |
118 | break; | 118 | break; |
119 | case TODO_CATEGORY: | 119 | case TODO_CATEGORY: |
120 | Category.Location = ToDo->Entries[j].Number; | 120 | Category.Location = ToDo->Entries[j].Number; |
121 | Category.Type = Category_ToDo; | 121 | Category.Type = Category_ToDo; |
122 | error=Phone->GetCategory(s, &Category); | 122 | error=Phone->GetCategory(s, &Category); |
123 | if (error == ERR_NONE) { | 123 | if (error == ERR_NONE) { |
124 | QStringList cat = todo->categories(); | 124 | QStringList cat = todo->categories(); |
125 | QString nCat = QString ( (const char*)Category.Name ); | 125 | QString nCat = QString ( (const char*)Category.Name ); |
126 | if ( !nCat.isEmpty() ) | 126 | if ( !nCat.isEmpty() ) |
127 | if ( !cat.contains( nCat )) { | 127 | if ( !cat.contains( nCat )) { |
128 | cat << nCat; | 128 | cat << nCat; |
129 | todo->setCategories( cat ); | 129 | todo->setCategories( cat ); |
130 | } | 130 | } |
131 | } | 131 | } |
132 | break; | 132 | break; |
133 | case TODO_CONTACTID: | 133 | case TODO_CONTACTID: |
134 | #if 0 | 134 | #if 0 |
135 | // not supported | 135 | // not supported |
136 | entry.Location = ToDo->Entries[j].Number; | 136 | entry.Location = ToDo->Entries[j].Number; |
137 | entry.MemoryType = MEM_ME; | 137 | entry.MemoryType = MEM_ME; |
138 | error=Phone->GetMemory(s, &entry); | 138 | error=Phone->GetMemory(s, &entry); |
139 | if (error == ERR_NONE) { | 139 | if (error == ERR_NONE) { |
140 | name = GSM_PhonebookGetEntryName(&entry); | 140 | name = GSM_PhonebookGetEntryName(&entry); |
141 | if (name != NULL) { | 141 | if (name != NULL) { |
142 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); | 142 | printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); |
143 | } else { | 143 | } else { |
144 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); | 144 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); |
145 | } | 145 | } |
146 | } else { | 146 | } else { |
147 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); | 147 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); |
148 | } | 148 | } |
149 | #endif | 149 | #endif |
150 | break; | 150 | break; |
151 | case TODO_PHONE: | 151 | case TODO_PHONE: |
152 | #if 0 | 152 | #if 0 |
153 | // not supported | 153 | // not supported |
154 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | 154 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); |
155 | #endif | 155 | #endif |
156 | break; | 156 | break; |
157 | } | 157 | } |
158 | } | 158 | } |
159 | QString alarmString = "na"; | 159 | QString alarmString = "na"; |
160 | if ( alarm ) { | 160 | if ( alarm ) { |
161 | Alarm *alarm; | 161 | Alarm *alarm; |
162 | if ( todo->alarms().count() > 0 ) | 162 | if ( todo->alarms().count() > 0 ) |
163 | alarm = todo->alarms().first(); | 163 | alarm = todo->alarms().first(); |
164 | else { | 164 | else { |
165 | alarm = new Alarm( todo ); | 165 | alarm = new Alarm( todo ); |
166 | todo->addAlarm( alarm ); | 166 | todo->addAlarm( alarm ); |
167 | } | 167 | } |
168 | alarm->setType( Alarm::Audio ); | 168 | alarm->setType( Alarm::Audio ); |
169 | alarm->setEnabled( true ); | 169 | alarm->setEnabled( true ); |
170 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); | 170 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); |
171 | alarm->setStartOffset( -alarmOffset ); | 171 | alarm->setStartOffset( -alarmOffset ); |
172 | alarmString = QString::number( alarmOffset ); | 172 | alarmString = QString::number( alarmOffset ); |
173 | } else { | 173 | } else { |
174 | Alarm *alarm; | 174 | Alarm *alarm; |
175 | if ( todo->alarms().count() > 0 ) { | 175 | if ( todo->alarms().count() > 0 ) { |
176 | alarm = todo->alarms().first(); | 176 | alarm = todo->alarms().first(); |
177 | alarm->setType( Alarm::Audio ); | 177 | alarm->setType( Alarm::Audio ); |
178 | alarm->setStartOffset( -60*15 ); | 178 | alarm->setStartOffset( -60*15 ); |
179 | alarm->setEnabled( false ); | 179 | alarm->setEnabled( false ); |
180 | } | 180 | } |
181 | } | 181 | } |
182 | // csum ***************************************** | 182 | // csum ***************************************** |
183 | uint cSum; | 183 | uint cSum; |
184 | cSum = PhoneFormat::getCsumTodo( todo ); | 184 | cSum = PhoneFormat::getCsumTodo( todo ); |
185 | todo->setCsum( mProfileName, QString::number( cSum )); | 185 | todo->setCsum( mProfileName, QString::number( cSum )); |
186 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 186 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
187 | mCalendar->addTodo( todo); | 187 | mCalendar->addTodo( todo); |
188 | 188 | ||
189 | return true; | 189 | return true; |
190 | } | 190 | } |
191 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) | 191 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) |
192 | { | 192 | { |
193 | 193 | ||
194 | int id = Note->Location; | 194 | int id = Note->Location; |
195 | Event *event; | 195 | Event *event; |
196 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); | 196 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); |
197 | if ( event ) | 197 | if ( event ) |
198 | event = (Event*)event->clone(); | 198 | event = (Event*)event->clone(); |
199 | else | 199 | else |
200 | event = new Event; | 200 | event = new Event; |
201 | event->setID( mProfileName,QString::number( id ) ); | 201 | event->setID( mProfileName,QString::number( id ) ); |
202 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 202 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
203 | 203 | ||
204 | 204 | ||
205 | int i = 0; | 205 | int i = 0; |
206 | bool repeating = false; | 206 | bool repeating = false; |
207 | int repeat_dayofweek = -1; | 207 | int repeat_dayofweek = -1; |
208 | int repeat_day = -1; | 208 | int repeat_day = -1; |
209 | int repeat_weekofmonth = -1; | 209 | int repeat_weekofmonth = -1; |
210 | int repeat_month = -1; | 210 | int repeat_month = -1; |
211 | int repeat_frequency = -1; | 211 | int repeat_frequency = -1; |
212 | int rec_type = -1; | 212 | int rec_type = -1; |
213 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 213 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
214 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 214 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
215 | GSM_DateTime* dtp; | 215 | GSM_DateTime* dtp; |
216 | bool alarm = false; | 216 | bool alarm = false; |
217 | QDateTime alarmDt; | 217 | QDateTime alarmDt; |
218 | repeat_startdate.Day= 0; | 218 | repeat_startdate.Day= 0; |
219 | repeat_stopdate.Day = 0; | 219 | repeat_stopdate.Day = 0; |
220 | for (i=0;i<Note->EntriesNum;i++) { | 220 | for (i=0;i<Note->EntriesNum;i++) { |
221 | 221 | ||
222 | //qDebug(" for ev"); | 222 | //qDebug(" for ev"); |
223 | switch (Note->Entries[i].EntryType) { | 223 | switch (Note->Entries[i].EntryType) { |
224 | case CAL_START_DATETIME: | 224 | case CAL_START_DATETIME: |
225 | dtp = &Note->Entries[i].Date ; | 225 | dtp = &Note->Entries[i].Date ; |
226 | if ( dtp->Hour > 24 ) { | 226 | if ( dtp->Hour > 24 ) { |
227 | event->setFloats( true ); | 227 | event->setFloats( true ); |
228 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 228 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
229 | } else { | 229 | } else { |
230 | event->setDtStart (fromGSM ( dtp )); | 230 | event->setDtStart (fromGSM ( dtp )); |
231 | 231 | ||
232 | } | 232 | } |
233 | //Note->Entries[i].Date.Hour = 5; | 233 | //Note->Entries[i].Date.Hour = 5; |
234 | break; | 234 | break; |
235 | case CAL_END_DATETIME: | 235 | case CAL_END_DATETIME: |
236 | dtp = &Note->Entries[i].Date ; | 236 | dtp = &Note->Entries[i].Date ; |
237 | if ( dtp->Hour > 24 ) { | 237 | if ( dtp->Hour > 24 ) { |
238 | event->setFloats( true ); | 238 | event->setFloats( true ); |
239 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 239 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
240 | } else { | 240 | } else { |
241 | event->setDtEnd (fromGSM ( dtp )); | 241 | event->setDtEnd (fromGSM ( dtp )); |
242 | } | 242 | } |
243 | break; | 243 | break; |
244 | case CAL_ALARM_DATETIME: | 244 | case CAL_ALARM_DATETIME: |
245 | dtp = &Note->Entries[i].Date ; | 245 | dtp = &Note->Entries[i].Date ; |
246 | alarm = true; | 246 | alarm = true; |
247 | alarmDt = fromGSM ( dtp ); | 247 | alarmDt = fromGSM ( dtp ); |
248 | break; | 248 | break; |
249 | case CAL_SILENT_ALARM_DATETIME: | 249 | case CAL_SILENT_ALARM_DATETIME: |
250 | dtp = &Note->Entries[i].Date ; | 250 | dtp = &Note->Entries[i].Date ; |
251 | alarm = true; | 251 | alarm = true; |
252 | alarmDt = fromGSM ( dtp ); | 252 | alarmDt = fromGSM ( dtp ); |
253 | break; | 253 | break; |
254 | case CAL_RECURRANCE: | 254 | case CAL_RECURRANCE: |
255 | rec_type = Note->Entries[i].Number; | 255 | rec_type = Note->Entries[i].Number; |
256 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); | 256 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); |
257 | break; | 257 | break; |
258 | case CAL_TEXT: | 258 | case CAL_TEXT: |
259 | //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); | 259 | //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); |
260 | event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); | 260 | event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); |
261 | break; | 261 | break; |
262 | case CAL_LOCATION: | 262 | case CAL_LOCATION: |
263 | event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); | 263 | event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); |
264 | break; | 264 | break; |
265 | case CAL_PHONE: | 265 | case CAL_PHONE: |
266 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 266 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
267 | break; | 267 | break; |
268 | case CAL_PRIVATE: | 268 | case CAL_PRIVATE: |
269 | if ( Note->Entries[i].Number == 1 ) | 269 | if ( Note->Entries[i].Number == 1 ) |
270 | event->setSecrecy( Incidence::SecrecyPrivate ); | 270 | event->setSecrecy( Incidence::SecrecyPrivate ); |
271 | else | 271 | else |
272 | event->setSecrecy( Incidence::SecrecyPublic ); | 272 | event->setSecrecy( Incidence::SecrecyPublic ); |
273 | 273 | ||
274 | break; | 274 | break; |
275 | case CAL_CONTACTID: | 275 | case CAL_CONTACTID: |
276 | #if 0 | 276 | #if 0 |
277 | entry.Location = Note->Entries[i].Number; | 277 | entry.Location = Note->Entries[i].Number; |
278 | entry.MemoryType = MEM_ME; | 278 | entry.MemoryType = MEM_ME; |
279 | error=Phone->GetMemory(&s, &entry); | 279 | error=Phone->GetMemory(&s, &entry); |
280 | if (error == ERR_NONE) { | 280 | if (error == ERR_NONE) { |
281 | name = GSM_PhonebookGetEntryName(&entry); | 281 | name = GSM_PhonebookGetEntryName(&entry); |
282 | if (name != NULL) { | 282 | if (name != NULL) { |
283 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); | 283 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); |
284 | } else { | 284 | } else { |
285 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 285 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
286 | } | 286 | } |
287 | } else { | 287 | } else { |
288 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 288 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
289 | } | 289 | } |
290 | #endif | 290 | #endif |
291 | break; | 291 | break; |
292 | case CAL_REPEAT_DAYOFWEEK: | 292 | case CAL_REPEAT_DAYOFWEEK: |
293 | repeat_dayofweek = Note->Entries[i].Number; | 293 | repeat_dayofweek = Note->Entries[i].Number; |
294 | repeating = true; | 294 | repeating = true; |
295 | break; | 295 | break; |
296 | case CAL_REPEAT_DAY: | 296 | case CAL_REPEAT_DAY: |
297 | repeat_day = Note->Entries[i].Number; | 297 | repeat_day = Note->Entries[i].Number; |
298 | repeating = true; | 298 | repeating = true; |
299 | break; | 299 | break; |
300 | case CAL_REPEAT_WEEKOFMONTH: | 300 | case CAL_REPEAT_WEEKOFMONTH: |
301 | repeat_weekofmonth = Note->Entries[i].Number; | 301 | repeat_weekofmonth = Note->Entries[i].Number; |
302 | repeating = true; | 302 | repeating = true; |
303 | break; | 303 | break; |
304 | case CAL_REPEAT_MONTH: | 304 | case CAL_REPEAT_MONTH: |
305 | repeat_month = Note->Entries[i].Number; | 305 | repeat_month = Note->Entries[i].Number; |
306 | repeating = true; | 306 | repeating = true; |
307 | break; | 307 | break; |
308 | case CAL_REPEAT_FREQUENCY: | 308 | case CAL_REPEAT_FREQUENCY: |
309 | repeat_frequency = Note->Entries[i].Number; | 309 | repeat_frequency = Note->Entries[i].Number; |
310 | repeating = true; | 310 | repeating = true; |
311 | break; | 311 | break; |
312 | case CAL_REPEAT_STARTDATE: | 312 | case CAL_REPEAT_STARTDATE: |
313 | repeat_startdate = Note->Entries[i].Date; | 313 | repeat_startdate = Note->Entries[i].Date; |
314 | repeating = true; | 314 | repeating = true; |
315 | break; | 315 | break; |
316 | case CAL_REPEAT_STOPDATE: | 316 | case CAL_REPEAT_STOPDATE: |
317 | repeat_stopdate = Note->Entries[i].Date; | 317 | repeat_stopdate = Note->Entries[i].Date; |
318 | repeating = true; | 318 | repeating = true; |
319 | break; | 319 | break; |
320 | } | 320 | } |
321 | } | 321 | } |
322 | #if 0 | 322 | #if 0 |
323 | event->setDescription( attList[4] ); | 323 | event->setDescription( attList[4] ); |
324 | bool repeating = false; | 324 | bool repeating = false; |
325 | int repeat_dayofweek = -1; | 325 | int repeat_dayofweek = -1; |
326 | int repeat_day = -1; | 326 | int repeat_day = -1; |
327 | int repeat_weekofmonth = -1; | 327 | int repeat_weekofmonth = -1; |
328 | int repeat_month = -1; | 328 | int repeat_month = -1; |
329 | int repeat_frequency = -1; | 329 | int repeat_frequency = -1; |
330 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 330 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
331 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 331 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
332 | 332 | ||
333 | #endif | 333 | #endif |
334 | 334 | ||
335 | QString recurString = "no"; | 335 | QString recurString = "no"; |
336 | if ( repeating && repeat_frequency != -1) { | 336 | if ( repeating && repeat_frequency != -1) { |
337 | recurString = "y"; | 337 | recurString = "y"; |
338 | if ( repeat_dayofweek >= 0 ) | 338 | if ( repeat_dayofweek >= 0 ) |
339 | recurString += "dow" + QString::number (repeat_dayofweek); | 339 | recurString += "dow" + QString::number (repeat_dayofweek); |
340 | if ( repeat_day >= 0 ) | 340 | if ( repeat_day >= 0 ) |
341 | recurString += "d" + QString::number (repeat_day); | 341 | recurString += "d" + QString::number (repeat_day); |
342 | if ( repeat_weekofmonth >= 0 ) | 342 | if ( repeat_weekofmonth >= 0 ) |
343 | recurString += "w" + QString::number (repeat_weekofmonth); | 343 | recurString += "w" + QString::number (repeat_weekofmonth); |
344 | if ( repeat_month >= 0 ) | 344 | if ( repeat_month >= 0 ) |
345 | recurString += "m" + QString::number ( repeat_month ); | 345 | recurString += "m" + QString::number ( repeat_month ); |
346 | if ( repeat_frequency >= 0 ) | 346 | if ( repeat_frequency >= 0 ) |
347 | recurString += "f" + QString::number (repeat_frequency ); | 347 | recurString += "f" + QString::number (repeat_frequency ); |
348 | 348 | ||
349 | int rtype = 0; | 349 | int rtype = 0; |
350 | // qDebug("recurs "); | 350 | // qDebug("recurs "); |
351 | QDate startDate, endDate; | 351 | QDate startDate, endDate; |
352 | if ( repeat_startdate.Day > 0 ) { | 352 | if ( repeat_startdate.Day > 0 ) { |
353 | startDate = datefromGSM ( &repeat_startdate ); | 353 | startDate = datefromGSM ( &repeat_startdate ); |
354 | event->setDtStart(QDateTime ( startDate, event->dtStart().time())); | 354 | event->setDtStart(QDateTime ( startDate, event->dtStart().time())); |
355 | } else { | 355 | } else { |
356 | startDate = event->dtStart().date(); | 356 | startDate = event->dtStart().date(); |
357 | } | 357 | } |
358 | int freq = repeat_frequency; | 358 | int freq = repeat_frequency; |
359 | bool hasEndDate = false; | 359 | bool hasEndDate = false; |
360 | if ( repeat_stopdate.Day > 0 ) { | 360 | if ( repeat_stopdate.Day > 0 ) { |
361 | endDate = datefromGSM ( &repeat_stopdate ); | 361 | endDate = datefromGSM ( &repeat_stopdate ); |
362 | hasEndDate = true; | 362 | hasEndDate = true; |
363 | } | 363 | } |
364 | 364 | ||
365 | uint weekDaysNum = repeat_dayofweek ; | 365 | uint weekDaysNum = repeat_dayofweek ; |
366 | // 1 == monday, 7 == sunday | 366 | // 1 == monday, 7 == sunday |
367 | QBitArray weekDays( 7 ); | 367 | QBitArray weekDays( 7 ); |
368 | int i; | 368 | int i; |
369 | int bb = 1; | 369 | int bb = 1; |
370 | for( i = 1; i <= 7; ++i ) { | 370 | for( i = 1; i <= 7; ++i ) { |
371 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 371 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
372 | bb = 2 << (i-1); | 372 | bb = 2 << (i-1); |
373 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 373 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
374 | } | 374 | } |
375 | // qDebug("next "); | 375 | // qDebug("next "); |
376 | int pos = 0; | 376 | int pos = 0; |
377 | Recurrence *r = event->recurrence(); | 377 | Recurrence *r = event->recurrence(); |
378 | /* | 378 | /* |
379 | 0 daily; | 379 | 0 daily; |
380 | 1 weekly;x | 380 | 1 weekly;x |
381 | 2 monthpos;x | 381 | 2 monthpos;x |
382 | 3 monthlyday; | 382 | 3 monthlyday; |
383 | 4 rYearlyMont | 383 | 4 rYearlyMont |
384 | bool repeating = false; | 384 | bool repeating = false; |
385 | int repeat_dayofweek = -1; | 385 | int repeat_dayofweek = -1; |
386 | int repeat_day = -1; | 386 | int repeat_day = -1; |
387 | int repeat_weekofmonth = -1; | 387 | int repeat_weekofmonth = -1; |
388 | int repeat_month = -1; | 388 | int repeat_month = -1; |
389 | int repeat_frequency = -1; | 389 | int repeat_frequency = -1; |
390 | */ | 390 | */ |
391 | int dayOfWeek = startDate.dayOfWeek(); | 391 | int dayOfWeek = startDate.dayOfWeek(); |
392 | if ( repeat_weekofmonth >= 0 ) { | 392 | if ( repeat_weekofmonth >= 0 ) { |
393 | rtype = 2; // ************************ 2 MonthlyPos | 393 | rtype = 2; // ************************ 2 MonthlyPos |
394 | pos = repeat_weekofmonth; | 394 | pos = repeat_weekofmonth; |
395 | if ( repeat_dayofweek >= 0 ) | 395 | if ( repeat_dayofweek >= 0 ) |
396 | dayOfWeek = repeat_dayofweek; | 396 | dayOfWeek = repeat_dayofweek; |
397 | if (repeat_month > 0) { | 397 | if (repeat_month > 0) { |
398 | if ( repeat_month != event->dtStart().date().month() ) { | 398 | if ( repeat_month != event->dtStart().date().month() ) { |
399 | QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() ); | 399 | QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() ); |
400 | event->setDtStart(QDateTime ( date , event->dtStart().time()) ); | 400 | event->setDtStart(QDateTime ( date , event->dtStart().time()) ); |
401 | } | 401 | } |
402 | if ( freq == 1 ) | 402 | if ( freq == 1 ) |
403 | freq = 12; | 403 | freq = 12; |
404 | } | 404 | } |
405 | } else if ( repeat_dayofweek >= 0 ) { | 405 | } else if ( repeat_dayofweek >= 0 ) { |
406 | rtype = 1;// ************************ 1 Weekly | 406 | rtype = 1;// ************************ 1 Weekly |
407 | } else if ( repeat_day >= 0 ) { | 407 | } else if ( repeat_day >= 0 ) { |
408 | if ( repeat_month > 0) { | 408 | if ( repeat_month > 0) { |
409 | rtype = 4; | 409 | rtype = 4; |
410 | } else { | 410 | } else { |
411 | rtype = 3; | 411 | rtype = 3; |
412 | } | 412 | } |
413 | } else { | 413 | } else { |
414 | rtype = 0 ; | 414 | rtype = 0 ; |
415 | } | 415 | } |
416 | 416 | ||
417 | if ( rtype == 0 ) { | 417 | if ( rtype == 0 ) { |
418 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 418 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
419 | else r->setDaily( freq, -1 ); | 419 | else r->setDaily( freq, -1 ); |
420 | } else if ( rtype == 1 ) { | 420 | } else if ( rtype == 1 ) { |
421 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 421 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
422 | else r->setWeekly( freq, weekDays, -1 ); | 422 | else r->setWeekly( freq, weekDays, -1 ); |
423 | } else if ( rtype == 3 ) { | 423 | } else if ( rtype == 3 ) { |
424 | if ( hasEndDate ) | 424 | if ( hasEndDate ) |
425 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 425 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
426 | else | 426 | else |
427 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 427 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
428 | r->addMonthlyDay( startDate.day() ); | 428 | r->addMonthlyDay( startDate.day() ); |
429 | } else if ( rtype == 2 ) { | 429 | } else if ( rtype == 2 ) { |
430 | if ( hasEndDate ) | 430 | if ( hasEndDate ) |
431 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 431 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
432 | else | 432 | else |
433 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 433 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
434 | QBitArray days( 7 ); | 434 | QBitArray days( 7 ); |
435 | days.fill( false ); | 435 | days.fill( false ); |
436 | days.setBit( dayOfWeek - 1 ); | 436 | days.setBit( dayOfWeek - 1 ); |
437 | r->addMonthlyPos( pos, days ); | 437 | r->addMonthlyPos( pos, days ); |
438 | } else if ( rtype == 4 ) { | 438 | } else if ( rtype == 4 ) { |
439 | if ( hasEndDate ) | 439 | if ( hasEndDate ) |
440 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 440 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
441 | else | 441 | else |
442 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 442 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
443 | r->addYearlyNum( startDate.month() ); | 443 | r->addYearlyNum( startDate.month() ); |
444 | } | 444 | } |
445 | } else { | 445 | } else { |
446 | event->recurrence()->unsetRecurs(); | 446 | event->recurrence()->unsetRecurs(); |
447 | } | 447 | } |
448 | 448 | ||
449 | QStringList categoryList; | 449 | QStringList cat = event->categories(); |
450 | categoryList << getCategory( Note ); | 450 | QString nCat = getCategory( Note ); |
451 | event->setCategories( categoryList ); | 451 | |
452 | // strange 0 semms to mean: alarm enabled | 452 | if ( !nCat.isEmpty() ) |
453 | if ( !cat.contains( nCat )) { | ||
454 | cat << nCat; | ||
455 | event->setCategories( cat ); | ||
456 | } | ||
457 | |||
453 | if ( alarm ) { | 458 | if ( alarm ) { |
454 | Alarm *alarm; | 459 | Alarm *alarm; |
455 | if ( event->alarms().count() > 0 ) | 460 | if ( event->alarms().count() > 0 ) |
456 | alarm = event->alarms().first(); | 461 | alarm = event->alarms().first(); |
457 | else { | 462 | else { |
458 | alarm = new Alarm( event ); | 463 | alarm = new Alarm( event ); |
459 | event->addAlarm( alarm ); | 464 | event->addAlarm( alarm ); |
460 | } | 465 | } |
461 | alarm->setType( Alarm::Audio ); | 466 | alarm->setType( Alarm::Audio ); |
462 | alarm->setEnabled( true ); | 467 | alarm->setEnabled( true ); |
463 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); | 468 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); |
464 | alarm->setStartOffset( -alarmOffset ); | 469 | alarm->setStartOffset( -alarmOffset ); |
465 | } else { | 470 | } else { |
466 | Alarm *alarm; | 471 | Alarm *alarm; |
467 | if ( event->alarms().count() > 0 ) { | 472 | if ( event->alarms().count() > 0 ) { |
468 | alarm = event->alarms().first(); | 473 | alarm = event->alarms().first(); |
469 | alarm->setType( Alarm::Audio ); | 474 | alarm->setType( Alarm::Audio ); |
470 | alarm->setStartOffset( -60*15 ); | 475 | alarm->setStartOffset( -60*15 ); |
471 | alarm->setEnabled( false ); | 476 | alarm->setEnabled( false ); |
472 | } | 477 | } |
473 | } | 478 | } |
474 | // csum ***************************************** | 479 | // csum ***************************************** |
475 | 480 | ||
476 | uint cSum; | 481 | uint cSum; |
477 | cSum = PhoneFormat::getCsumEvent( event ); | 482 | cSum = PhoneFormat::getCsumEvent( event ); |
478 | event->setCsum( mProfileName, QString::number( cSum )); | 483 | event->setCsum( mProfileName, QString::number( cSum )); |
479 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 484 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
480 | mCalendar->addEvent( event); | 485 | mCalendar->addEvent( event); |
481 | 486 | ||
482 | return true; | 487 | return true; |
483 | } | 488 | } |
484 | 489 | ||
485 | 490 | ||
486 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = false ) { | 491 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = false ) { |
487 | QDateTime dt; | 492 | QDateTime dt; |
488 | int y,m,t,h,min,sec; | 493 | int y,m,t,h,min,sec; |
489 | y = dtp->Year; | 494 | y = dtp->Year; |
490 | m = dtp->Month; | 495 | m = dtp->Month; |
491 | t = dtp->Day; | 496 | t = dtp->Day; |
492 | h = dtp->Hour; | 497 | h = dtp->Hour; |
493 | min = dtp->Minute; | 498 | min = dtp->Minute; |
494 | sec = dtp->Second; | 499 | sec = dtp->Second; |
495 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 500 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
496 | // dtp->Timezone: offset in hours | 501 | // dtp->Timezone: offset in hours |
497 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 502 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
498 | if ( useTz ) | 503 | if ( useTz ) |
499 | dt = dt.addSecs ( offset*60); | 504 | dt = dt.addSecs ( offset*60); |
500 | return dt; | 505 | return dt; |
501 | 506 | ||
502 | } | 507 | } |
503 | 508 | ||
504 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) | 509 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
505 | { | 510 | { |
506 | QString datestr; | 511 | QString datestr; |
507 | QString timestr; | 512 | QString timestr; |
508 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 513 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
509 | QDateTime dt; | 514 | QDateTime dt; |
510 | if (useTZ) | 515 | if (useTZ) |
511 | dt = dti.addSecs ( -(offset*60)); | 516 | dt = dti.addSecs ( -(offset*60)); |
512 | else | 517 | else |
513 | dt = dti; | 518 | dt = dti; |
514 | if(dt.date().isValid()){ | 519 | if(dt.date().isValid()){ |
515 | const QDate& date = dt.date(); | 520 | const QDate& date = dt.date(); |
516 | datestr.sprintf("%04d%02d%02d", | 521 | datestr.sprintf("%04d%02d%02d", |
517 | date.year(), date.month(), date.day()); | 522 | date.year(), date.month(), date.day()); |
518 | } | 523 | } |
519 | if(dt.time().isValid()){ | 524 | if(dt.time().isValid()){ |
520 | const QTime& time = dt.time(); | 525 | const QTime& time = dt.time(); |
521 | timestr.sprintf("T%02d%02d%02d", | 526 | timestr.sprintf("T%02d%02d%02d", |
522 | time.hour(), time.minute(), time.second()); | 527 | time.hour(), time.minute(), time.second()); |
523 | } | 528 | } |
524 | return datestr + timestr; | 529 | return datestr + timestr; |
525 | } | 530 | } |
526 | QDate datefromGSM ( GSM_DateTime*dtp ) { | 531 | QDate datefromGSM ( GSM_DateTime*dtp ) { |
527 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); | 532 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); |
528 | } | 533 | } |
529 | QString getCategory( GSM_CalendarEntry*Note) | 534 | QString getCategory( GSM_CalendarEntry*Note) |
530 | { | 535 | { |
531 | QString CATEGORY; | 536 | QString CATEGORY; |
532 | switch (Note->Type) { | 537 | switch (Note->Type) { |
533 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; | 538 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; |
534 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; | 539 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; |
535 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; | 540 | //case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; |
536 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; | 541 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; |
537 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; | 542 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; |
538 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; | 543 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; |
539 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; | 544 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; |
540 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; | 545 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; |
541 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; | 546 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; |
542 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; | 547 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; |
543 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; | 548 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; |
544 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; | 549 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; |
545 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; | 550 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; |
546 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; | 551 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; |
547 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; | 552 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; |
548 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; | 553 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; |
549 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; | 554 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; |
550 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; | 555 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; |
551 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; | 556 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; |
552 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; | 557 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; |
553 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; | 558 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; |
554 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; | 559 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; |
555 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; | 560 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; |
556 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; | 561 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; |
557 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; | 562 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; |
558 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; | 563 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; |
559 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; | 564 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; |
560 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; | 565 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; |
561 | default : CATEGORY = QString(""); | 566 | default : CATEGORY = QString(""); |
562 | } | 567 | } |
563 | 568 | ||
564 | return CATEGORY; | 569 | return CATEGORY; |
565 | } | 570 | } |
566 | 571 | ||
567 | protected: | 572 | protected: |
568 | private: | 573 | private: |
569 | Calendar *mCalendar; | 574 | Calendar *mCalendar; |
570 | QString mProfileName ; | 575 | QString mProfileName ; |
571 | }; | 576 | }; |
572 | 577 | ||
573 | 578 | ||
574 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 579 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
575 | { | 580 | { |
576 | mProfileName = profileName; | 581 | mProfileName = profileName; |
577 | mDevice = device; | 582 | mDevice = device; |
578 | mConnection = connection; | 583 | mConnection = connection; |
579 | mModel = model; | 584 | mModel = model; |
580 | } | 585 | } |
581 | 586 | ||
582 | PhoneFormat::~PhoneFormat() | 587 | PhoneFormat::~PhoneFormat() |
583 | { | 588 | { |
584 | } | 589 | } |
585 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 590 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
586 | { | 591 | { |
587 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 592 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
588 | s->ConfigNum = 1; | 593 | s->ConfigNum = 1; |
589 | GSM_Config *cfg = &s->Config[0]; | 594 | GSM_Config *cfg = &s->Config[0]; |
590 | if ( ! mConnection.isEmpty() ) { | 595 | if ( ! mConnection.isEmpty() ) { |
591 | cfg->Connection = strdup(mConnection.latin1()); | 596 | cfg->Connection = strdup(mConnection.latin1()); |
592 | cfg->DefaultConnection = false; | 597 | cfg->DefaultConnection = false; |
593 | qDebug("Connection set %s ", cfg->Connection ); | 598 | qDebug("Connection set %s ", cfg->Connection ); |
594 | 599 | ||
595 | } | 600 | } |
596 | if ( ! mDevice.isEmpty() ) { | 601 | if ( ! mDevice.isEmpty() ) { |
597 | cfg->Device = strdup(mDevice.latin1()); | 602 | cfg->Device = strdup(mDevice.latin1()); |
598 | cfg->DefaultDevice = false; | 603 | cfg->DefaultDevice = false; |
599 | qDebug("Device set %s ", cfg->Device); | 604 | qDebug("Device set %s ", cfg->Device); |
600 | 605 | ||
601 | } | 606 | } |
602 | if ( ! mModel.isEmpty() ) { | 607 | if ( ! mModel.isEmpty() ) { |
603 | strcpy(cfg->Model,mModel.latin1() ); | 608 | strcpy(cfg->Model,mModel.latin1() ); |
604 | cfg->DefaultModel = false; | 609 | cfg->DefaultModel = false; |
605 | qDebug("Model set %s ",cfg->Model ); | 610 | qDebug("Model set %s ",cfg->Model ); |
606 | } | 611 | } |
607 | int error=GSM_InitConnection(s,3); | 612 | int error=GSM_InitConnection(s,3); |
608 | return error; | 613 | return error; |
609 | } | 614 | } |
610 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | 615 | ulong PhoneFormat::getCsumTodo( Todo* todo ) |
611 | { | 616 | { |
612 | QStringList attList; | 617 | QStringList attList; |
613 | if ( todo->hasDueDate() ) | 618 | if ( todo->hasDueDate() ) |
614 | attList << PhoneParser::dtToString ( todo->dtDue() ); | 619 | attList << PhoneParser::dtToString ( todo->dtDue() ); |
615 | attList << todo->summary(); | 620 | attList << todo->summary(); |
616 | QString completedString = "no"; | 621 | QString completedString = "no"; |
617 | if ( todo->isCompleted() ) | 622 | if ( todo->isCompleted() ) |
618 | completedString = "yes"; | 623 | completedString = "yes"; |
619 | attList << completedString; | 624 | attList << completedString; |
620 | attList << QString::number( todo->priority() ); | 625 | attList << QString::number( todo->priority() ); |
621 | QString alarmString = "na"; | 626 | QString alarmString = "na"; |
622 | Alarm *alarm; | 627 | Alarm *alarm; |
623 | if ( todo->alarms().count() > 0 ) { | 628 | if ( todo->alarms().count() > 0 ) { |
624 | alarm = todo->alarms().first(); | 629 | alarm = todo->alarms().first(); |
625 | if ( alarm->enabled() ) { | 630 | if ( alarm->enabled() ) { |
626 | alarmString = QString::number(alarm->startOffset().asSeconds() ); | 631 | alarmString = QString::number(alarm->startOffset().asSeconds() ); |
627 | } | 632 | } |
628 | } | 633 | } |
629 | attList << alarmString; | 634 | attList << alarmString; |
630 | attList << todo->categoriesStr(); | 635 | attList << todo->categoriesStr(); |
631 | attList << todo->secrecyStr(); | 636 | attList << todo->secrecyStr(); |
632 | return PhoneFormat::getCsum(attList ); | 637 | return PhoneFormat::getCsum(attList ); |
633 | 638 | ||
634 | } | 639 | } |
635 | ulong PhoneFormat::getCsumEvent( Event* event ) | 640 | ulong PhoneFormat::getCsumEvent( Event* event ) |
636 | { | 641 | { |
637 | QStringList attList; | 642 | QStringList attList; |
638 | attList << PhoneParser::dtToString ( event->dtStart() ); | 643 | attList << PhoneParser::dtToString ( event->dtStart() ); |
639 | attList << PhoneParser::dtToString ( event->dtEnd() ); | 644 | attList << PhoneParser::dtToString ( event->dtEnd() ); |
640 | attList << event->summary(); | 645 | attList << event->summary(); |
641 | attList << event->location(); | 646 | attList << event->location(); |
642 | QString alarmString = "na"; | 647 | QString alarmString = "na"; |
643 | Alarm *alarm; | 648 | Alarm *alarm; |
644 | if ( event->alarms().count() > 0 ) { | 649 | if ( event->alarms().count() > 0 ) { |
645 | alarm = event->alarms().first(); | 650 | alarm = event->alarms().first(); |
646 | if ( alarm->enabled() ) { | 651 | if ( alarm->enabled() ) { |
647 | alarmString = QString::number( alarm->startOffset().asSeconds() ); | 652 | alarmString = QString::number( alarm->startOffset().asSeconds() ); |
648 | } | 653 | } |
649 | } | 654 | } |
650 | attList << alarmString; | 655 | attList << alarmString; |
651 | Recurrence* rec = event->recurrence(); | 656 | Recurrence* rec = event->recurrence(); |
652 | QStringList list; | 657 | QStringList list; |
653 | bool writeEndDate = false; | 658 | bool writeEndDate = false; |
654 | switch ( rec->doesRecur() ) | 659 | switch ( rec->doesRecur() ) |
655 | { | 660 | { |
656 | case Recurrence::rDaily: // 0 | 661 | case Recurrence::rDaily: // 0 |
657 | list.append( "0" ); | 662 | list.append( "0" ); |
658 | list.append( QString::number( rec->frequency() ));//12 | 663 | list.append( QString::number( rec->frequency() ));//12 |
659 | list.append( "0" ); | 664 | list.append( "0" ); |
660 | list.append( "0" ); | 665 | list.append( "0" ); |
661 | writeEndDate = true; | 666 | writeEndDate = true; |
662 | break; | 667 | break; |
663 | case Recurrence::rWeekly:// 1 | 668 | case Recurrence::rWeekly:// 1 |
664 | list.append( "1" ); | 669 | list.append( "1" ); |
665 | list.append( QString::number( rec->frequency()) );//12 | 670 | list.append( QString::number( rec->frequency()) );//12 |
666 | list.append( "0" ); | 671 | list.append( "0" ); |
667 | { | 672 | { |
668 | int days = 0; | 673 | int days = 0; |
669 | QBitArray weekDays = rec->days(); | 674 | QBitArray weekDays = rec->days(); |
670 | int i; | 675 | int i; |
671 | for( i = 1; i <= 7; ++i ) { | 676 | for( i = 1; i <= 7; ++i ) { |
672 | if ( weekDays[i-1] ) { | 677 | if ( weekDays[i-1] ) { |
673 | days += 1 << (i-1); | 678 | days += 1 << (i-1); |
674 | } | 679 | } |
675 | } | 680 | } |
676 | list.append( QString::number( days ) ); | 681 | list.append( QString::number( days ) ); |
677 | } | 682 | } |
678 | //pending weekdays | 683 | //pending weekdays |
679 | writeEndDate = true; | 684 | writeEndDate = true; |
680 | 685 | ||
681 | break; | 686 | break; |
682 | case Recurrence::rMonthlyPos:// 2 | 687 | case Recurrence::rMonthlyPos:// 2 |
683 | list.append( "2" ); | 688 | list.append( "2" ); |
684 | list.append( QString::number( rec->frequency()) );//12 | 689 | list.append( QString::number( rec->frequency()) );//12 |
685 | 690 | ||
686 | writeEndDate = true; | 691 | writeEndDate = true; |
687 | { | 692 | { |
688 | int count = 1; | 693 | int count = 1; |
689 | QPtrList<Recurrence::rMonthPos> rmp; | 694 | QPtrList<Recurrence::rMonthPos> rmp; |
690 | rmp = rec->monthPositions(); | 695 | rmp = rec->monthPositions(); |
691 | if ( rmp.first()->negative ) | 696 | if ( rmp.first()->negative ) |
692 | count = 5 - rmp.first()->rPos - 1; | 697 | count = 5 - rmp.first()->rPos - 1; |
693 | else | 698 | else |
694 | count = rmp.first()->rPos - 1; | 699 | count = rmp.first()->rPos - 1; |
695 | list.append( QString::number( count ) ); | 700 | list.append( QString::number( count ) ); |
696 | 701 | ||
697 | } | 702 | } |
698 | 703 | ||
699 | list.append( "0" ); | 704 | list.append( "0" ); |
700 | break; | 705 | break; |
701 | case Recurrence::rMonthlyDay:// 3 | 706 | case Recurrence::rMonthlyDay:// 3 |
702 | list.append( "3" ); | 707 | list.append( "3" ); |
703 | list.append( QString::number( rec->frequency()) );//12 | 708 | list.append( QString::number( rec->frequency()) );//12 |
704 | list.append( "0" ); | 709 | list.append( "0" ); |
705 | list.append( "0" ); | 710 | list.append( "0" ); |
706 | writeEndDate = true; | 711 | writeEndDate = true; |
707 | break; | 712 | break; |
708 | case Recurrence::rYearlyMonth://4 | 713 | case Recurrence::rYearlyMonth://4 |
709 | list.append( "4" ); | 714 | list.append( "4" ); |
710 | list.append( QString::number( rec->frequency()) );//12 | 715 | list.append( QString::number( rec->frequency()) );//12 |
711 | list.append( "0" ); | 716 | list.append( "0" ); |
712 | list.append( "0" ); | 717 | list.append( "0" ); |
713 | writeEndDate = true; | 718 | writeEndDate = true; |
714 | break; | 719 | break; |
715 | 720 | ||
716 | default: | 721 | default: |
717 | list.append( "255" ); | 722 | list.append( "255" ); |
718 | list.append( QString() ); | 723 | list.append( QString() ); |
719 | list.append( "0" ); | 724 | list.append( "0" ); |
720 | list.append( QString() ); | 725 | list.append( QString() ); |
721 | list.append( "0" ); | 726 | list.append( "0" ); |
722 | list.append( "20991231T000000" ); | 727 | list.append( "20991231T000000" ); |
723 | break; | 728 | break; |
724 | } | 729 | } |
725 | if ( writeEndDate ) { | 730 | if ( writeEndDate ) { |
726 | 731 | ||
727 | if ( rec->endDate().isValid() ) { // 15 + 16 | 732 | if ( rec->endDate().isValid() ) { // 15 + 16 |
728 | list.append( "1" ); | 733 | list.append( "1" ); |
729 | list.append( PhoneParser::dtToString( rec->endDate()) ); | 734 | list.append( PhoneParser::dtToString( rec->endDate()) ); |
730 | } else { | 735 | } else { |
731 | list.append( "0" ); | 736 | list.append( "0" ); |
732 | list.append( "20991231T000000" ); | 737 | list.append( "20991231T000000" ); |
733 | } | 738 | } |
734 | 739 | ||
735 | } | 740 | } |
736 | attList << list.join(""); | 741 | attList << list.join(""); |
737 | attList << event->categoriesStr(); | 742 | attList << event->categoriesStr(); |
738 | attList << event->secrecyStr(); | 743 | attList << event->secrecyStr(); |
739 | return PhoneFormat::getCsum(attList ); | 744 | return PhoneFormat::getCsum(attList ); |
740 | } | 745 | } |
741 | ulong PhoneFormat::getCsum( const QStringList & attList) | 746 | ulong PhoneFormat::getCsum( const QStringList & attList) |
742 | { | 747 | { |
743 | int max = attList.count() -1; | 748 | int max = attList.count() -1; |
744 | ulong cSum = 0; | 749 | ulong cSum = 0; |
745 | int j,k,i; | 750 | int j,k,i; |
746 | int add; | 751 | int add; |
747 | for ( i = 1; i < max ; ++i ) { | 752 | for ( i = 1; i < max ; ++i ) { |
748 | QString s = attList[i]; | 753 | QString s = attList[i]; |
749 | if ( ! s.isEmpty() ){ | 754 | if ( ! s.isEmpty() ){ |
750 | j = s.length(); | 755 | j = s.length(); |
751 | for ( k = 0; k < j; ++k ) { | 756 | for ( k = 0; k < j; ++k ) { |
752 | int mul = k +1; | 757 | int mul = k +1; |
753 | add = s[k].unicode (); | 758 | add = s[k].unicode (); |
754 | if ( k < 16 ) | 759 | if ( k < 16 ) |
755 | mul = mul * mul; | 760 | mul = mul * mul; |
756 | add = add * mul *i*i*i; | 761 | add = add * mul *i*i*i; |
757 | cSum += add; | 762 | cSum += add; |
758 | } | 763 | } |
759 | } | 764 | } |
760 | } | 765 | } |
761 | return cSum; | 766 | return cSum; |
762 | 767 | ||
763 | } | 768 | } |
764 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 769 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
765 | #include <stdlib.h> | 770 | #include <stdlib.h> |
766 | #define DEBUGMODE false | 771 | #define DEBUGMODE false |
767 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 772 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
768 | { | 773 | { |
769 | GSM_StateMachines; | 774 | GSM_StateMachines; |
770 | qDebug(" load "); | 775 | qDebug(" load "); |
771 | s.opened = false; | 776 | s.opened = false; |
772 | s.msg = NULL; | 777 | s.msg = NULL; |
773 | s.ConfigNum = 0; | 778 | s.ConfigNum = 0; |
774 | QLabel status ( i18n("Opening device ..."), 0 ); | 779 | QLabel status ( i18n("Opening device ..."), 0 ); |
775 | int w = status.sizeHint().width()+20 ; | 780 | int w = status.sizeHint().width()+20 ; |
776 | if ( w < 200 ) w = 230; | 781 | if ( w < 200 ) w = 230; |
777 | int h = status.sizeHint().height()+20 ; | 782 | int h = status.sizeHint().height()+20 ; |
778 | int dw = QApplication::desktop()->width(); | 783 | int dw = QApplication::desktop()->width(); |
779 | int dh = QApplication::desktop()->height(); | 784 | int dh = QApplication::desktop()->height(); |
780 | status.setCaption(i18n("Reading phone...") ); | 785 | status.setCaption(i18n("Reading phone...") ); |
781 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 786 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
782 | status.show(); | 787 | status.show(); |
783 | status.raise(); | 788 | status.raise(); |
784 | qApp->processEvents(); | 789 | qApp->processEvents(); |
785 | 790 | ||
786 | int error=initDevice(&s); | 791 | int error=initDevice(&s); |
787 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); | 792 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); |
788 | if ( error != ERR_NONE ) | 793 | if ( error != ERR_NONE ) |
789 | return false; | 794 | return false; |
790 | GSM_Phone_Functions*Phone; | 795 | GSM_Phone_Functions*Phone; |
791 | GSM_CalendarEntrynote; | 796 | GSM_CalendarEntrynote; |
792 | bool start = true; | 797 | bool start = true; |
793 | Phone=s.Phone.Functions; | 798 | Phone=s.Phone.Functions; |
794 | bool gshutdown = false; | 799 | bool gshutdown = false; |
795 | PhoneParser handler( calendar, mProfileName ); | 800 | PhoneParser handler( calendar, mProfileName ); |
796 | int ccc = 0; | 801 | int ccc = 0; |
797 | QString message = i18n(" Reading event # "); | 802 | QString message = i18n(" Reading event # "); |
798 | int procCount = 0; | 803 | int procCount = 0; |
799 | qDebug("Debug: only 10 calender items are downloaded "); | 804 | qDebug("Debug: only 10 calender items are downloaded "); |
800 | while (!gshutdown && ccc++ < 10) { | 805 | while (!gshutdown && ccc++ < 10) { |
801 | status.setText ( message + QString::number ( ++procCount ) ); | 806 | status.setText ( message + QString::number ( ++procCount ) ); |
802 | qApp->processEvents(); | 807 | qApp->processEvents(); |
803 | qDebug("readEvent %d ", ccc); | 808 | qDebug("readEvent %d ", ccc); |
804 | error=Phone->GetNextCalendar(&s,¬e,start); | 809 | error=Phone->GetNextCalendar(&s,¬e,start); |
805 | if (error == ERR_EMPTY) break; | 810 | if (error == ERR_EMPTY) break; |
806 | start = false; | 811 | start = false; |
807 | handler.readEvent( existingCal, ¬e ); | 812 | handler.readEvent( existingCal, ¬e ); |
808 | qDebug("Org loc %d ",note.Location); | 813 | qDebug("Org loc %d ",note.Location); |
809 | //note.Location = 0; | 814 | //note.Location = 0; |
810 | error=Phone->SetCalendar(&s,¬e); | 815 | error=Phone->SetCalendar(&s,¬e); |
811 | qDebug("new loc %d ",note.Location); | 816 | qDebug("new loc %d ",note.Location); |
812 | } | 817 | } |
813 | 818 | ||
814 | start = true; | 819 | start = true; |
815 | GSM_ToDoEntry ToDo; | 820 | GSM_ToDoEntry ToDo; |
816 | ccc = 0; | 821 | ccc = 0; |
817 | message = i18n(" Reading todo # "); | 822 | message = i18n(" Reading todo # "); |
818 | procCount = 0; | 823 | procCount = 0; |
819 | while (!gshutdown && ccc++ < 10) { | 824 | while (!gshutdown && ccc++ < 10) { |
820 | status.setText ( message + QString::number ( ++procCount ) ); | 825 | status.setText ( message + QString::number ( ++procCount ) ); |
821 | qApp->processEvents(); | 826 | qApp->processEvents(); |
822 | error = Phone->GetNextToDo(&s, &ToDo, start); | 827 | error = Phone->GetNextToDo(&s, &ToDo, start); |
823 | if (error == ERR_EMPTY) break; | 828 | if (error == ERR_EMPTY) break; |
824 | start = false; | 829 | start = false; |
825 | qDebug("ReadTodo %d ", ccc); | 830 | qDebug("ReadTodo %d ", ccc); |
826 | handler.readTodo( existingCal, &ToDo, &s); | 831 | handler.readTodo( existingCal, &ToDo, &s); |
827 | 832 | ||
828 | } | 833 | } |
829 | 834 | ||
830 | error=GSM_TerminateConnection(&s); | 835 | error=GSM_TerminateConnection(&s); |
831 | 836 | ||
832 | return true; | 837 | return true; |
833 | } | 838 | } |
834 | #include <qcstring.h> | 839 | #include <qcstring.h> |
835 | void PhoneFormat::event2GSM( Calendar *cal,Event* ev, GSM_CalendarEntry*Note ) | 840 | void PhoneFormat::event2GSM( Calendar *cal,Event* ev, GSM_CalendarEntry*Note ) |
836 | { | 841 | { |
837 | QString eText = vfconverter.eventToString( ev, cal ); | 842 | QString eText = vfconverter.eventToString( ev, cal ); |
838 | int pos = 0; | 843 | int pos = 0; |
839 | GSM_ToDoEntry dummy; | 844 | GSM_ToDoEntry dummy; |
840 | qDebug( "Convert event"); | 845 | qDebug( "Convert event"); |
841 | QByteArray ba; | 846 | QByteArray ba; |
842 | QDataStream s ( ba, IO_WriteOnly ); | 847 | QDataStream s ( ba, IO_WriteOnly ); |
843 | s << eText.utf8(); | 848 | s << eText.utf8(); |
844 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); | 849 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); |
845 | qDebug( "Convert event done"); | 850 | qDebug( "Convert event done"); |
846 | Note->Location = 0; | 851 | Note->Location = 0; |
847 | QString loc = ev->getID(mProfileName); | 852 | QString loc = ev->getID(mProfileName); |
848 | if ( !loc.isEmpty() ){ | 853 | if ( !loc.isEmpty() ){ |
849 | Note->Location = loc.toInt(); | 854 | Note->Location = loc.toInt(); |
850 | } | 855 | } |
851 | 856 | ||
852 | } | 857 | } |
853 | void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo ) | 858 | void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo ) |
854 | { | 859 | { |
855 | qDebug( "Convert todo1"); | 860 | qDebug( "Convert todo1"); |
856 | QString tText = vfconverter.todoToString( todo, cal ); | 861 | QString tText = vfconverter.todoToString( todo, cal ); |
857 | int pos = 0; | 862 | int pos = 0; |
858 | GSM_CalendarEntry dummy; | 863 | GSM_CalendarEntry dummy; |
859 | QByteArray ba; | 864 | QByteArray ba; |
860 | QDataStream s ( ba, IO_WriteOnly ); | 865 | QDataStream s ( ba, IO_WriteOnly ); |
861 | s << tText.utf8(); | 866 | s << tText.utf8(); |
862 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); | 867 | GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); |
863 | qDebug( "Convert todo done "); | 868 | qDebug( "Convert todo done "); |
864 | gsmTodo->Location = 0; | 869 | gsmTodo->Location = 0; |
865 | QString loc = todo->getID(mProfileName); | 870 | QString loc = todo->getID(mProfileName); |
866 | if ( !loc.isEmpty() ){ | 871 | if ( !loc.isEmpty() ){ |
867 | gsmTodo->Location = loc.toInt(); | 872 | gsmTodo->Location = loc.toInt(); |
868 | } | 873 | } |
869 | 874 | ||
870 | } | 875 | } |
871 | void PhoneFormat::afterSave( Incidence* inc) | 876 | void PhoneFormat::afterSave( Incidence* inc) |
872 | { | 877 | { |
873 | uint csum; | 878 | uint csum; |
874 | inc->removeID( mProfileName ); | 879 | inc->removeID( mProfileName ); |
875 | if ( inc->type() == "Event") | 880 | if ( inc->type() == "Event") |
876 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | 881 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); |
877 | else | 882 | else |
878 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | 883 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); |
879 | inc->setCsum( mProfileName, QString::number( csum )); | 884 | inc->setCsum( mProfileName, QString::number( csum )); |
880 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 885 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
881 | 886 | ||
882 | } | 887 | } |
883 | bool PhoneFormat::save( Calendar *calendar) | 888 | bool PhoneFormat::save( Calendar *calendar) |
884 | { | 889 | { |
885 | 890 | ||
886 | GSM_StateMachines; | 891 | GSM_StateMachines; |
887 | qDebug(" save "); | 892 | qDebug(" save "); |
888 | s.opened = false; | 893 | s.opened = false; |
889 | s.msg = NULL; | 894 | s.msg = NULL; |
890 | s.ConfigNum = 0; | 895 | s.ConfigNum = 0; |
891 | QLabel status ( i18n(" Opening device ..."), 0 ); | 896 | QLabel status ( i18n(" Opening device ..."), 0 ); |
892 | int w = status.sizeHint().width()+20 ; | 897 | int w = status.sizeHint().width()+20 ; |
893 | if ( w < 200 ) w = 230; | 898 | if ( w < 200 ) w = 230; |
894 | int h = status.sizeHint().height()+20 ; | 899 | int h = status.sizeHint().height()+20 ; |
895 | int dw = QApplication::desktop()->width(); | 900 | int dw = QApplication::desktop()->width(); |
896 | int dh = QApplication::desktop()->height(); | 901 | int dh = QApplication::desktop()->height(); |
897 | status.setCaption(i18n("Writing to phone...") ); | 902 | status.setCaption(i18n("Writing to phone...") ); |
898 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 903 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
899 | status.show(); | 904 | status.show(); |
900 | status.raise(); | 905 | status.raise(); |
901 | qApp->processEvents(); | 906 | qApp->processEvents(); |
902 | 907 | ||
903 | int error=initDevice(&s); | 908 | int error=initDevice(&s); |
904 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); | 909 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); |
905 | if ( error != ERR_NONE ) | 910 | if ( error != ERR_NONE ) |
906 | return false; | 911 | return false; |
907 | GSM_Phone_Functions*Phone; | 912 | GSM_Phone_Functions*Phone; |
908 | GSM_CalendarEntryNote; | 913 | GSM_CalendarEntryNote; |
909 | bool start = true; | 914 | bool start = true; |
910 | Phone=s.Phone.Functions; | 915 | Phone=s.Phone.Functions; |
911 | bool gshutdown = false; | 916 | bool gshutdown = false; |
912 | QPtrList<Event> er = calendar->rawEvents(); | 917 | QPtrList<Event> er = calendar->rawEvents(); |
913 | Event* ev = er.first(); | 918 | Event* ev = er.first(); |
914 | QString message = i18n(" Deleting event # "); | 919 | QString message = i18n(" Deleting event # "); |
915 | int procCount = 0; | 920 | int procCount = 0; |
916 | int diffProc = 0; | 921 | int diffProc = 0; |
917 | bool setPossible = true; | 922 | bool setPossible = true; |
918 | #ifdef _WIN32_ | 923 | #ifdef _WIN32_ |
919 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; | 924 | QString fileName = locateLocal("data", "korganizer") + "\\tempfile.vcs"; |
920 | #else | 925 | #else |
921 | QString fileName = "/tmp/kdepimtemp.vcs"; | 926 | QString fileName = "/tmp/kdepimtemp.vcs"; |
922 | #endif | 927 | #endif |
923 | //algo 1 delete event | 928 | //algo 1 delete event |
924 | while ( ev ) { | 929 | while ( ev ) { |
925 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one | 930 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one |
926 | 931 | ||
927 | status.setText ( message + QString::number ( ++procCount ) ); | 932 | status.setText ( message + QString::number ( ++procCount ) ); |
928 | qApp->processEvents(); | 933 | qApp->processEvents(); |
929 | qDebug("del event1 %d ", procCount); | 934 | qDebug("del event1 %d ", procCount); |
930 | //event2GSM( calendar, ev, &Note ); | 935 | //event2GSM( calendar, ev, &Note ); |
931 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 936 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
932 | 937 | ||
933 | QString loc = ev->getID(mProfileName); | 938 | QString loc = ev->getID(mProfileName); |
934 | if ( !loc.isEmpty() ){ | 939 | if ( !loc.isEmpty() ){ |
935 | Note.Location = loc.toInt(); | 940 | Note.Location = loc.toInt(); |
936 | } else { | 941 | } else { |
937 | qDebug("error: loc is empty "); | 942 | qDebug("error: loc is empty "); |
938 | } | 943 | } |
939 | error = Phone->DeleteCalendar(&s, &Note); | 944 | error = Phone->DeleteCalendar(&s, &Note); |
940 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 945 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
941 | qDebug(" e error delete1 planB %d ", error); | 946 | qDebug(" e error delete1 planB %d ", error); |
942 | break; | 947 | break; |
943 | } | 948 | } |
944 | } | 949 | } |
945 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new | 950 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new |
946 | // we have to do this later after deleting | 951 | // we have to do this later after deleting |
947 | 952 | ||
948 | } | 953 | } |
949 | else { // change existing | 954 | else { // change existing |
950 | 955 | ||
951 | QString loc = ev->getID(mProfileName); | 956 | QString loc = ev->getID(mProfileName); |
952 | if ( !loc.isEmpty() ){ | 957 | if ( !loc.isEmpty() ){ |
953 | Note.Location = loc.toInt(); | 958 | Note.Location = loc.toInt(); |
954 | } else { | 959 | } else { |
955 | qDebug("error3: loc is empty "); | 960 | qDebug("error3: loc is empty "); |
956 | } | 961 | } |
957 | error = Phone->DeleteCalendar(&s, &Note); | 962 | error = Phone->DeleteCalendar(&s, &Note); |
958 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 963 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
959 | qDebug(" e error delete2 planB %d ", error); | 964 | qDebug(" e error delete2 planB %d ", error); |
960 | break; | 965 | break; |
961 | } | 966 | } |
962 | ev->removeID( mProfileName ); | 967 | ev->removeID( mProfileName ); |
963 | } | 968 | } |
964 | } | 969 | } |
965 | ev = er.next(); | 970 | ev = er.next(); |
966 | } | 971 | } |
967 | //algo 1 delete todo | 972 | //algo 1 delete todo |
968 | GSM_ToDoEntry ToDoEntry; | 973 | GSM_ToDoEntry ToDoEntry; |
969 | QPtrList<Todo> tl = calendar->rawTodos(); | 974 | QPtrList<Todo> tl = calendar->rawTodos(); |
970 | Todo* to = tl.first(); | 975 | Todo* to = tl.first(); |
971 | message = i18n(" Deleting todo # "); | 976 | message = i18n(" Deleting todo # "); |
972 | procCount = 0; | 977 | procCount = 0; |
973 | while ( to ) { | 978 | while ( to ) { |
974 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 979 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
975 | qDebug("todo3 %d ", procCount); | 980 | qDebug("todo3 %d ", procCount); |
976 | status.setText ( message + QString::number ( ++procCount ) ); | 981 | status.setText ( message + QString::number ( ++procCount ) ); |
977 | qApp->processEvents(); | 982 | qApp->processEvents(); |
978 | qDebug("todo5 %d ", procCount); | 983 | qDebug("todo5 %d ", procCount); |
979 | // todo2GSM( calendar, to, &ToDoEntry ); | 984 | // todo2GSM( calendar, to, &ToDoEntry ); |
980 | QString loc = to->getID(mProfileName); | 985 | QString loc = to->getID(mProfileName); |
981 | if ( !loc.isEmpty() ){ | 986 | if ( !loc.isEmpty() ){ |
982 | ToDoEntry.Location = loc.toInt(); | 987 | ToDoEntry.Location = loc.toInt(); |
983 | } else { | 988 | } else { |
984 | qDebug("error2: loc is empty "); | 989 | qDebug("error2: loc is empty "); |
985 | } | 990 | } |
986 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 991 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
987 | error=Phone->DeleteToDo(&s,&ToDoEntry); | 992 | error=Phone->DeleteToDo(&s,&ToDoEntry); |
988 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 993 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
989 | qDebug("delete planB %d ", error); | 994 | qDebug("delete planB %d ", error); |
990 | } | 995 | } |
991 | } | 996 | } |
992 | else if ( to->getID(mProfileName).isEmpty() ) { // add new | 997 | else if ( to->getID(mProfileName).isEmpty() ) { // add new |
993 | ; | 998 | ; |
994 | } | 999 | } |
995 | else { // change existing | 1000 | else { // change existing |
996 | error=Phone->DeleteToDo(&s,&ToDoEntry); | 1001 | error=Phone->DeleteToDo(&s,&ToDoEntry); |
997 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1002 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
998 | qDebug("set planB %d ", error); | 1003 | qDebug("set planB %d ", error); |
999 | } | 1004 | } |
1000 | to->removeID( mProfileName ); | 1005 | to->removeID( mProfileName ); |
1001 | } | 1006 | } |
1002 | } | 1007 | } |
1003 | to = tl.next(); | 1008 | to = tl.next(); |
1004 | } | 1009 | } |
1005 | //algo 2 add event | 1010 | //algo 2 add event |
1006 | ev = er.first(); | 1011 | ev = er.first(); |
1007 | QString filec; | 1012 | QString filec; |
1008 | message = i18n(" Preparing event # "); | 1013 | message = i18n(" Preparing event # "); |
1009 | procCount = 0; | 1014 | procCount = 0; |
1010 | while ( ev ) { | 1015 | while ( ev ) { |
1011 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 1016 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
1012 | if ( ev->getID(mProfileName).isEmpty() ) { | 1017 | if ( ev->getID(mProfileName).isEmpty() ) { |
1013 | status.setText ( message + QString::number ( ++procCount ) ); | 1018 | status.setText ( message + QString::number ( ++procCount ) ); |
1014 | qApp->processEvents(); | 1019 | qApp->processEvents(); |
1015 | filec += vfconverter.eventToString( ev, calendar )+ "\n"; | 1020 | filec += vfconverter.eventToString( ev, calendar )+ "\n"; |
1016 | afterSave ( ev ); | 1021 | afterSave ( ev ); |
1017 | 1022 | ||
1018 | } | 1023 | } |
1019 | } | 1024 | } |
1020 | ev = er.next(); | 1025 | ev = er.next(); |
1021 | } | 1026 | } |
1022 | //algo 2 add todo | 1027 | //algo 2 add todo |
1023 | to = tl.first(); | 1028 | to = tl.first(); |
1024 | procCount = 0; | 1029 | procCount = 0; |
1025 | message = i18n(" Preparing todo # "); | 1030 | message = i18n(" Preparing todo # "); |
1026 | while ( to ) { | 1031 | while ( to ) { |
1027 | qDebug("todo2 %d ", procCount); | 1032 | qDebug("todo2 %d ", procCount); |
1028 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 1033 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
1029 | qDebug("todo4 %d ", procCount); | 1034 | qDebug("todo4 %d ", procCount); |
1030 | if ( to->getID(mProfileName).isEmpty() ) { | 1035 | if ( to->getID(mProfileName).isEmpty() ) { |
1031 | status.setText ( message + QString::number ( ++procCount ) ); | 1036 | status.setText ( message + QString::number ( ++procCount ) ); |
1032 | qApp->processEvents(); | 1037 | qApp->processEvents(); |
1033 | filec += vfconverter.todoToString( to, calendar )+ "\n"; | 1038 | filec += vfconverter.todoToString( to, calendar )+ "\n"; |
1034 | afterSave ( to ); | 1039 | afterSave ( to ); |
1035 | } | 1040 | } |
1036 | } | 1041 | } |
1037 | to = tl.next(); | 1042 | to = tl.next(); |
1038 | } | 1043 | } |
1039 | if ( filec.isEmpty() ) { | 1044 | if ( filec.isEmpty() ) { |
1040 | qDebug("Nothing to write back.Finished. "); | 1045 | qDebug("Nothing to write back.Finished. "); |
1041 | error=GSM_TerminateConnection(&s); | 1046 | error=GSM_TerminateConnection(&s); |
1042 | return true; | 1047 | return true; |
1043 | } | 1048 | } |
1044 | //algo 3 saving file | 1049 | //algo 3 saving file |
1045 | message = i18n(" Saving temp file ... "); | 1050 | message = i18n(" Saving temp file ... "); |
1046 | status.setText ( message ); | 1051 | status.setText ( message ); |
1047 | qApp->processEvents(); | 1052 | qApp->processEvents(); |
1048 | QFile file( fileName ); | 1053 | QFile file( fileName ); |
1049 | if (!file.open( IO_WriteOnly ) ) { | 1054 | if (!file.open( IO_WriteOnly ) ) { |
1050 | qDebug("error open file "); | 1055 | qDebug("error open file "); |
1051 | error=GSM_TerminateConnection(&s); | 1056 | error=GSM_TerminateConnection(&s); |
1052 | return false; | 1057 | return false; |
1053 | } | 1058 | } |
1054 | QTextStream ts( &file ); | 1059 | QTextStream ts( &file ); |
1055 | ts.setCodec( QTextCodec::codecForName("utf8") ); | 1060 | ts.setCodec( QTextCodec::codecForName("utf8") ); |
1056 | ts << filec ; | 1061 | ts << filec ; |
1057 | file.close(); | 1062 | file.close(); |
1058 | 1063 | ||
1059 | 1064 | ||
1060 | message = i18n(" Parsing temp file ... "); | 1065 | message = i18n(" Parsing temp file ... "); |
1061 | status.setText ( message ); | 1066 | status.setText ( message ); |
1062 | qApp->processEvents(); | 1067 | qApp->processEvents(); |
1063 | GSM_Backup Backup; | 1068 | GSM_Backup Backup; |
1064 | error=GSM_ReadBackupFile( (char*) fileName.latin1() ,&Backup); | 1069 | error=GSM_ReadBackupFile( (char*) fileName.latin1() ,&Backup); |
1065 | qDebug("Read file result %d ",error ); | 1070 | qDebug("Read file result %d ",error ); |
1066 | //algo 4 writing event | 1071 | //algo 4 writing event |
1067 | int max, i; | 1072 | int max, i; |
1068 | procCount = 0; | 1073 | procCount = 0; |
1069 | message = i18n(" Writing event # "); | 1074 | message = i18n(" Writing event # "); |
1070 | if (Backup.Calendar[0] != NULL) { | 1075 | if (Backup.Calendar[0] != NULL) { |
1071 | max = 0; | 1076 | max = 0; |
1072 | while (Backup.Calendar[max]!=NULL) max++; | 1077 | while (Backup.Calendar[max]!=NULL) max++; |
1078 | |||
1079 | GSM_DateTime*dtp; | ||
1080 | |||
1073 | for (i=0;i<max;i++) { | 1081 | for (i=0;i<max;i++) { |
1074 | status.setText ( message + QString::number ( ++procCount ) ); | 1082 | status.setText ( message + QString::number ( ++procCount ) ); |
1075 | qApp->processEvents(); | 1083 | qApp->processEvents(); |
1076 | Note = *Backup.Calendar[i]; | 1084 | Note = *Backup.Calendar[i]; |
1085 | |||
1086 | #if 0 | ||
1087 | int j; | ||
1088 | for (j=0;j<Note.EntriesNum;j++) { | ||
1089 | //qDebug(" for ev"); | ||
1090 | switch (Note.Entries[j].EntryType) { | ||
1091 | case CAL_START_DATETIME: | ||
1092 | //Note->Entries[i].Date.Hour = 5; | ||
1093 | dtp = &Note.Entries[j].Date; | ||
1094 | qDebug("start event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second ); | ||
1095 | break; | ||
1096 | case CAL_END_DATETIME: | ||
1097 | dtp = &Note.Entries[j].Date; | ||
1098 | qDebug("end event %d %d %d - %d %d %d", dtp->Year, dtp->Month, dtp->Day, dtp->Hour, dtp->Minute, dtp->Second ); | ||
1099 | break; | ||
1100 | } | ||
1101 | } | ||
1102 | int type = Note.Type; | ||
1103 | qDebug(" event type %d - %d %d - %d %d %d",type, GSM_CAL_CALL , GSM_CAL_MEETING ,GSM_CAL_BIRTHDAY, GSM_CAL_MEMO ,GSM_CAL_ALARM ); | ||
1104 | #endif | ||
1105 | |||
1106 | Note.Type = GSM_CAL_MEETING; | ||
1107 | // pending: fix in gammu GSM_ReadBackupFile the type settings | ||
1108 | int loc = Note.Location; | ||
1077 | Note.Location = 0; | 1109 | Note.Location = 0; |
1078 | error=Phone->AddCalendar(&s,&Note); | 1110 | error=Phone->AddCalendar(&s,&Note); |
1079 | qDebug("add event %d %d", error, Note.Location ); | 1111 | qDebug("add event %d %d %d", error, Note.Location, loc ); |
1080 | } | 1112 | } |
1081 | } | 1113 | } |
1082 | //algo 4 writing todo | 1114 | //algo 4 writing todo |
1083 | procCount = 0; | 1115 | procCount = 0; |
1084 | message = i18n(" Writing todo # "); | 1116 | message = i18n(" Writing todo # "); |
1085 | if (Backup.ToDo[0] != NULL) { | 1117 | if (Backup.ToDo[0] != NULL) { |
1086 | max = 0; | 1118 | max = 0; |
1087 | while (Backup.ToDo[max]!=NULL) max++; | 1119 | while (Backup.ToDo[max]!=NULL) max++; |
1088 | for (i=0;i<max;i++) { | 1120 | for (i=0;i<max;i++) { |
1089 | status.setText ( message + QString::number ( ++procCount ) ); | 1121 | status.setText ( message + QString::number ( ++procCount ) ); |
1090 | qApp->processEvents(); | 1122 | qApp->processEvents(); |
1091 | ToDoEntry = *Backup.ToDo[i]; | 1123 | ToDoEntry = *Backup.ToDo[i]; |
1092 | error = Phone->AddToDo(&s,&ToDoEntry); | 1124 | error = Phone->AddToDo(&s,&ToDoEntry); |
1093 | qDebug("add todo %d ", error); | 1125 | qDebug("add todo %d ", error); |
1094 | } | 1126 | } |
1095 | } | 1127 | } |
1096 | //algo 5 reread | 1128 | //algo 5 reread |
1097 | message = i18n(" Rereading all data ... "); | 1129 | message = i18n(" Rereading all data ... "); |
1098 | status.setText ( message ); | 1130 | status.setText ( message ); |
1099 | qApp->processEvents(); | 1131 | qApp->processEvents(); |
1100 | error=GSM_TerminateConnection(&s); | 1132 | error=GSM_TerminateConnection(&s); |
1101 | CalendarLocal* calendarTemp = new CalendarLocal(); | 1133 | CalendarLocal* calendarTemp = new CalendarLocal(); |
1102 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); | 1134 | calendarTemp->setTimeZoneId( calendar->timeZoneId()); |
1103 | if ( ! load( calendarTemp,calendar) ){ | 1135 | if ( ! load( calendarTemp,calendar) ){ |
1104 | qDebug("error reloading calendar "); | 1136 | qDebug("error reloading calendar "); |
1105 | delete calendarTemp; | 1137 | delete calendarTemp; |
1106 | return false; | 1138 | return false; |
1107 | } | 1139 | } |
1108 | 1140 | ||
1109 | 1141 | ||
1110 | //algo 6 compare event | 1142 | //algo 6 compare event |
1111 | ev = er.first(); | 1143 | ev = er.first(); |
1112 | message = i18n(" Comparing event # "); | 1144 | message = i18n(" Comparing event # "); |
1113 | QPtrList<Event> er1 = calendarTemp->rawEvents(); | 1145 | QPtrList<Event> er1 = calendarTemp->rawEvents(); |
1114 | Event* ev1; | 1146 | Event* ev1; |
1115 | procCount = 0; | 1147 | procCount = 0; |
1116 | while ( ev ) { | 1148 | while ( ev ) { |
1117 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) { | 1149 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) { |
1118 | qDebug("event new ID "); | 1150 | qDebug("event new ID "); |
1119 | status.setText ( message + QString::number ( ++procCount ) ); | 1151 | status.setText ( message + QString::number ( ++procCount ) ); |
1120 | qApp->processEvents(); | 1152 | qApp->processEvents(); |
1121 | QString cSum = ev->getCsum(mProfileName); | 1153 | QString cSum = ev->getCsum(mProfileName); |
1122 | ev1 = er1.first(); | 1154 | ev1 = er1.first(); |
1123 | while ( ev1 ) { | 1155 | while ( ev1 ) { |
1124 | if ( ev1->getCsum( mProfileName ) == cSum ) { | 1156 | if ( ev1->getCsum( mProfileName ) == cSum ) { |
1125 | er1.remove( ev1 ); | 1157 | er1.remove( ev1 ); |
1126 | ev->setID(mProfileName, ev1->getID(mProfileName) ); | 1158 | ev->setID(mProfileName, ev1->getID(mProfileName) ); |
1127 | break; | 1159 | break; |
1128 | } | 1160 | } |
1129 | ev1 = er1.next(); | 1161 | ev1 = er1.next(); |
1130 | } | 1162 | } |
1131 | if ( ! ev1 ) { | 1163 | if ( ! ev1 ) { |
1132 | ev->removeID(mProfileName); | 1164 | ev->removeID(mProfileName); |
1133 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); | 1165 | qDebug("ERROR: No event found on phone for %s ", ev->summary().latin1()); |
1134 | qDebug("Probably writing back of events not supported "); | 1166 | qDebug("Probably writing back of events not supported "); |
1135 | } | 1167 | } |
1136 | 1168 | ||
1137 | } | 1169 | } |
1138 | ev = er.next(); | 1170 | ev = er.next(); |
1139 | } | 1171 | } |
1140 | //algo 6 compare todo | 1172 | //algo 6 compare todo |
1141 | to = tl.first(); | 1173 | to = tl.first(); |
1142 | procCount = 0; | 1174 | procCount = 0; |
1143 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); | 1175 | QPtrList<Todo> tl1 = calendarTemp->rawTodos(); |
1144 | Todo* to1 ; | 1176 | Todo* to1 ; |
1145 | message = i18n(" Comparing todo # "); | 1177 | message = i18n(" Comparing todo # "); |
1146 | while ( to ) { | 1178 | while ( to ) { |
1147 | qDebug("todo2 %d ", procCount); | 1179 | qDebug("todo2 %d ", procCount); |
1148 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) { | 1180 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_NEW_ID) { |
1149 | status.setText ( message + QString::number ( ++procCount ) ); | 1181 | status.setText ( message + QString::number ( ++procCount ) ); |
1150 | qApp->processEvents(); | 1182 | qApp->processEvents(); |
1151 | QString cSum = to->getCsum(mProfileName); | 1183 | QString cSum = to->getCsum(mProfileName); |
1152 | Todo* to1 = tl1.first(); | 1184 | Todo* to1 = tl1.first(); |
1153 | while ( to1 ) { | 1185 | while ( to1 ) { |
1154 | if ( to1->getCsum( mProfileName ) == cSum ) { | 1186 | if ( to1->getCsum( mProfileName ) == cSum ) { |
1155 | tl1.remove( to1 ); | 1187 | tl1.remove( to1 ); |
1156 | to->setID(mProfileName, to1->getID(mProfileName) ); | 1188 | to->setID(mProfileName, to1->getID(mProfileName) ); |
1157 | break; | 1189 | break; |
1158 | } | 1190 | } |
1159 | to1 = tl1.next(); | 1191 | to1 = tl1.next(); |
1160 | } | 1192 | } |
1161 | if ( ! to1 ) { | 1193 | if ( ! to1 ) { |
1162 | to->removeID(mProfileName); | 1194 | to->removeID(mProfileName); |
1163 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); | 1195 | qDebug("ERROR: No todo found on phone for %s ", to->summary().latin1()); |
1164 | qDebug("Probably writing back of todos not supported "); | 1196 | qDebug("Probably writing back of todos not supported "); |
1165 | } | 1197 | } |
1166 | } | 1198 | } |
1167 | to = tl.next(); | 1199 | to = tl.next(); |
1168 | } | 1200 | } |
1169 | delete calendarTemp; | 1201 | delete calendarTemp; |
1170 | return true; | 1202 | return true; |
1171 | // ******************************************************************* | 1203 | // ******************************************************************* |
1172 | // ******************************************************************* | 1204 | // ******************************************************************* |
1173 | // ******************************************************************* | 1205 | // ******************************************************************* |
1174 | #if 0 | 1206 | #if 0 |
1175 | while ( ev && ! planB) { | 1207 | while ( ev && ! planB) { |
1176 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one | 1208 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one |
1177 | 1209 | ||
1178 | status.setText ( message + QString::number ( ++procCount ) ); | 1210 | status.setText ( message + QString::number ( ++procCount ) ); |
1179 | qApp->processEvents(); | 1211 | qApp->processEvents(); |
1180 | qDebug("event1 %d ", procCount); | 1212 | qDebug("event1 %d ", procCount); |
1181 | event2GSM( calendar, ev, &Note ); | 1213 | event2GSM( calendar, ev, &Note ); |
1182 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 1214 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
1183 | error = Phone->DeleteCalendar(&s, &Note); | 1215 | error = Phone->DeleteCalendar(&s, &Note); |
1184 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1216 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1185 | planB = true; | 1217 | planB = true; |
1186 | qDebug(" e delete1 planB %d ", error); | 1218 | qDebug(" e delete1 planB %d ", error); |
1187 | break; | 1219 | break; |
1188 | } | 1220 | } |
1189 | } | 1221 | } |
1190 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new | 1222 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new |
1191 | // we have to do this later after deleting | 1223 | // we have to do this later after deleting |
1192 | 1224 | ||
1193 | } | 1225 | } |
1194 | else { // change existing | 1226 | else { // change existing |
1195 | if ( setPossible ) { | 1227 | if ( setPossible ) { |
1196 | error = Phone->SetCalendar(&s, &Note); | 1228 | error = Phone->SetCalendar(&s, &Note); |
1197 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1229 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1198 | setPossible = false; | 1230 | setPossible = false; |
1199 | ++diffProc; | 1231 | ++diffProc; |
1200 | qDebug("Set cal not supported %d ", error); | 1232 | qDebug("Set cal not supported %d ", error); |
1201 | break; | 1233 | break; |
1202 | } | 1234 | } |
1203 | } | 1235 | } |
1204 | if ( ! setPossible) { | 1236 | if ( ! setPossible) { |
1205 | ++diffProc; | 1237 | ++diffProc; |
1206 | error = Phone->DeleteCalendar(&s, &Note); | 1238 | error = Phone->DeleteCalendar(&s, &Note); |
1207 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1239 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1208 | planB = true; | 1240 | planB = true; |
1209 | qDebug(" e delete2 planB %d ", error); | 1241 | qDebug(" e delete2 planB %d ", error); |
1210 | break; | 1242 | break; |
1211 | } | 1243 | } |
1212 | ev->removeID( mProfileName ); | 1244 | ev->removeID( mProfileName ); |
1213 | } | 1245 | } |
1214 | qDebug("Change Calendar. Location %d status: %d",Note.Location, error ); | 1246 | qDebug("Change Calendar. Location %d status: %d",Note.Location, error ); |
1215 | } | 1247 | } |
1216 | } | 1248 | } |
1217 | ev = er.next(); | 1249 | ev = er.next(); |
1218 | } | 1250 | } |
1219 | ev = er.first(); | 1251 | ev = er.first(); |
1220 | // pending get empty slots | 1252 | // pending get empty slots |
1221 | int loc = 0; | 1253 | int loc = 0; |
1222 | procCount -= diffProc; | 1254 | procCount -= diffProc; |
1223 | while ( ev && ! planB) { | 1255 | while ( ev && ! planB) { |
1224 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 1256 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
1225 | qDebug("event2 %d ", procCount); | 1257 | qDebug("event2 %d ", procCount); |
1226 | if ( ev->getID(mProfileName).isEmpty() ) { | 1258 | if ( ev->getID(mProfileName).isEmpty() ) { |
1227 | status.setText ( message + QString::number ( ++procCount ) ); | 1259 | status.setText ( message + QString::number ( ++procCount ) ); |
1228 | qApp->processEvents(); | 1260 | qApp->processEvents(); |
1229 | //int newID ;//= pending | 1261 | //int newID ;//= pending |
1230 | //ev->setID(mProfileName, QString::number( newID )); | 1262 | //ev->setID(mProfileName, QString::number( newID )); |
1231 | event2GSM( calendar, ev, &Note ); | 1263 | event2GSM( calendar, ev, &Note ); |
1232 | ++loc; | 1264 | ++loc; |
1233 | Note.Location = loc; | 1265 | Note.Location = loc; |
1234 | error = Phone->AddCalendar(&s, &Note); | 1266 | error = Phone->AddCalendar(&s, &Note); |
1235 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1267 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1236 | planB = true; | 1268 | planB = true; |
1237 | qDebug(" e add planB %d ", error); | 1269 | qDebug(" e add planB %d ", error); |
1238 | break; | 1270 | break; |
1239 | } | 1271 | } |
1240 | ev->setID( mProfileName, QString::number( Note.Location ) ); | 1272 | ev->setID( mProfileName, QString::number( Note.Location ) ); |
1241 | qDebug("New Calendar. Location %d stat %d %d",Note.Location ,error, ERR_UNKNOWN); | 1273 | qDebug("New Calendar. Location %d stat %d %d",Note.Location ,error, ERR_UNKNOWN); |
1242 | afterSave( ev ); | 1274 | afterSave( ev ); |
1243 | } else { | 1275 | } else { |
1244 | afterSave( ev ); // setting temp sync stat for changed items | 1276 | afterSave( ev ); // setting temp sync stat for changed items |
1245 | } | 1277 | } |
1246 | } | 1278 | } |
1247 | ev = er.next(); | 1279 | ev = er.next(); |
1248 | } | 1280 | } |
1249 | 1281 | ||
1250 | 1282 | ||
1251 | if ( planB ) { | 1283 | if ( planB ) { |
1252 | qDebug("delete all calendar..."); | 1284 | qDebug("delete all calendar..."); |
1253 | status.setText ( i18n("Deleting all calendar...")); | 1285 | status.setText ( i18n("Deleting all calendar...")); |
1254 | qApp->processEvents(); | 1286 | qApp->processEvents(); |
1255 | error=Phone->DeleteAllCalendar(&s); | 1287 | error=Phone->DeleteAllCalendar(&s); |
1256 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1288 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1257 | message = i18n(" Deleting event # "); | 1289 | message = i18n(" Deleting event # "); |
1258 | procCount = 0; | 1290 | procCount = 0; |
1259 | while (1) { | 1291 | while (1) { |
1260 | status.setText ( message + QString::number ( ++procCount ) ); | 1292 | status.setText ( message + QString::number ( ++procCount ) ); |
1261 | qApp->processEvents(); | 1293 | qApp->processEvents(); |
1262 | qDebug("deleting event ... %d", procCount); | 1294 | qDebug("deleting event ... %d", procCount); |
1263 | error = Phone->GetNextCalendar(&s,&Note,true); | 1295 | error = Phone->GetNextCalendar(&s,&Note,true); |
1264 | if (error != ERR_NONE) break; | 1296 | if (error != ERR_NONE) break; |
1265 | error = Phone->DeleteCalendar(&s,&Note); | 1297 | error = Phone->DeleteCalendar(&s,&Note); |
1266 | } | 1298 | } |
1267 | qDebug("deleting calendar ... finished"); | 1299 | qDebug("deleting calendar ... finished"); |
1268 | } else { | 1300 | } else { |
1269 | status.setText ( i18n("All calendar deleted!")); | 1301 | status.setText ( i18n("All calendar deleted!")); |
1270 | qDebug("all cal deleted"); | 1302 | qDebug("all cal deleted"); |
1271 | } | 1303 | } |
1272 | bool planC = false; | 1304 | bool planC = false; |
1273 | ev = er.first(); | 1305 | ev = er.first(); |
1274 | procCount = 0; | 1306 | procCount = 0; |
1275 | message = i18n(" Writing event # "); | 1307 | message = i18n(" Writing event # "); |
1276 | while ( ev && ! planC) { | 1308 | while ( ev && ! planC) { |
1277 | status.setText ( message + QString::number ( ++procCount ) ); | 1309 | status.setText ( message + QString::number ( ++procCount ) ); |
1278 | qApp->processEvents(); | 1310 | qApp->processEvents(); |
1279 | event2GSM( calendar, ev, &Note ); | 1311 | event2GSM( calendar, ev, &Note ); |
1280 | Note.Location = procCount; | 1312 | Note.Location = procCount; |
1281 | error=Phone->AddCalendar(&s,&Note); | 1313 | error=Phone->AddCalendar(&s,&Note); |
1282 | if (error != ERR_NONE ) { | 1314 | if (error != ERR_NONE ) { |
1283 | // we have currently no planC :-( | 1315 | // we have currently no planC :-( |
1284 | // planC = true; | 1316 | // planC = true; |
1285 | //qDebug("add planC %d ", error); | 1317 | //qDebug("add planC %d ", error); |
1286 | //break; | 1318 | //break; |
1287 | // we remove the ID such that this todo is not deleted after next sync | 1319 | // we remove the ID such that this todo is not deleted after next sync |
1288 | ev->removeID(mProfileName); | 1320 | ev->removeID(mProfileName); |
1289 | ev->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 1321 | ev->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
1290 | qDebug("error :cal adding loc %d planB stat %d ", Note.Location ,error); | 1322 | qDebug("error :cal adding loc %d planB stat %d ", Note.Location ,error); |
1291 | } else { | 1323 | } else { |
1292 | qDebug("cal adding loc %d planB stat %d ", Note.Location ,error); | 1324 | qDebug("cal adding loc %d planB stat %d ", Note.Location ,error); |
1293 | ev->setID(mProfileName, QString::number( Note.Location )); | 1325 | ev->setID(mProfileName, QString::number( Note.Location )); |
1294 | afterSave( ev ); | 1326 | afterSave( ev ); |
1295 | } | 1327 | } |
1296 | ev = er.next(); | 1328 | ev = er.next(); |
1297 | } | 1329 | } |
1298 | if ( planC ) { | 1330 | if ( planC ) { |
1299 | qDebug("writing cal went wrong..."); | 1331 | qDebug("writing cal went wrong..."); |
1300 | 1332 | ||
1301 | // we have currently no planC :-( | 1333 | // we have currently no planC :-( |
1302 | } | 1334 | } |
1303 | } | 1335 | } |
1304 | GSM_ToDoEntry ToDoEntry; | 1336 | GSM_ToDoEntry ToDoEntry; |
1305 | QPtrList<Todo> tl = calendar->rawTodos(); | 1337 | QPtrList<Todo> tl = calendar->rawTodos(); |
1306 | Todo* to = tl.first(); | 1338 | Todo* to = tl.first(); |
1307 | 1339 | ||
1308 | message = i18n(" Processing todo # "); | 1340 | message = i18n(" Processing todo # "); |
1309 | procCount = 0; | 1341 | procCount = 0; |
1310 | planB = false; | 1342 | planB = false; |
1311 | while ( to && ! planB ) { | 1343 | while ( to && ! planB ) { |
1312 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 1344 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
1313 | qDebug("todo3 %d ", procCount); | 1345 | qDebug("todo3 %d ", procCount); |
1314 | status.setText ( message + QString::number ( ++procCount ) ); | 1346 | status.setText ( message + QString::number ( ++procCount ) ); |
1315 | qApp->processEvents(); | 1347 | qApp->processEvents(); |
1316 | qDebug("todo5 %d ", procCount); | 1348 | qDebug("todo5 %d ", procCount); |
1317 | todo2GSM( calendar, to, &ToDoEntry ); | 1349 | todo2GSM( calendar, to, &ToDoEntry ); |
1318 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 1350 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
1319 | error=Phone->DeleteToDo(&s,&ToDoEntry); | 1351 | error=Phone->DeleteToDo(&s,&ToDoEntry); |
1320 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1352 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1321 | planB = true; | 1353 | planB = true; |
1322 | qDebug("delete planB %d ", error); | 1354 | qDebug("delete planB %d ", error); |
1323 | } | 1355 | } |
1324 | } | 1356 | } |
1325 | else if ( to->getID(mProfileName).isEmpty() ) { // add new | 1357 | else if ( to->getID(mProfileName).isEmpty() ) { // add new |
1326 | ; | 1358 | ; |
1327 | } | 1359 | } |
1328 | else { // change existing | 1360 | else { // change existing |
1329 | error=Phone->SetToDo(&s,&ToDoEntry); | 1361 | error=Phone->SetToDo(&s,&ToDoEntry); |
1330 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1362 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1331 | planB = true; | 1363 | planB = true; |
1332 | qDebug("set planB %d ", error); | 1364 | qDebug("set planB %d ", error); |
1333 | } | 1365 | } |
1334 | qDebug("Old Todo. Location %d %d",ToDoEntry.Location , error ); | 1366 | qDebug("Old Todo. Location %d %d",ToDoEntry.Location , error ); |
1335 | } | 1367 | } |
1336 | } | 1368 | } |
1337 | to = tl.next(); | 1369 | to = tl.next(); |
1338 | } | 1370 | } |
1339 | 1371 | ||
1340 | // pending get empty slots | 1372 | // pending get empty slots |
1341 | to = tl.first(); | 1373 | to = tl.first(); |
1342 | while ( to && ! planB ) { | 1374 | while ( to && ! planB ) { |
1343 | qDebug("todo2 %d ", procCount); | 1375 | qDebug("todo2 %d ", procCount); |
1344 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 1376 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
1345 | qDebug("todo4 %d ", procCount); | 1377 | qDebug("todo4 %d ", procCount); |
1346 | if ( to->getID(mProfileName).isEmpty() ) { | 1378 | if ( to->getID(mProfileName).isEmpty() ) { |
1347 | status.setText ( message + QString::number ( ++procCount ) ); | 1379 | status.setText ( message + QString::number ( ++procCount ) ); |
1348 | qApp->processEvents(); | 1380 | qApp->processEvents(); |
1349 | //int newID ;//= pending | 1381 | //int newID ;//= pending |
1350 | //to->setID(mProfileName, QString::number( newID )); | 1382 | //to->setID(mProfileName, QString::number( newID )); |
1351 | todo2GSM( calendar,to, &ToDoEntry ); | 1383 | todo2GSM( calendar,to, &ToDoEntry ); |
1352 | ToDoEntry.Location = 0; | 1384 | ToDoEntry.Location = 0; |
1353 | error=Phone->AddToDo(&s,&ToDoEntry); | 1385 | error=Phone->AddToDo(&s,&ToDoEntry); |
1354 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1386 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1355 | planB = true; | 1387 | planB = true; |
1356 | qDebug("new planB %d ", error); | 1388 | qDebug("new planB %d ", error); |
1357 | } | 1389 | } |
1358 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); | 1390 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); |
1359 | afterSave( to ); | 1391 | afterSave( to ); |
1360 | qDebug("New Todo. Location %d %d",ToDoEntry.Location, error ); | 1392 | qDebug("New Todo. Location %d %d",ToDoEntry.Location, error ); |
1361 | } else { | 1393 | } else { |
1362 | afterSave( to ); | 1394 | afterSave( to ); |
1363 | } | 1395 | } |
1364 | } | 1396 | } |
1365 | to = tl.next(); | 1397 | to = tl.next(); |
1366 | } | 1398 | } |
1367 | if ( planB ) { | 1399 | if ( planB ) { |
1368 | qDebug("delete all ..."); | 1400 | qDebug("delete all ..."); |
1369 | error=Phone->DeleteAllToDo(&s); | 1401 | error=Phone->DeleteAllToDo(&s); |
1370 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1402 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1371 | while (1) { | 1403 | while (1) { |
1372 | qDebug("deleting todo ..."); | 1404 | qDebug("deleting todo ..."); |
1373 | error = Phone->GetNextToDo(&s,&ToDoEntry,true); | 1405 | error = Phone->GetNextToDo(&s,&ToDoEntry,true); |
1374 | if (error != ERR_NONE) break; | 1406 | if (error != ERR_NONE) break; |
1375 | error = Phone->DeleteToDo(&s,&ToDoEntry); | 1407 | error = Phone->DeleteToDo(&s,&ToDoEntry); |
1376 | } | 1408 | } |
1377 | qDebug("deleting todo ... finished"); | 1409 | qDebug("deleting todo ... finished"); |
1378 | } else { | 1410 | } else { |
1379 | qDebug("all todo deleted"); | 1411 | qDebug("all todo deleted"); |
1380 | } | 1412 | } |
1381 | bool planC = false; | 1413 | bool planC = false; |
1382 | to = tl.first(); | 1414 | to = tl.first(); |
1383 | while ( to && ! planC ) { | 1415 | while ( to && ! planC ) { |
1384 | todo2GSM( calendar,to, &ToDoEntry ); | 1416 | todo2GSM( calendar,to, &ToDoEntry ); |
1385 | ToDoEntry.Location = 0; | 1417 | ToDoEntry.Location = 0; |
1386 | error=Phone->AddToDo(&s,&ToDoEntry); | 1418 | error=Phone->AddToDo(&s,&ToDoEntry); |
1387 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { | 1419 | if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) { |
1388 | // we have currently no planC :-( | 1420 | // we have currently no planC :-( |
1389 | // planC = true; | 1421 | // planC = true; |
1390 | //qDebug("add planC %d ", error); | 1422 | //qDebug("add planC %d ", error); |
1391 | //break; | 1423 | //break; |
1392 | // we remove the ID such that this todo is not deleted after next sync | 1424 | // we remove the ID such that this todo is not deleted after next sync |
1393 | to->removeID(mProfileName); | 1425 | to->removeID(mProfileName); |
1394 | to->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | 1426 | to->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); |
1395 | } else { | 1427 | } else { |
1396 | qDebug("adding %d planB %d ", ToDoEntry.Location ,error); | 1428 | qDebug("adding %d planB %d ", ToDoEntry.Location ,error); |
1397 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); | 1429 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); |
1398 | afterSave( to ); | 1430 | afterSave( to ); |
1399 | } | 1431 | } |
1400 | to = tl.next(); | 1432 | to = tl.next(); |
1401 | } | 1433 | } |
1402 | if ( planC ) { | 1434 | if ( planC ) { |
1403 | // we have currently no planC :-( | 1435 | // we have currently no planC :-( |
1404 | } | 1436 | } |
1405 | } | 1437 | } |
1406 | return true; | 1438 | return true; |
1407 | #endif | 1439 | #endif |
1408 | } | 1440 | } |
1409 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) | 1441 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) |
1410 | { | 1442 | { |
1411 | QString datestr; | 1443 | QString datestr; |
1412 | QString timestr; | 1444 | QString timestr; |
1413 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 1445 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
1414 | QDateTime dt; | 1446 | QDateTime dt; |
1415 | if (useTZ) | 1447 | if (useTZ) |
1416 | dt = dti.addSecs ( -(offset*60)); | 1448 | dt = dti.addSecs ( -(offset*60)); |
1417 | else | 1449 | else |
1418 | dt = dti; | 1450 | dt = dti; |
1419 | if(dt.date().isValid()){ | 1451 | if(dt.date().isValid()){ |
1420 | const QDate& date = dt.date(); | 1452 | const QDate& date = dt.date(); |
1421 | datestr.sprintf("%04d%02d%02d", | 1453 | datestr.sprintf("%04d%02d%02d", |
1422 | date.year(), date.month(), date.day()); | 1454 | date.year(), date.month(), date.day()); |
1423 | } | 1455 | } |
1424 | if(dt.time().isValid()){ | 1456 | if(dt.time().isValid()){ |
1425 | const QTime& time = dt.time(); | 1457 | const QTime& time = dt.time(); |
1426 | timestr.sprintf("T%02d%02d%02d", | 1458 | timestr.sprintf("T%02d%02d%02d", |
1427 | time.hour(), time.minute(), time.second()); | 1459 | time.hour(), time.minute(), time.second()); |
1428 | } | 1460 | } |
1429 | return datestr + timestr; | 1461 | return datestr + timestr; |
1430 | } | 1462 | } |
1431 | QString PhoneFormat::getEventString( Event* event ) | 1463 | QString PhoneFormat::getEventString( Event* event ) |
1432 | { | 1464 | { |
1433 | #if 0 | 1465 | #if 0 |
1434 | QStringList list; | 1466 | QStringList list; |
1435 | list.append( QString::number(event->zaurusId() ) ); | 1467 | list.append( QString::number(event->zaurusId() ) ); |
1436 | list.append( event->categories().join(",") ); | 1468 | list.append( event->categories().join(",") ); |
1437 | if ( !event->summary().isEmpty() ) | 1469 | if ( !event->summary().isEmpty() ) |
1438 | list.append( event->summary() ); | 1470 | list.append( event->summary() ); |
1439 | else | 1471 | else |
1440 | list.append("" ); | 1472 | list.append("" ); |
1441 | if ( !event->location().isEmpty() ) | 1473 | if ( !event->location().isEmpty() ) |
1442 | list.append( event->location() ); | 1474 | list.append( event->location() ); |
1443 | else | 1475 | else |
1444 | list.append("" ); | 1476 | list.append("" ); |
1445 | if ( !event->description().isEmpty() ) | 1477 | if ( !event->description().isEmpty() ) |
1446 | list.append( event->description() ); | 1478 | list.append( event->description() ); |
1447 | else | 1479 | else |
1448 | list.append( "" ); | 1480 | list.append( "" ); |
1449 | if ( event->doesFloat () ) { | 1481 | if ( event->doesFloat () ) { |
1450 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); | 1482 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); |
1451 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 | 1483 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 |
1452 | list.append( "1" ); | 1484 | list.append( "1" ); |
1453 | 1485 | ||
1454 | } | 1486 | } |
1455 | else { | 1487 | else { |
1456 | list.append( dtToString( event->dtStart()) ); | 1488 | list.append( dtToString( event->dtStart()) ); |
1457 | list.append( dtToString( event->dtEnd()) ); //6 | 1489 | list.append( dtToString( event->dtEnd()) ); //6 |
1458 | list.append( "0" ); | 1490 | list.append( "0" ); |
1459 | } | 1491 | } |
1460 | bool noAlarm = true; | 1492 | bool noAlarm = true; |
1461 | if ( event->alarms().count() > 0 ) { | 1493 | if ( event->alarms().count() > 0 ) { |
1462 | Alarm * al = event->alarms().first(); | 1494 | Alarm * al = event->alarms().first(); |
1463 | if ( al->enabled() ) { | 1495 | if ( al->enabled() ) { |
1464 | noAlarm = false; | 1496 | noAlarm = false; |
1465 | list.append( "0" ); // yes, 0 == alarm | 1497 | list.append( "0" ); // yes, 0 == alarm |
1466 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); | 1498 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); |
1467 | if ( al->type() == Alarm::Audio ) | 1499 | if ( al->type() == Alarm::Audio ) |
1468 | list.append( "1" ); // type audio | 1500 | list.append( "1" ); // type audio |
1469 | else | 1501 | else |
1470 | list.append( "0" ); // type silent | 1502 | list.append( "0" ); // type silent |
1471 | } | 1503 | } |
1472 | } | 1504 | } |
1473 | if ( noAlarm ) { | 1505 | if ( noAlarm ) { |
1474 | list.append( "1" ); // yes, 1 == no alarm | 1506 | list.append( "1" ); // yes, 1 == no alarm |
1475 | list.append( "0" ); // no alarm offset | 1507 | list.append( "0" ); // no alarm offset |
1476 | list.append( "1" ); // type | 1508 | list.append( "1" ); // type |
1477 | } | 1509 | } |
1478 | // next is: 11 | 1510 | // next is: 11 |
1479 | // next is: 11-16 are recurrence | 1511 | // next is: 11-16 are recurrence |
1480 | Recurrence* rec = event->recurrence(); | 1512 | Recurrence* rec = event->recurrence(); |
1481 | 1513 | ||
1482 | bool writeEndDate = false; | 1514 | bool writeEndDate = false; |
1483 | switch ( rec->doesRecur() ) | 1515 | switch ( rec->doesRecur() ) |
1484 | { | 1516 | { |
1485 | case Recurrence::rDaily: // 0 | 1517 | case Recurrence::rDaily: // 0 |
1486 | list.append( "0" ); | 1518 | list.append( "0" ); |
1487 | list.append( QString::number( rec->frequency() ));//12 | 1519 | list.append( QString::number( rec->frequency() ));//12 |
1488 | list.append( "0" ); | 1520 | list.append( "0" ); |
1489 | list.append( "0" ); | 1521 | list.append( "0" ); |
1490 | writeEndDate = true; | 1522 | writeEndDate = true; |
1491 | break; | 1523 | break; |
1492 | case Recurrence::rWeekly:// 1 | 1524 | case Recurrence::rWeekly:// 1 |
1493 | list.append( "1" ); | 1525 | list.append( "1" ); |
1494 | list.append( QString::number( rec->frequency()) );//12 | 1526 | list.append( QString::number( rec->frequency()) );//12 |
1495 | list.append( "0" ); | 1527 | list.append( "0" ); |
1496 | { | 1528 | { |
1497 | int days = 0; | 1529 | int days = 0; |
1498 | QBitArray weekDays = rec->days(); | 1530 | QBitArray weekDays = rec->days(); |
1499 | int i; | 1531 | int i; |
1500 | for( i = 1; i <= 7; ++i ) { | 1532 | for( i = 1; i <= 7; ++i ) { |
1501 | if ( weekDays[i-1] ) { | 1533 | if ( weekDays[i-1] ) { |
1502 | days += 1 << (i-1); | 1534 | days += 1 << (i-1); |
1503 | } | 1535 | } |
1504 | } | 1536 | } |
1505 | list.append( QString::number( days ) ); | 1537 | list.append( QString::number( days ) ); |
1506 | } | 1538 | } |
1507 | //pending weekdays | 1539 | //pending weekdays |
1508 | writeEndDate = true; | 1540 | writeEndDate = true; |
1509 | 1541 | ||
1510 | break; | 1542 | break; |
1511 | case Recurrence::rMonthlyPos:// 2 | 1543 | case Recurrence::rMonthlyPos:// 2 |
1512 | list.append( "2" ); | 1544 | list.append( "2" ); |
1513 | list.append( QString::number( rec->frequency()) );//12 | 1545 | list.append( QString::number( rec->frequency()) );//12 |
1514 | 1546 | ||
1515 | writeEndDate = true; | 1547 | writeEndDate = true; |
1516 | { | 1548 | { |
1517 | int count = 1; | 1549 | int count = 1; |
1518 | QPtrList<Recurrence::rMonthPos> rmp; | 1550 | QPtrList<Recurrence::rMonthPos> rmp; |
1519 | rmp = rec->monthPositions(); | 1551 | rmp = rec->monthPositions(); |
1520 | if ( rmp.first()->negative ) | 1552 | if ( rmp.first()->negative ) |
1521 | count = 5 - rmp.first()->rPos - 1; | 1553 | count = 5 - rmp.first()->rPos - 1; |
1522 | else | 1554 | else |
1523 | count = rmp.first()->rPos - 1; | 1555 | count = rmp.first()->rPos - 1; |
1524 | list.append( QString::number( count ) ); | 1556 | list.append( QString::number( count ) ); |
1525 | 1557 | ||
1526 | } | 1558 | } |
1527 | 1559 | ||
1528 | list.append( "0" ); | 1560 | list.append( "0" ); |
1529 | break; | 1561 | break; |
1530 | case Recurrence::rMonthlyDay:// 3 | 1562 | case Recurrence::rMonthlyDay:// 3 |
1531 | list.append( "3" ); | 1563 | list.append( "3" ); |
1532 | list.append( QString::number( rec->frequency()) );//12 | 1564 | list.append( QString::number( rec->frequency()) );//12 |
1533 | list.append( "0" ); | 1565 | list.append( "0" ); |
1534 | list.append( "0" ); | 1566 | list.append( "0" ); |
1535 | writeEndDate = true; | 1567 | writeEndDate = true; |
1536 | break; | 1568 | break; |
1537 | case Recurrence::rYearlyMonth://4 | 1569 | case Recurrence::rYearlyMonth://4 |
1538 | list.append( "4" ); | 1570 | list.append( "4" ); |
1539 | list.append( QString::number( rec->frequency()) );//12 | 1571 | list.append( QString::number( rec->frequency()) );//12 |
1540 | list.append( "0" ); | 1572 | list.append( "0" ); |
1541 | list.append( "0" ); | 1573 | list.append( "0" ); |
1542 | writeEndDate = true; | 1574 | writeEndDate = true; |
1543 | break; | 1575 | break; |
1544 | 1576 | ||
1545 | default: | 1577 | default: |
1546 | list.append( "255" ); | 1578 | list.append( "255" ); |
1547 | list.append( QString() ); | 1579 | list.append( QString() ); |
1548 | list.append( "0" ); | 1580 | list.append( "0" ); |
1549 | list.append( QString() ); | 1581 | list.append( QString() ); |
1550 | list.append( "0" ); | 1582 | list.append( "0" ); |
1551 | list.append( "20991231T000000" ); | 1583 | list.append( "20991231T000000" ); |
1552 | break; | 1584 | break; |
1553 | } | 1585 | } |
1554 | if ( writeEndDate ) { | 1586 | if ( writeEndDate ) { |
1555 | 1587 | ||
1556 | if ( rec->endDate().isValid() ) { // 15 + 16 | 1588 | if ( rec->endDate().isValid() ) { // 15 + 16 |
1557 | list.append( "1" ); | 1589 | list.append( "1" ); |
1558 | list.append( dtToString( rec->endDate()) ); | 1590 | list.append( dtToString( rec->endDate()) ); |
1559 | } else { | 1591 | } else { |
1560 | list.append( "0" ); | 1592 | list.append( "0" ); |
1561 | list.append( "20991231T000000" ); | 1593 | list.append( "20991231T000000" ); |
1562 | } | 1594 | } |
1563 | 1595 | ||
1564 | } | 1596 | } |
1565 | if ( event->doesFloat () ) { | 1597 | if ( event->doesFloat () ) { |
1566 | list.append( dtToString( event->dtStart(), false ).left( 8 )); | 1598 | list.append( dtToString( event->dtStart(), false ).left( 8 )); |
1567 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 | 1599 | list.append( dtToString( event->dtEnd(), false ).left( 8 )); //6 |
1568 | 1600 | ||
1569 | } | 1601 | } |
1570 | else { | 1602 | else { |
1571 | list.append( QString() ); | 1603 | list.append( QString() ); |
1572 | list.append( QString() ); | 1604 | list.append( QString() ); |
1573 | 1605 | ||
1574 | } | 1606 | } |
1575 | if (event->dtStart().date() == event->dtEnd().date() ) | 1607 | if (event->dtStart().date() == event->dtEnd().date() ) |
1576 | list.append( "0" ); | 1608 | list.append( "0" ); |
1577 | else | 1609 | else |
1578 | list.append( "1" ); | 1610 | list.append( "1" ); |
1579 | 1611 | ||
1580 | 1612 | ||
1581 | for(QStringList::Iterator it=list.begin(); | 1613 | for(QStringList::Iterator it=list.begin(); |
1582 | it!=list.end(); ++it){ | 1614 | it!=list.end(); ++it){ |
1583 | QString& s = (*it); | 1615 | QString& s = (*it); |
1584 | s.replace(QRegExp("\""), "\"\""); | 1616 | s.replace(QRegExp("\""), "\"\""); |
1585 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 1617 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
1586 | s.prepend('\"'); | 1618 | s.prepend('\"'); |
1587 | s.append('\"'); | 1619 | s.append('\"'); |
1588 | } else if(s.isEmpty() && !s.isNull()){ | 1620 | } else if(s.isEmpty() && !s.isNull()){ |
1589 | s = "\"\""; | 1621 | s = "\"\""; |
1590 | } | 1622 | } |
1591 | } | 1623 | } |
1592 | return list.join(","); | 1624 | return list.join(","); |
1593 | #endif | 1625 | #endif |
1594 | return QString(); | 1626 | return QString(); |
1595 | 1627 | ||
1596 | } | 1628 | } |
1597 | QString PhoneFormat::getTodoString( Todo* todo ) | 1629 | QString PhoneFormat::getTodoString( Todo* todo ) |
1598 | { | 1630 | { |
1599 | #if 0 | 1631 | #if 0 |
1600 | QStringList list; | 1632 | QStringList list; |
1601 | list.append( QString::number( todo->zaurusId() ) ); | 1633 | list.append( QString::number( todo->zaurusId() ) ); |
1602 | list.append( todo->categories().join(",") ); | 1634 | list.append( todo->categories().join(",") ); |
1603 | 1635 | ||
1604 | if ( todo->hasStartDate() ) { | 1636 | if ( todo->hasStartDate() ) { |
1605 | list.append( dtToString( todo->dtStart()) ); | 1637 | list.append( dtToString( todo->dtStart()) ); |
1606 | } else | 1638 | } else |
1607 | list.append( QString() ); | 1639 | list.append( QString() ); |
1608 | 1640 | ||
1609 | if ( todo->hasDueDate() ) { | 1641 | if ( todo->hasDueDate() ) { |
1610 | QTime tim; | 1642 | QTime tim; |
1611 | if ( todo->doesFloat()) { | 1643 | if ( todo->doesFloat()) { |
1612 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | 1644 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; |
1613 | } else { | 1645 | } else { |
1614 | list.append( dtToString(todo->dtDue() ) ); | 1646 | list.append( dtToString(todo->dtDue() ) ); |
1615 | } | 1647 | } |
1616 | } else | 1648 | } else |
1617 | list.append( QString() ); | 1649 | list.append( QString() ); |
1618 | 1650 | ||
1619 | if ( todo->isCompleted() ) { | 1651 | if ( todo->isCompleted() ) { |
1620 | list.append( dtToString( todo->completed()) ); | 1652 | list.append( dtToString( todo->completed()) ); |
1621 | list.append( "0" ); // yes 0 == completed | 1653 | list.append( "0" ); // yes 0 == completed |
1622 | } else { | 1654 | } else { |
1623 | list.append( dtToString( todo->completed()) ); | 1655 | list.append( dtToString( todo->completed()) ); |
1624 | list.append( "1" ); | 1656 | list.append( "1" ); |
1625 | } | 1657 | } |
1626 | list.append( QString::number( todo->priority() )); | 1658 | list.append( QString::number( todo->priority() )); |
1627 | if( ! todo->summary().isEmpty() ) | 1659 | if( ! todo->summary().isEmpty() ) |
1628 | list.append( todo->summary() ); | 1660 | list.append( todo->summary() ); |
1629 | else | 1661 | else |
1630 | list.append( "" ); | 1662 | list.append( "" ); |
1631 | if (! todo->description().isEmpty() ) | 1663 | if (! todo->description().isEmpty() ) |
1632 | list.append( todo->description() ); | 1664 | list.append( todo->description() ); |
1633 | else | 1665 | else |
1634 | list.append( "" ); | 1666 | list.append( "" ); |
1635 | for(QStringList::Iterator it=list.begin(); | 1667 | for(QStringList::Iterator it=list.begin(); |
1636 | it!=list.end(); ++it){ | 1668 | it!=list.end(); ++it){ |
1637 | QString& s = (*it); | 1669 | QString& s = (*it); |
1638 | s.replace(QRegExp("\""), "\"\""); | 1670 | s.replace(QRegExp("\""), "\"\""); |
1639 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 1671 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
1640 | s.prepend('\"'); | 1672 | s.prepend('\"'); |
1641 | s.append('\"'); | 1673 | s.append('\"'); |
1642 | } else if(s.isEmpty() && !s.isNull()){ | 1674 | } else if(s.isEmpty() && !s.isNull()){ |
1643 | s = "\"\""; | 1675 | s = "\"\""; |
1644 | } | 1676 | } |
1645 | } | 1677 | } |
1646 | return list.join(","); | 1678 | return list.join(","); |
1647 | #endif | 1679 | #endif |
1648 | return QString(); | 1680 | return QString(); |
1649 | } | 1681 | } |
1650 | 1682 | ||
1651 | 1683 | ||
1652 | QString PhoneFormat::toString( Calendar * ) | 1684 | QString PhoneFormat::toString( Calendar * ) |
1653 | { | 1685 | { |
1654 | return QString::null; | 1686 | return QString::null; |
1655 | } | 1687 | } |
1656 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) | 1688 | bool PhoneFormat::fromString( Calendar *calendar, const QString & text) |
1657 | { | 1689 | { |
1658 | return false; | 1690 | return false; |
1659 | } | 1691 | } |
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp index 9307f12..0ebd7d1 100644 --- a/libkcal/vcalformat.cpp +++ b/libkcal/vcalformat.cpp | |||
@@ -1,1705 +1,1714 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brwon | 3 | Copyright (c) 1998 Preston Brwon |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #include <qapplication.h> | 22 | #include <qapplication.h> |
23 | #include <qdatetime.h> | 23 | #include <qdatetime.h> |
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | #include <qptrlist.h> | 25 | #include <qptrlist.h> |
26 | #include <qregexp.h> | 26 | #include <qregexp.h> |
27 | #include <qclipboard.h> | 27 | #include <qclipboard.h> |
28 | #include <qdialog.h> | 28 | #include <qdialog.h> |
29 | #include <qfile.h> | 29 | #include <qfile.h> |
30 | 30 | ||
31 | #include <kdebug.h> | 31 | #include <kdebug.h> |
32 | #include <kglobal.h> | ||
32 | #include <kmessagebox.h> | 33 | #include <kmessagebox.h> |
33 | #include <kiconloader.h> | 34 | #include <kiconloader.h> |
34 | #include <klocale.h> | 35 | #include <klocale.h> |
35 | 36 | ||
36 | #include "vcc.h" | 37 | #include "vcc.h" |
37 | #include "vobject.h" | 38 | #include "vobject.h" |
38 | 39 | ||
39 | #include "vcaldrag.h" | 40 | #include "vcaldrag.h" |
40 | #include "calendar.h" | 41 | #include "calendar.h" |
41 | 42 | ||
42 | #include "vcalformat.h" | 43 | #include "vcalformat.h" |
43 | 44 | ||
44 | using namespace KCal; | 45 | using namespace KCal; |
45 | 46 | ||
46 | VCalFormat::VCalFormat() | 47 | VCalFormat::VCalFormat() |
47 | { | 48 | { |
48 | mCalendar = 0; | 49 | mCalendar = 0; |
50 | useLocalTime = false; | ||
49 | } | 51 | } |
50 | 52 | ||
51 | VCalFormat::~VCalFormat() | 53 | VCalFormat::~VCalFormat() |
52 | { | 54 | { |
53 | } | 55 | } |
54 | 56 | ||
55 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) | 57 | bool VCalFormat::load(Calendar *calendar, const QString &fileName) |
56 | { | 58 | { |
57 | mCalendar = calendar; | 59 | mCalendar = calendar; |
58 | 60 | ||
59 | clearException(); | 61 | clearException(); |
60 | 62 | ||
61 | kdDebug(5800) << "VCalFormat::load() " << fileName << endl; | 63 | kdDebug(5800) << "VCalFormat::load() " << fileName << endl; |
62 | 64 | ||
63 | VObject *vcal = 0; | 65 | VObject *vcal = 0; |
64 | 66 | ||
65 | // this is not necessarily only 1 vcal. Could be many vcals, or include | 67 | // this is not necessarily only 1 vcal. Could be many vcals, or include |
66 | // a vcard... | 68 | // a vcard... |
67 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); | 69 | vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); |
68 | 70 | ||
69 | if (!vcal) { | 71 | if (!vcal) { |
70 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); | 72 | setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); |
71 | return FALSE; | 73 | return FALSE; |
72 | } | 74 | } |
73 | 75 | ||
74 | // any other top-level calendar stuff should be added/initialized here | 76 | // any other top-level calendar stuff should be added/initialized here |
75 | 77 | ||
76 | // put all vobjects into their proper places | 78 | // put all vobjects into their proper places |
77 | populate(vcal); | 79 | populate(vcal); |
78 | 80 | ||
79 | // clean up from vcal API stuff | 81 | // clean up from vcal API stuff |
80 | cleanVObjects(vcal); | 82 | cleanVObjects(vcal); |
81 | cleanStrTbl(); | 83 | cleanStrTbl(); |
82 | 84 | ||
83 | return true; | 85 | return true; |
84 | } | 86 | } |
85 | 87 | ||
86 | 88 | ||
87 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) | 89 | bool VCalFormat::save(Calendar *calendar, const QString &fileName) |
88 | { | 90 | { |
89 | mCalendar = calendar; | 91 | mCalendar = calendar; |
90 | 92 | ||
91 | QString tmpStr; | 93 | QString tmpStr; |
92 | VObject *vcal, *vo; | 94 | VObject *vcal, *vo; |
93 | 95 | ||
94 | kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; | 96 | kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; |
95 | 97 | ||
96 | vcal = newVObject(VCCalProp); | 98 | vcal = newVObject(VCCalProp); |
97 | 99 | ||
98 | // addPropValue(vcal,VCLocationProp, "0.0"); | 100 | // addPropValue(vcal,VCLocationProp, "0.0"); |
99 | addPropValue(vcal,VCProdIdProp, productId()); | 101 | addPropValue(vcal,VCProdIdProp, productId()); |
100 | tmpStr = mCalendar->getTimeZoneStr(); | 102 | tmpStr = mCalendar->getTimeZoneStr(); |
101 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); | 103 | //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); |
102 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); | 104 | addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); |
103 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); | 105 | addPropValue(vcal,VCVersionProp, _VCAL_VERSION); |
104 | 106 | ||
105 | // TODO STUFF | 107 | // TODO STUFF |
106 | QPtrList<Todo> todoList = mCalendar->rawTodos(); | 108 | QPtrList<Todo> todoList = mCalendar->rawTodos(); |
107 | QPtrListIterator<Todo> qlt(todoList); | 109 | QPtrListIterator<Todo> qlt(todoList); |
108 | for (; qlt.current(); ++qlt) { | 110 | for (; qlt.current(); ++qlt) { |
109 | vo = eventToVTodo(qlt.current()); | 111 | vo = eventToVTodo(qlt.current()); |
110 | addVObjectProp(vcal, vo); | 112 | addVObjectProp(vcal, vo); |
111 | } | 113 | } |
112 | 114 | ||
113 | // EVENT STUFF | 115 | // EVENT STUFF |
114 | QPtrList<Event> events = mCalendar->rawEvents(); | 116 | QPtrList<Event> events = mCalendar->rawEvents(); |
115 | Event *ev; | 117 | Event *ev; |
116 | for(ev=events.first();ev;ev=events.next()) { | 118 | for(ev=events.first();ev;ev=events.next()) { |
117 | vo = eventToVEvent(ev); | 119 | vo = eventToVEvent(ev); |
118 | addVObjectProp(vcal, vo); | 120 | addVObjectProp(vcal, vo); |
119 | } | 121 | } |
120 | 122 | ||
121 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); | 123 | writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); |
122 | cleanVObjects(vcal); | 124 | cleanVObjects(vcal); |
123 | cleanStrTbl(); | 125 | cleanStrTbl(); |
124 | 126 | ||
125 | if (QFile::exists(fileName)) { | 127 | if (QFile::exists(fileName)) { |
126 | kdDebug(5800) << "No error" << endl; | 128 | kdDebug(5800) << "No error" << endl; |
127 | return true; | 129 | return true; |
128 | } else { | 130 | } else { |
129 | kdDebug(5800) << "Error" << endl; | 131 | kdDebug(5800) << "Error" << endl; |
130 | return false; // error | 132 | return false; // error |
131 | } | 133 | } |
132 | } | 134 | } |
133 | 135 | ||
134 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) | 136 | bool VCalFormat::fromString( Calendar *calendar, const QString &text ) |
135 | { | 137 | { |
136 | // TODO: Factor out VCalFormat::fromString() | 138 | // TODO: Factor out VCalFormat::fromString() |
137 | 139 | ||
138 | QCString data = text.utf8(); | 140 | QCString data = text.utf8(); |
139 | 141 | ||
140 | if ( !data.size() ) return false; | 142 | if ( !data.size() ) return false; |
141 | 143 | ||
142 | VObject *vcal = Parse_MIME( data.data(), data.size()); | 144 | VObject *vcal = Parse_MIME( data.data(), data.size()); |
143 | if ( !vcal ) return false; | 145 | if ( !vcal ) return false; |
144 | 146 | ||
145 | VObjectIterator i; | 147 | VObjectIterator i; |
146 | VObject *curvo; | 148 | VObject *curvo; |
147 | initPropIterator( &i, vcal ); | 149 | initPropIterator( &i, vcal ); |
148 | 150 | ||
149 | // we only take the first object. TODO: parse all incidences. | 151 | // we only take the first object. TODO: parse all incidences. |
150 | do { | 152 | do { |
151 | curvo = nextVObject( &i ); | 153 | curvo = nextVObject( &i ); |
152 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && | 154 | } while ( strcmp( vObjectName( curvo ), VCEventProp ) && |
153 | strcmp( vObjectName( curvo ), VCTodoProp ) ); | 155 | strcmp( vObjectName( curvo ), VCTodoProp ) ); |
154 | 156 | ||
155 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { | 157 | if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { |
156 | Event *event = VEventToEvent( curvo ); | 158 | Event *event = VEventToEvent( curvo ); |
157 | calendar->addEvent( event ); | 159 | calendar->addEvent( event ); |
158 | } else { | 160 | } else { |
159 | kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; | 161 | kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; |
160 | deleteVObject( vcal ); | 162 | deleteVObject( vcal ); |
161 | return false; | 163 | return false; |
162 | } | 164 | } |
163 | 165 | ||
164 | deleteVObject( vcal ); | 166 | deleteVObject( vcal ); |
165 | 167 | ||
166 | return true; | 168 | return true; |
167 | } | 169 | } |
168 | 170 | ||
169 | QString VCalFormat::eventToString( Event * event, Calendar *calendar) | 171 | QString VCalFormat::eventToString( Event * event, Calendar *calendar, bool useLocal) |
170 | { | 172 | { |
173 | |||
171 | if ( !event ) return QString::null; | 174 | if ( !event ) return QString::null; |
175 | bool useL = useLocalTime; | ||
176 | useLocalTime = useLocal; | ||
172 | mCalendar = calendar; | 177 | mCalendar = calendar; |
173 | VObject *vevent = eventToVEvent( event ); | 178 | VObject *vevent = eventToVEvent( event ); |
174 | char *buf = writeMemVObject( 0, 0, vevent ); | 179 | char *buf = writeMemVObject( 0, 0, vevent ); |
175 | QString result( buf ); | 180 | QString result( buf ); |
176 | cleanVObject( vevent ); | 181 | cleanVObject( vevent ); |
182 | useLocalTime = useL; | ||
177 | return result; | 183 | return result; |
178 | } | 184 | } |
179 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar ) | 185 | QString VCalFormat::todoToString( Todo * todo, Calendar *calendar, bool useLocal ) |
180 | { | 186 | { |
187 | |||
181 | if ( !todo ) return QString::null; | 188 | if ( !todo ) return QString::null; |
189 | bool useL = useLocalTime; | ||
190 | useLocalTime = useLocal; | ||
182 | mCalendar = calendar; | 191 | mCalendar = calendar; |
183 | VObject *vevent = eventToVTodo( todo ); | 192 | VObject *vevent = eventToVTodo( todo ); |
184 | char *buf = writeMemVObject( 0, 0, vevent ); | 193 | char *buf = writeMemVObject( 0, 0, vevent ); |
185 | QString result( buf ); | 194 | QString result( buf ); |
186 | cleanVObject( vevent ); | 195 | cleanVObject( vevent ); |
196 | useLocalTime = useL; | ||
187 | return result; | 197 | return result; |
188 | } | 198 | } |
189 | 199 | ||
190 | QString VCalFormat::toString( Calendar *calendar ) | 200 | QString VCalFormat::toString( Calendar *calendar ) |
191 | { | 201 | { |
192 | // TODO: Factor out VCalFormat::asString() | 202 | // TODO: Factor out VCalFormat::asString() |
193 | 203 | ||
194 | VObject *vcal = newVObject(VCCalProp); | 204 | VObject *vcal = newVObject(VCCalProp); |
195 | 205 | ||
196 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); | 206 | addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); |
197 | QString tmpStr = mCalendar->getTimeZoneStr(); | 207 | QString tmpStr = mCalendar->getTimeZoneStr(); |
198 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); | 208 | addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); |
199 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); | 209 | addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); |
200 | 210 | ||
201 | // TODO: Use all data. | 211 | // TODO: Use all data. |
202 | QPtrList<Event> events = calendar->events(); | 212 | QPtrList<Event> events = calendar->events(); |
203 | Event *event = events.first(); | 213 | Event *event = events.first(); |
204 | if ( !event ) return QString::null; | 214 | if ( !event ) return QString::null; |
205 | 215 | ||
206 | VObject *vevent = eventToVEvent( event ); | 216 | VObject *vevent = eventToVEvent( event ); |
207 | 217 | ||
208 | addVObjectProp( vcal, vevent ); | 218 | addVObjectProp( vcal, vevent ); |
209 | 219 | ||
210 | char *buf = writeMemVObject( 0, 0, vcal ); | 220 | char *buf = writeMemVObject( 0, 0, vcal ); |
211 | 221 | ||
212 | QString result( buf ); | 222 | QString result( buf ); |
213 | 223 | ||
214 | cleanVObject( vcal ); | 224 | cleanVObject( vcal ); |
215 | 225 | ||
216 | return result; | 226 | return result; |
217 | } | 227 | } |
218 | 228 | ||
219 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) | 229 | VObject *VCalFormat::eventToVTodo(const Todo *anEvent) |
220 | { | 230 | { |
221 | VObject *vtodo; | 231 | VObject *vtodo; |
222 | QString tmpStr; | 232 | QString tmpStr; |
223 | QStringList tmpStrList; | 233 | QStringList tmpStrList; |
224 | 234 | ||
225 | vtodo = newVObject(VCTodoProp); | 235 | vtodo = newVObject(VCTodoProp); |
226 | 236 | ||
227 | // due date | 237 | // due date |
228 | if (anEvent->hasDueDate()) { | 238 | if (anEvent->hasDueDate()) { |
229 | tmpStr = qDateTimeToISO(anEvent->dtDue(), | 239 | tmpStr = qDateTimeToISO(anEvent->dtDue(), |
230 | !anEvent->doesFloat()); | 240 | !anEvent->doesFloat()); |
231 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); | 241 | addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); |
232 | } | 242 | } |
233 | 243 | ||
234 | // start date | 244 | // start date |
235 | if (anEvent->hasStartDate()) { | 245 | if (anEvent->hasStartDate()) { |
236 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 246 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
237 | !anEvent->doesFloat()); | 247 | !anEvent->doesFloat()); |
238 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); | 248 | addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); |
239 | } | 249 | } |
240 | 250 | ||
241 | // creation date | 251 | // creation date |
242 | tmpStr = qDateTimeToISO(anEvent->created()); | 252 | tmpStr = qDateTimeToISO(anEvent->created()); |
243 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); | 253 | addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); |
244 | 254 | ||
245 | // unique id | 255 | // unique id |
246 | addPropValue(vtodo, VCUniqueStringProp, | 256 | addPropValue(vtodo, VCUniqueStringProp, |
247 | anEvent->uid().local8Bit()); | 257 | anEvent->uid().local8Bit()); |
248 | 258 | ||
249 | // revision | 259 | // revision |
250 | tmpStr.sprintf("%i", anEvent->revision()); | 260 | tmpStr.sprintf("%i", anEvent->revision()); |
251 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); | 261 | addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); |
252 | 262 | ||
253 | // last modification date | 263 | // last modification date |
254 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 264 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
255 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); | 265 | addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); |
256 | 266 | ||
257 | // organizer stuff | 267 | // organizer stuff |
258 | tmpStr = "MAILTO:" + anEvent->organizer(); | 268 | tmpStr = "MAILTO:" + anEvent->organizer(); |
259 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); | 269 | addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); |
260 | 270 | ||
261 | // attendees | 271 | // attendees |
262 | if (anEvent->attendeeCount() != 0) { | 272 | if (anEvent->attendeeCount() != 0) { |
263 | QPtrList<Attendee> al = anEvent->attendees(); | 273 | QPtrList<Attendee> al = anEvent->attendees(); |
264 | QPtrListIterator<Attendee> ai(al); | 274 | QPtrListIterator<Attendee> ai(al); |
265 | Attendee *curAttendee; | 275 | Attendee *curAttendee; |
266 | 276 | ||
267 | for (; ai.current(); ++ai) { | 277 | for (; ai.current(); ++ai) { |
268 | curAttendee = ai.current(); | 278 | curAttendee = ai.current(); |
269 | if (!curAttendee->email().isEmpty() && | 279 | if (!curAttendee->email().isEmpty() && |
270 | !curAttendee->name().isEmpty()) | 280 | !curAttendee->name().isEmpty()) |
271 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 281 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
272 | curAttendee->email() + ">"; | 282 | curAttendee->email() + ">"; |
273 | else if (curAttendee->name().isEmpty()) | 283 | else if (curAttendee->name().isEmpty()) |
274 | tmpStr = "MAILTO: " + curAttendee->email(); | 284 | tmpStr = "MAILTO: " + curAttendee->email(); |
275 | else if (curAttendee->email().isEmpty()) | 285 | else if (curAttendee->email().isEmpty()) |
276 | tmpStr = "MAILTO: " + curAttendee->name(); | 286 | tmpStr = "MAILTO: " + curAttendee->name(); |
277 | else if (curAttendee->name().isEmpty() && | 287 | else if (curAttendee->name().isEmpty() && |
278 | curAttendee->email().isEmpty()) | 288 | curAttendee->email().isEmpty()) |
279 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 289 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
280 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); | 290 | VObject *aProp = addPropValue(vtodo, VCAttendeeProp, tmpStr.local8Bit()); |
281 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); | 291 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE"); |
282 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 292 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
283 | } | 293 | } |
284 | } | 294 | } |
285 | 295 | ||
286 | // description BL: | 296 | // description BL: |
287 | if (!anEvent->description().isEmpty()) { | 297 | if (!anEvent->description().isEmpty()) { |
288 | VObject *d = addPropValue(vtodo, VCDescriptionProp, | 298 | VObject *d = addPropValue(vtodo, VCDescriptionProp, |
289 | anEvent->description().local8Bit()); | 299 | anEvent->description().local8Bit()); |
290 | if (anEvent->description().find('\n') != -1) | 300 | if (anEvent->description().find('\n') != -1) |
291 | addProp(d, VCQuotedPrintableProp); | 301 | addProp(d, VCQuotedPrintableProp); |
292 | } | 302 | } |
293 | 303 | ||
294 | // summary | 304 | // summary |
295 | if (!anEvent->summary().isEmpty()) | 305 | if (!anEvent->summary().isEmpty()) |
296 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); | 306 | addPropValue(vtodo, VCSummaryProp, anEvent->summary().local8Bit()); |
297 | 307 | ||
298 | if (!anEvent->location().isEmpty()) | 308 | if (!anEvent->location().isEmpty()) |
299 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); | 309 | addPropValue(vtodo, VCLocationProp, anEvent->location().local8Bit()); |
300 | 310 | ||
301 | // completed | 311 | // completed |
302 | // status | 312 | // status |
303 | // backward compatibility, KOrganizer used to interpret only these two values | 313 | // backward compatibility, KOrganizer used to interpret only these two values |
304 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : | 314 | addPropValue(vtodo, VCStatusProp, anEvent->isCompleted() ? "COMPLETED" : |
305 | "NEEDS_ACTION"); | 315 | "NEEDS_ACTION"); |
306 | // completion date | 316 | // completion date |
307 | if (anEvent->hasCompletedDate()) { | 317 | if (anEvent->hasCompletedDate()) { |
308 | tmpStr = qDateTimeToISO(anEvent->completed()); | 318 | tmpStr = qDateTimeToISO(anEvent->completed()); |
309 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); | 319 | addPropValue(vtodo, VCCompletedProp, tmpStr.local8Bit()); |
310 | } | 320 | } |
311 | 321 | ||
312 | // priority | 322 | // priority |
313 | tmpStr.sprintf("%i",anEvent->priority()); | 323 | tmpStr.sprintf("%i",anEvent->priority()); |
314 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); | 324 | addPropValue(vtodo, VCPriorityProp, tmpStr.local8Bit()); |
315 | 325 | ||
316 | // related event | 326 | // related event |
317 | if (anEvent->relatedTo()) { | 327 | if (anEvent->relatedTo()) { |
318 | addPropValue(vtodo, VCRelatedToProp, | 328 | addPropValue(vtodo, VCRelatedToProp, |
319 | anEvent->relatedTo()->uid().local8Bit()); | 329 | anEvent->relatedTo()->uid().local8Bit()); |
320 | } | 330 | } |
321 | 331 | ||
322 | // categories | 332 | // categories |
323 | tmpStrList = anEvent->categories(); | 333 | tmpStrList = anEvent->categories(); |
324 | tmpStr = ""; | 334 | tmpStr = ""; |
325 | QString catStr; | 335 | QString catStr; |
326 | for ( QStringList::Iterator it = tmpStrList.begin(); | 336 | for ( QStringList::Iterator it = tmpStrList.begin(); |
327 | it != tmpStrList.end(); | 337 | it != tmpStrList.end(); |
328 | ++it ) { | 338 | ++it ) { |
329 | catStr = *it; | 339 | catStr = *it; |
330 | if (catStr[0] == ' ') | 340 | if (catStr[0] == ' ') |
331 | tmpStr += catStr.mid(1); | 341 | tmpStr += catStr.mid(1); |
332 | else | 342 | else |
333 | tmpStr += catStr; | 343 | tmpStr += catStr; |
334 | // this must be a ';' character as the vCalendar specification requires! | 344 | // this must be a ';' character as the vCalendar specification requires! |
335 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 345 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
336 | // read in. | 346 | // read in. |
337 | tmpStr += ";"; | 347 | tmpStr += ";"; |
338 | } | 348 | } |
339 | if (!tmpStr.isEmpty()) { | 349 | if (!tmpStr.isEmpty()) { |
340 | tmpStr.truncate(tmpStr.length()-1); | 350 | tmpStr.truncate(tmpStr.length()-1); |
341 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); | 351 | addPropValue(vtodo, VCCategoriesProp, tmpStr.local8Bit()); |
342 | } | 352 | } |
343 | 353 | ||
344 | // alarm stuff | 354 | // alarm stuff |
345 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; | 355 | kdDebug(5800) << "vcalformat::eventToVTodo was called" << endl; |
346 | QPtrList<Alarm> alarms = anEvent->alarms(); | 356 | QPtrList<Alarm> alarms = anEvent->alarms(); |
347 | Alarm* alarm; | 357 | Alarm* alarm; |
348 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 358 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
349 | if (alarm->enabled()) { | 359 | if (alarm->enabled()) { |
350 | VObject *a; | 360 | VObject *a; |
351 | tmpStr = qDateTimeToISO(alarm->time()); | 361 | tmpStr = qDateTimeToISO(alarm->time()); |
352 | if (alarm->type() == Alarm::Audio) { | 362 | if (alarm->type() == Alarm::Audio) { |
353 | a = addProp(vtodo, VCAAlarmProp); | 363 | a = addProp(vtodo, VCAAlarmProp); |
354 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 364 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
355 | addPropValue(a, VCRepeatCountProp, "1"); | 365 | addPropValue(a, VCRepeatCountProp, "1"); |
356 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 366 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
357 | } | 367 | } |
358 | else if (alarm->type() == Alarm::Procedure) { | 368 | else if (alarm->type() == Alarm::Procedure) { |
359 | a = addProp(vtodo, VCPAlarmProp); | 369 | a = addProp(vtodo, VCPAlarmProp); |
360 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 370 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
361 | addPropValue(a, VCRepeatCountProp, "1"); | 371 | addPropValue(a, VCRepeatCountProp, "1"); |
362 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 372 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
363 | } else { | 373 | } else { |
364 | a = addProp(vtodo, VCDAlarmProp); | 374 | a = addProp(vtodo, VCDAlarmProp); |
365 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 375 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
366 | addPropValue(a, VCRepeatCountProp, "1"); | 376 | addPropValue(a, VCRepeatCountProp, "1"); |
367 | addPropValue(a, VCDisplayStringProp, "beep!"); | 377 | addPropValue(a, VCDisplayStringProp, "beep!"); |
368 | } | 378 | } |
369 | } | 379 | } |
370 | } | 380 | } |
371 | 381 | ||
372 | if (anEvent->pilotId()) { | 382 | if (anEvent->pilotId()) { |
373 | // pilot sync stuff | 383 | // pilot sync stuff |
374 | tmpStr.sprintf("%i",anEvent->pilotId()); | 384 | tmpStr.sprintf("%i",anEvent->pilotId()); |
375 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); | 385 | addPropValue(vtodo, XPilotIdProp, tmpStr.local8Bit()); |
376 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 386 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
377 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); | 387 | addPropValue(vtodo, XPilotStatusProp, tmpStr.local8Bit()); |
378 | } | 388 | } |
379 | 389 | ||
380 | return vtodo; | 390 | return vtodo; |
381 | } | 391 | } |
382 | 392 | ||
383 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) | 393 | VObject* VCalFormat::eventToVEvent(const Event *anEvent) |
384 | { | 394 | { |
385 | VObject *vevent; | 395 | VObject *vevent; |
386 | QString tmpStr; | 396 | QString tmpStr; |
387 | QStringList tmpStrList; | 397 | QStringList tmpStrList; |
388 | 398 | ||
389 | vevent = newVObject(VCEventProp); | 399 | vevent = newVObject(VCEventProp); |
390 | 400 | ||
391 | // start and end time | 401 | // start and end time |
392 | tmpStr = qDateTimeToISO(anEvent->dtStart(), | 402 | tmpStr = qDateTimeToISO(anEvent->dtStart(), |
393 | !anEvent->doesFloat()); | 403 | !anEvent->doesFloat()); |
394 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); | 404 | addPropValue(vevent, VCDTstartProp, tmpStr.local8Bit()); |
395 | 405 | ||
396 | // events that have time associated but take up no time should | 406 | // events that have time associated but take up no time should |
397 | // not have both DTSTART and DTEND. | 407 | // not have both DTSTART and DTEND. |
398 | if (anEvent->dtStart() != anEvent->dtEnd()) { | 408 | if (anEvent->dtStart() != anEvent->dtEnd()) { |
399 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), | 409 | tmpStr = qDateTimeToISO(anEvent->dtEnd(), |
400 | !anEvent->doesFloat()); | 410 | !anEvent->doesFloat()); |
401 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); | 411 | addPropValue(vevent, VCDTendProp, tmpStr.local8Bit()); |
402 | } | 412 | } |
403 | 413 | ||
404 | // creation date | 414 | // creation date |
405 | tmpStr = qDateTimeToISO(anEvent->created()); | 415 | tmpStr = qDateTimeToISO(anEvent->created()); |
406 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); | 416 | addPropValue(vevent, VCDCreatedProp, tmpStr.local8Bit()); |
407 | 417 | ||
408 | // unique id | 418 | // unique id |
409 | addPropValue(vevent, VCUniqueStringProp, | 419 | addPropValue(vevent, VCUniqueStringProp, |
410 | anEvent->uid().local8Bit()); | 420 | anEvent->uid().local8Bit()); |
411 | 421 | ||
412 | // revision | 422 | // revision |
413 | tmpStr.sprintf("%i", anEvent->revision()); | 423 | tmpStr.sprintf("%i", anEvent->revision()); |
414 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); | 424 | addPropValue(vevent, VCSequenceProp, tmpStr.local8Bit()); |
415 | 425 | ||
416 | // last modification date | 426 | // last modification date |
417 | tmpStr = qDateTimeToISO(anEvent->lastModified()); | 427 | tmpStr = qDateTimeToISO(anEvent->lastModified()); |
418 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); | 428 | addPropValue(vevent, VCLastModifiedProp, tmpStr.local8Bit()); |
419 | 429 | ||
420 | // attendee and organizer stuff | 430 | // attendee and organizer stuff |
421 | tmpStr = "MAILTO:" + anEvent->organizer(); | 431 | tmpStr = "MAILTO:" + anEvent->organizer(); |
422 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); | 432 | addPropValue(vevent, ICOrganizerProp, tmpStr.local8Bit()); |
423 | 433 | ||
424 | if (anEvent->attendeeCount() != 0) { | 434 | if (anEvent->attendeeCount() != 0) { |
425 | QPtrList<Attendee> al = anEvent->attendees(); | 435 | QPtrList<Attendee> al = anEvent->attendees(); |
426 | QPtrListIterator<Attendee> ai(al); | 436 | QPtrListIterator<Attendee> ai(al); |
427 | Attendee *curAttendee; | 437 | Attendee *curAttendee; |
428 | 438 | ||
429 | // TODO: Put this functionality into Attendee class | 439 | // TODO: Put this functionality into Attendee class |
430 | for (; ai.current(); ++ai) { | 440 | for (; ai.current(); ++ai) { |
431 | curAttendee = ai.current(); | 441 | curAttendee = ai.current(); |
432 | if (!curAttendee->email().isEmpty() && | 442 | if (!curAttendee->email().isEmpty() && |
433 | !curAttendee->name().isEmpty()) | 443 | !curAttendee->name().isEmpty()) |
434 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + | 444 | tmpStr = "MAILTO:" + curAttendee->name() + " <" + |
435 | curAttendee->email() + ">"; | 445 | curAttendee->email() + ">"; |
436 | else if (curAttendee->name().isEmpty()) | 446 | else if (curAttendee->name().isEmpty()) |
437 | tmpStr = "MAILTO: " + curAttendee->email(); | 447 | tmpStr = "MAILTO: " + curAttendee->email(); |
438 | else if (curAttendee->email().isEmpty()) | 448 | else if (curAttendee->email().isEmpty()) |
439 | tmpStr = "MAILTO: " + curAttendee->name(); | 449 | tmpStr = "MAILTO: " + curAttendee->name(); |
440 | else if (curAttendee->name().isEmpty() && | 450 | else if (curAttendee->name().isEmpty() && |
441 | curAttendee->email().isEmpty()) | 451 | curAttendee->email().isEmpty()) |
442 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; | 452 | kdDebug(5800) << "warning! this Event has an attendee w/o name or email!" << endl; |
443 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); | 453 | VObject *aProp = addPropValue(vevent, VCAttendeeProp, tmpStr.local8Bit()); |
444 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; | 454 | addPropValue(aProp, VCRSVPProp, curAttendee->RSVP() ? "TRUE" : "FALSE");; |
445 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); | 455 | addPropValue(aProp, VCStatusProp, writeStatus(curAttendee->status())); |
446 | } | 456 | } |
447 | } | 457 | } |
448 | 458 | ||
449 | // recurrence rule stuff | 459 | // recurrence rule stuff |
450 | if (anEvent->recurrence()->doesRecur()) { | 460 | if (anEvent->recurrence()->doesRecur()) { |
451 | // some more variables | 461 | // some more variables |
452 | QPtrList<Recurrence::rMonthPos> tmpPositions; | 462 | QPtrList<Recurrence::rMonthPos> tmpPositions; |
453 | QPtrList<int> tmpDays; | 463 | QPtrList<int> tmpDays; |
454 | int *tmpDay; | 464 | int *tmpDay; |
455 | Recurrence::rMonthPos *tmpPos; | 465 | Recurrence::rMonthPos *tmpPos; |
456 | QString tmpStr2; | 466 | QString tmpStr2; |
457 | int i; | 467 | int i; |
458 | 468 | ||
459 | switch(anEvent->recurrence()->doesRecur()) { | 469 | switch(anEvent->recurrence()->doesRecur()) { |
460 | case Recurrence::rDaily: | 470 | case Recurrence::rDaily: |
461 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); | 471 | tmpStr.sprintf("D%i ",anEvent->recurrence()->frequency()); |
462 | // if (anEvent->rDuration > 0) | 472 | // if (anEvent->rDuration > 0) |
463 | //tmpStr += "#"; | 473 | //tmpStr += "#"; |
464 | break; | 474 | break; |
465 | case Recurrence::rWeekly: | 475 | case Recurrence::rWeekly: |
466 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); | 476 | tmpStr.sprintf("W%i ",anEvent->recurrence()->frequency()); |
467 | for (i = 0; i < 7; i++) { | 477 | for (i = 0; i < 7; i++) { |
468 | if (anEvent->recurrence()->days().testBit(i)) | 478 | if (anEvent->recurrence()->days().testBit(i)) |
469 | tmpStr += dayFromNum(i); | 479 | tmpStr += dayFromNum(i); |
470 | } | 480 | } |
471 | break; | 481 | break; |
472 | case Recurrence::rMonthlyPos: | 482 | case Recurrence::rMonthlyPos: |
473 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); | 483 | tmpStr.sprintf("MP%i ", anEvent->recurrence()->frequency()); |
474 | // write out all rMonthPos's | 484 | // write out all rMonthPos's |
475 | tmpPositions = anEvent->recurrence()->monthPositions(); | 485 | tmpPositions = anEvent->recurrence()->monthPositions(); |
476 | for (tmpPos = tmpPositions.first(); | 486 | for (tmpPos = tmpPositions.first(); |
477 | tmpPos; | 487 | tmpPos; |
478 | tmpPos = tmpPositions.next()) { | 488 | tmpPos = tmpPositions.next()) { |
479 | 489 | ||
480 | tmpStr2.sprintf("%i", tmpPos->rPos); | 490 | tmpStr2.sprintf("%i", tmpPos->rPos); |
481 | if (tmpPos->negative) | 491 | if (tmpPos->negative) |
482 | tmpStr2 += "- "; | 492 | tmpStr2 += "- "; |
483 | else | 493 | else |
484 | tmpStr2 += "+ "; | 494 | tmpStr2 += "+ "; |
485 | tmpStr += tmpStr2; | 495 | tmpStr += tmpStr2; |
486 | for (i = 0; i < 7; i++) { | 496 | for (i = 0; i < 7; i++) { |
487 | if (tmpPos->rDays.testBit(i)) | 497 | if (tmpPos->rDays.testBit(i)) |
488 | tmpStr += dayFromNum(i); | 498 | tmpStr += dayFromNum(i); |
489 | } | 499 | } |
490 | } // loop for all rMonthPos's | 500 | } // loop for all rMonthPos's |
491 | break; | 501 | break; |
492 | case Recurrence::rMonthlyDay: | 502 | case Recurrence::rMonthlyDay: |
493 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); | 503 | tmpStr.sprintf("MD%i ", anEvent->recurrence()->frequency()); |
494 | // write out all rMonthDays; | 504 | // write out all rMonthDays; |
495 | tmpDays = anEvent->recurrence()->monthDays(); | 505 | tmpDays = anEvent->recurrence()->monthDays(); |
496 | for (tmpDay = tmpDays.first(); | 506 | for (tmpDay = tmpDays.first(); |
497 | tmpDay; | 507 | tmpDay; |
498 | tmpDay = tmpDays.next()) { | 508 | tmpDay = tmpDays.next()) { |
499 | tmpStr2.sprintf("%i ", *tmpDay); | 509 | tmpStr2.sprintf("%i ", *tmpDay); |
500 | tmpStr += tmpStr2; | 510 | tmpStr += tmpStr2; |
501 | } | 511 | } |
502 | break; | 512 | break; |
503 | case Recurrence::rYearlyMonth: | 513 | case Recurrence::rYearlyMonth: |
504 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); | 514 | tmpStr.sprintf("YM%i ", anEvent->recurrence()->frequency()); |
505 | // write out all the rYearNums; | 515 | // write out all the rYearNums; |
506 | tmpDays = anEvent->recurrence()->yearNums(); | 516 | tmpDays = anEvent->recurrence()->yearNums(); |
507 | for (tmpDay = tmpDays.first(); | 517 | for (tmpDay = tmpDays.first(); |
508 | tmpDay; | 518 | tmpDay; |
509 | tmpDay = tmpDays.next()) { | 519 | tmpDay = tmpDays.next()) { |
510 | tmpStr2.sprintf("%i ", *tmpDay); | 520 | tmpStr2.sprintf("%i ", *tmpDay); |
511 | tmpStr += tmpStr2; | 521 | tmpStr += tmpStr2; |
512 | } | 522 | } |
513 | break; | 523 | break; |
514 | case Recurrence::rYearlyDay: | 524 | case Recurrence::rYearlyDay: |
515 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); | 525 | tmpStr.sprintf("YD%i ", anEvent->recurrence()->frequency()); |
516 | // write out all the rYearNums; | 526 | // write out all the rYearNums; |
517 | tmpDays = anEvent->recurrence()->yearNums(); | 527 | tmpDays = anEvent->recurrence()->yearNums(); |
518 | for (tmpDay = tmpDays.first(); | 528 | for (tmpDay = tmpDays.first(); |
519 | tmpDay; | 529 | tmpDay; |
520 | tmpDay = tmpDays.next()) { | 530 | tmpDay = tmpDays.next()) { |
521 | tmpStr2.sprintf("%i ", *tmpDay); | 531 | tmpStr2.sprintf("%i ", *tmpDay); |
522 | tmpStr += tmpStr2; | 532 | tmpStr += tmpStr2; |
523 | } | 533 | } |
524 | break; | 534 | break; |
525 | default: | 535 | default: |
526 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; | 536 | kdDebug(5800) << "ERROR, it should never get here in eventToVEvent!" << endl; |
527 | break; | 537 | break; |
528 | } // switch | 538 | } // switch |
529 | 539 | ||
530 | if (anEvent->recurrence()->duration() > 0) { | 540 | if (anEvent->recurrence()->duration() > 0) { |
531 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); | 541 | tmpStr2.sprintf("#%i",anEvent->recurrence()->duration()); |
532 | tmpStr += tmpStr2; | 542 | tmpStr += tmpStr2; |
533 | } else if (anEvent->recurrence()->duration() == -1) { | 543 | } else if (anEvent->recurrence()->duration() == -1) { |
534 | tmpStr += "#0"; // defined as repeat forever | 544 | tmpStr += "#0"; // defined as repeat forever |
535 | } else { | 545 | } else { |
536 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); | 546 | tmpStr += qDateTimeToISO(anEvent->recurrence()->endDate(), FALSE); |
537 | } | 547 | } |
538 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); | 548 | addPropValue(vevent,VCRRuleProp, tmpStr.local8Bit()); |
539 | 549 | ||
540 | } // event repeats | 550 | } // event repeats |
541 | 551 | ||
542 | // exceptions to recurrence | 552 | // exceptions to recurrence |
543 | DateList dateList = anEvent->exDates(); | 553 | DateList dateList = anEvent->exDates(); |
544 | DateList::ConstIterator it; | 554 | DateList::ConstIterator it; |
545 | QString tmpStr2; | 555 | QString tmpStr2; |
546 | 556 | ||
547 | for (it = dateList.begin(); it != dateList.end(); ++it) { | 557 | for (it = dateList.begin(); it != dateList.end(); ++it) { |
548 | tmpStr = qDateToISO(*it) + ";"; | 558 | tmpStr = qDateToISO(*it) + ";"; |
549 | tmpStr2 += tmpStr; | 559 | tmpStr2 += tmpStr; |
550 | } | 560 | } |
551 | if (!tmpStr2.isEmpty()) { | 561 | if (!tmpStr2.isEmpty()) { |
552 | tmpStr2.truncate(tmpStr2.length()-1); | 562 | tmpStr2.truncate(tmpStr2.length()-1); |
553 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); | 563 | addPropValue(vevent, VCExpDateProp, tmpStr2.local8Bit()); |
554 | } | 564 | } |
555 | 565 | ||
556 | // description | 566 | // description |
557 | if (!anEvent->description().isEmpty()) { | 567 | if (!anEvent->description().isEmpty()) { |
558 | VObject *d = addPropValue(vevent, VCDescriptionProp, | 568 | VObject *d = addPropValue(vevent, VCDescriptionProp, |
559 | anEvent->description().local8Bit()); | 569 | anEvent->description().local8Bit()); |
560 | if (anEvent->description().find('\n') != -1) | 570 | if (anEvent->description().find('\n') != -1) |
561 | addProp(d, VCQuotedPrintableProp); | 571 | addProp(d, VCQuotedPrintableProp); |
562 | } | 572 | } |
563 | 573 | ||
564 | // summary | 574 | // summary |
565 | if (!anEvent->summary().isEmpty()) | 575 | if (!anEvent->summary().isEmpty()) |
566 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); | 576 | addPropValue(vevent, VCSummaryProp, anEvent->summary().local8Bit()); |
567 | 577 | ||
568 | if (!anEvent->location().isEmpty()) | 578 | if (!anEvent->location().isEmpty()) |
569 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); | 579 | addPropValue(vevent, VCLocationProp, anEvent->location().local8Bit()); |
570 | 580 | ||
571 | // status | 581 | // status |
572 | // TODO: define Event status | 582 | // TODO: define Event status |
573 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); | 583 | // addPropValue(vevent, VCStatusProp, anEvent->statusStr().local8Bit()); |
574 | 584 | ||
575 | // secrecy | 585 | // secrecy |
576 | const char *text = 0; | 586 | const char *text = 0; |
577 | switch (anEvent->secrecy()) { | 587 | switch (anEvent->secrecy()) { |
578 | case Incidence::SecrecyPublic: | 588 | case Incidence::SecrecyPublic: |
579 | text = "PUBLIC"; | 589 | text = "PUBLIC"; |
580 | break; | 590 | break; |
581 | case Incidence::SecrecyPrivate: | 591 | case Incidence::SecrecyPrivate: |
582 | text = "PRIVATE"; | 592 | text = "PRIVATE"; |
583 | break; | 593 | break; |
584 | case Incidence::SecrecyConfidential: | 594 | case Incidence::SecrecyConfidential: |
585 | text = "CONFIDENTIAL"; | 595 | text = "CONFIDENTIAL"; |
586 | break; | 596 | break; |
587 | } | 597 | } |
588 | if (text) { | 598 | if (text) { |
589 | addPropValue(vevent, VCClassProp, text); | 599 | addPropValue(vevent, VCClassProp, text); |
590 | } | 600 | } |
591 | 601 | ||
592 | // categories | 602 | // categories |
593 | tmpStrList = anEvent->categories(); | 603 | tmpStrList = anEvent->categories(); |
594 | tmpStr = ""; | 604 | tmpStr = ""; |
595 | QString catStr; | 605 | QString catStr; |
596 | for ( QStringList::Iterator it = tmpStrList.begin(); | 606 | for ( QStringList::Iterator it = tmpStrList.begin(); |
597 | it != tmpStrList.end(); | 607 | it != tmpStrList.end(); |
598 | ++it ) { | 608 | ++it ) { |
599 | catStr = *it; | 609 | catStr = *it; |
600 | if (catStr[0] == ' ') | 610 | if (catStr[0] == ' ') |
601 | tmpStr += catStr.mid(1); | 611 | tmpStr += catStr.mid(1); |
602 | else | 612 | else |
603 | tmpStr += catStr; | 613 | tmpStr += catStr; |
604 | // this must be a ';' character as the vCalendar specification requires! | 614 | // this must be a ';' character as the vCalendar specification requires! |
605 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is | 615 | // vcc.y has been hacked to translate the ';' to a ',' when the vcal is |
606 | // read in. | 616 | // read in. |
607 | tmpStr += ";"; | 617 | tmpStr += ";"; |
608 | } | 618 | } |
609 | if (!tmpStr.isEmpty()) { | 619 | if (!tmpStr.isEmpty()) { |
610 | tmpStr.truncate(tmpStr.length()-1); | 620 | tmpStr.truncate(tmpStr.length()-1); |
611 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); | 621 | addPropValue(vevent, VCCategoriesProp, tmpStr.local8Bit()); |
612 | } | 622 | } |
613 | 623 | ||
614 | // attachments | 624 | // attachments |
615 | // TODO: handle binary attachments! | 625 | // TODO: handle binary attachments! |
616 | QPtrList<Attachment> attachments = anEvent->attachments(); | 626 | QPtrList<Attachment> attachments = anEvent->attachments(); |
617 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) | 627 | for ( Attachment *at = attachments.first(); at; at = attachments.next() ) |
618 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); | 628 | addPropValue(vevent, VCAttachProp, at->uri().local8Bit()); |
619 | 629 | ||
620 | // resources | 630 | // resources |
621 | tmpStrList = anEvent->resources(); | 631 | tmpStrList = anEvent->resources(); |
622 | tmpStr = tmpStrList.join(";"); | 632 | tmpStr = tmpStrList.join(";"); |
623 | if (!tmpStr.isEmpty()) | 633 | if (!tmpStr.isEmpty()) |
624 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); | 634 | addPropValue(vevent, VCResourcesProp, tmpStr.local8Bit()); |
625 | 635 | ||
626 | // alarm stuff | 636 | // alarm stuff |
627 | QPtrList<Alarm> alarms = anEvent->alarms(); | 637 | QPtrList<Alarm> alarms = anEvent->alarms(); |
628 | Alarm* alarm; | 638 | Alarm* alarm; |
629 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { | 639 | for (alarm = alarms.first(); alarm; alarm = alarms.next()) { |
630 | if (alarm->enabled()) { | 640 | if (alarm->enabled()) { |
631 | VObject *a ; | 641 | VObject *a ; |
632 | tmpStr = qDateTimeToISO(alarm->time()); | 642 | tmpStr = qDateTimeToISO(alarm->time()); |
633 | if (alarm->type() == Alarm::Audio) { | 643 | if (alarm->type() == Alarm::Audio) { |
634 | a = addProp(vevent, VCAAlarmProp); | 644 | a = addProp(vevent, VCAAlarmProp); |
635 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 645 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
636 | addPropValue(a, VCRepeatCountProp, "1"); | 646 | addPropValue(a, VCRepeatCountProp, "1"); |
637 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); | 647 | addPropValue(a, VCAudioContentProp, QFile::encodeName(alarm->audioFile())); |
638 | } | 648 | } |
639 | if (alarm->type() == Alarm::Procedure) { | 649 | if (alarm->type() == Alarm::Procedure) { |
640 | a = addProp(vevent, VCPAlarmProp); | 650 | a = addProp(vevent, VCPAlarmProp); |
641 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 651 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
642 | addPropValue(a, VCRepeatCountProp, "1"); | 652 | addPropValue(a, VCRepeatCountProp, "1"); |
643 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); | 653 | addPropValue(a, VCProcedureNameProp, QFile::encodeName(alarm->programFile())); |
644 | } else { | 654 | } else { |
645 | a = addProp(vevent, VCDAlarmProp); | 655 | a = addProp(vevent, VCDAlarmProp); |
646 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); | 656 | addPropValue(a, VCRunTimeProp, tmpStr.local8Bit()); |
647 | addPropValue(a, VCRepeatCountProp, "1"); | 657 | addPropValue(a, VCRepeatCountProp, "1"); |
648 | addPropValue(a, VCDisplayStringProp, "beep!"); | 658 | addPropValue(a, VCDisplayStringProp, "beep!"); |
649 | 659 | ||
650 | } | 660 | } |
651 | } | 661 | } |
652 | } | 662 | } |
653 | 663 | ||
654 | // priority | 664 | // priority |
655 | tmpStr.sprintf("%i",anEvent->priority()); | 665 | tmpStr.sprintf("%i",anEvent->priority()); |
656 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); | 666 | addPropValue(vevent, VCPriorityProp, tmpStr.local8Bit()); |
657 | 667 | ||
658 | // transparency | 668 | // transparency |
659 | tmpStr.sprintf("%i",anEvent->transparency()); | 669 | tmpStr.sprintf("%i",anEvent->transparency()); |
660 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); | 670 | addPropValue(vevent, VCTranspProp, tmpStr.local8Bit()); |
661 | 671 | ||
662 | // related event | 672 | // related event |
663 | if (anEvent->relatedTo()) { | 673 | if (anEvent->relatedTo()) { |
664 | addPropValue(vevent, VCRelatedToProp, | 674 | addPropValue(vevent, VCRelatedToProp, |
665 | anEvent->relatedTo()->uid().local8Bit()); | 675 | anEvent->relatedTo()->uid().local8Bit()); |
666 | } | 676 | } |
667 | 677 | ||
668 | if (anEvent->pilotId()) { | 678 | if (anEvent->pilotId()) { |
669 | // pilot sync stuff | 679 | // pilot sync stuff |
670 | tmpStr.sprintf("%i",anEvent->pilotId()); | 680 | tmpStr.sprintf("%i",anEvent->pilotId()); |
671 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); | 681 | addPropValue(vevent, XPilotIdProp, tmpStr.local8Bit()); |
672 | tmpStr.sprintf("%i",anEvent->syncStatus()); | 682 | tmpStr.sprintf("%i",anEvent->syncStatus()); |
673 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); | 683 | addPropValue(vevent, XPilotStatusProp, tmpStr.local8Bit()); |
674 | } | 684 | } |
675 | 685 | ||
676 | return vevent; | 686 | return vevent; |
677 | } | 687 | } |
678 | 688 | ||
679 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) | 689 | Todo *VCalFormat::VTodoToEvent(VObject *vtodo) |
680 | { | 690 | { |
681 | VObject *vo; | 691 | VObject *vo; |
682 | VObjectIterator voi; | 692 | VObjectIterator voi; |
683 | char *s; | 693 | char *s; |
684 | 694 | ||
685 | Todo *anEvent = new Todo; | 695 | Todo *anEvent = new Todo; |
686 | 696 | ||
687 | // creation date | 697 | // creation date |
688 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { | 698 | if ((vo = isAPropertyOf(vtodo, VCDCreatedProp)) != 0) { |
689 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 699 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
690 | deleteStr(s); | 700 | deleteStr(s); |
691 | } | 701 | } |
692 | 702 | ||
693 | // unique id | 703 | // unique id |
694 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); | 704 | vo = isAPropertyOf(vtodo, VCUniqueStringProp); |
695 | // while the UID property is preferred, it is not required. We'll use the | 705 | // while the UID property is preferred, it is not required. We'll use the |
696 | // default Event UID if none is given. | 706 | // default Event UID if none is given. |
697 | if (vo) { | 707 | if (vo) { |
698 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 708 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
699 | deleteStr(s); | 709 | deleteStr(s); |
700 | } | 710 | } |
701 | 711 | ||
702 | // last modification date | 712 | // last modification date |
703 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { | 713 | if ((vo = isAPropertyOf(vtodo, VCLastModifiedProp)) != 0) { |
704 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 714 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
705 | deleteStr(s); | 715 | deleteStr(s); |
706 | } | 716 | } |
707 | else | 717 | else |
708 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 718 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
709 | QTime::currentTime())); | 719 | QTime::currentTime())); |
710 | 720 | ||
711 | // organizer | 721 | // organizer |
712 | // if our extension property for the event's ORGANIZER exists, add it. | 722 | // if our extension property for the event's ORGANIZER exists, add it. |
713 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { | 723 | if ((vo = isAPropertyOf(vtodo, ICOrganizerProp)) != 0) { |
714 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 724 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
715 | deleteStr(s); | 725 | deleteStr(s); |
716 | } else { | 726 | } else { |
717 | anEvent->setOrganizer(mCalendar->getEmail()); | 727 | anEvent->setOrganizer(mCalendar->getEmail()); |
718 | } | 728 | } |
719 | 729 | ||
720 | // attendees. | 730 | // attendees. |
721 | initPropIterator(&voi, vtodo); | 731 | initPropIterator(&voi, vtodo); |
722 | while (moreIteration(&voi)) { | 732 | while (moreIteration(&voi)) { |
723 | vo = nextVObject(&voi); | 733 | vo = nextVObject(&voi); |
724 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 734 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
725 | Attendee *a; | 735 | Attendee *a; |
726 | VObject *vp; | 736 | VObject *vp; |
727 | s = fakeCString(vObjectUStringZValue(vo)); | 737 | s = fakeCString(vObjectUStringZValue(vo)); |
728 | QString tmpStr = QString::fromLocal8Bit(s); | 738 | QString tmpStr = QString::fromLocal8Bit(s); |
729 | deleteStr(s); | 739 | deleteStr(s); |
730 | tmpStr = tmpStr.simplifyWhiteSpace(); | 740 | tmpStr = tmpStr.simplifyWhiteSpace(); |
731 | int emailPos1, emailPos2; | 741 | int emailPos1, emailPos2; |
732 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 742 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
733 | // both email address and name | 743 | // both email address and name |
734 | emailPos2 = tmpStr.findRev('>'); | 744 | emailPos2 = tmpStr.findRev('>'); |
735 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 745 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
736 | tmpStr.mid(emailPos1 + 1, | 746 | tmpStr.mid(emailPos1 + 1, |
737 | emailPos2 - (emailPos1 + 1))); | 747 | emailPos2 - (emailPos1 + 1))); |
738 | } else if (tmpStr.find('@') > 0) { | 748 | } else if (tmpStr.find('@') > 0) { |
739 | // just an email address | 749 | // just an email address |
740 | a = new Attendee(0, tmpStr); | 750 | a = new Attendee(0, tmpStr); |
741 | } else { | 751 | } else { |
742 | // just a name | 752 | // just a name |
743 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 753 | QString email = tmpStr.replace( QRegExp(" "), "." ); |
744 | a = new Attendee(tmpStr,email); | 754 | a = new Attendee(tmpStr,email); |
745 | } | 755 | } |
746 | 756 | ||
747 | // is there an RSVP property? | 757 | // is there an RSVP property? |
748 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 758 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
749 | a->setRSVP(vObjectStringZValue(vp)); | 759 | a->setRSVP(vObjectStringZValue(vp)); |
750 | // is there a status property? | 760 | // is there a status property? |
751 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 761 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
752 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 762 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
753 | // add the attendee | 763 | // add the attendee |
754 | anEvent->addAttendee(a); | 764 | anEvent->addAttendee(a); |
755 | } | 765 | } |
756 | } | 766 | } |
757 | 767 | ||
758 | // description for todo | 768 | // description for todo |
759 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { | 769 | if ((vo = isAPropertyOf(vtodo, VCDescriptionProp)) != 0) { |
760 | s = fakeCString(vObjectUStringZValue(vo)); | 770 | s = fakeCString(vObjectUStringZValue(vo)); |
761 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 771 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
762 | deleteStr(s); | 772 | deleteStr(s); |
763 | } | 773 | } |
764 | 774 | ||
765 | // summary | 775 | // summary |
766 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { | 776 | if ((vo = isAPropertyOf(vtodo, VCSummaryProp))) { |
767 | s = fakeCString(vObjectUStringZValue(vo)); | 777 | s = fakeCString(vObjectUStringZValue(vo)); |
768 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 778 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
769 | deleteStr(s); | 779 | deleteStr(s); |
770 | } | 780 | } |
771 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { | 781 | if ((vo = isAPropertyOf(vtodo, VCLocationProp))) { |
772 | s = fakeCString(vObjectUStringZValue(vo)); | 782 | s = fakeCString(vObjectUStringZValue(vo)); |
773 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 783 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
774 | deleteStr(s); | 784 | deleteStr(s); |
775 | } | 785 | } |
776 | 786 | ||
777 | 787 | ||
778 | // completed | 788 | // completed |
779 | // was: status | 789 | // was: status |
780 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { | 790 | if ((vo = isAPropertyOf(vtodo, VCStatusProp)) != 0) { |
781 | s = fakeCString(vObjectUStringZValue(vo)); | 791 | s = fakeCString(vObjectUStringZValue(vo)); |
782 | if (strcmp(s,"COMPLETED") == 0) { | 792 | if (strcmp(s,"COMPLETED") == 0) { |
783 | anEvent->setCompleted(true); | 793 | anEvent->setCompleted(true); |
784 | } else { | 794 | } else { |
785 | anEvent->setCompleted(false); | 795 | anEvent->setCompleted(false); |
786 | } | 796 | } |
787 | deleteStr(s); | 797 | deleteStr(s); |
788 | } | 798 | } |
789 | else | 799 | else |
790 | anEvent->setCompleted(false); | 800 | anEvent->setCompleted(false); |
791 | 801 | ||
792 | // completion date | 802 | // completion date |
793 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { | 803 | if ((vo = isAPropertyOf(vtodo, VCCompletedProp)) != 0) { |
794 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 804 | anEvent->setCompleted(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
795 | deleteStr(s); | 805 | deleteStr(s); |
796 | } | 806 | } |
797 | 807 | ||
798 | // priority | 808 | // priority |
799 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { | 809 | if ((vo = isAPropertyOf(vtodo, VCPriorityProp))) { |
800 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 810 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
801 | deleteStr(s); | 811 | deleteStr(s); |
802 | } | 812 | } |
803 | 813 | ||
804 | // due date | 814 | // due date |
805 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { | 815 | if ((vo = isAPropertyOf(vtodo, VCDueProp)) != 0) { |
806 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 816 | anEvent->setDtDue(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
807 | deleteStr(s); | 817 | deleteStr(s); |
808 | anEvent->setHasDueDate(true); | 818 | anEvent->setHasDueDate(true); |
809 | } else { | 819 | } else { |
810 | anEvent->setHasDueDate(false); | 820 | anEvent->setHasDueDate(false); |
811 | } | 821 | } |
812 | 822 | ||
813 | // start time | 823 | // start time |
814 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { | 824 | if ((vo = isAPropertyOf(vtodo, VCDTstartProp)) != 0) { |
815 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 825 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
816 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 826 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
817 | deleteStr(s); | 827 | deleteStr(s); |
818 | anEvent->setHasStartDate(true); | 828 | anEvent->setHasStartDate(true); |
819 | } else { | 829 | } else { |
820 | anEvent->setHasStartDate(false); | 830 | anEvent->setHasStartDate(false); |
821 | } | 831 | } |
822 | 832 | ||
823 | /* alarm stuff */ | 833 | /* alarm stuff */ |
824 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; | 834 | //kdDebug(5800) << "vcalformat::VTodoToEvent called" << endl; |
825 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { | 835 | if ((vo = isAPropertyOf(vtodo, VCDAlarmProp))) { |
826 | Alarm* alarm = anEvent->newAlarm(); | 836 | Alarm* alarm = anEvent->newAlarm(); |
827 | VObject *a; | 837 | VObject *a; |
828 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 838 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
829 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 839 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
830 | deleteStr(s); | 840 | deleteStr(s); |
831 | } | 841 | } |
832 | alarm->setEnabled(true); | 842 | alarm->setEnabled(true); |
833 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { | 843 | if ((vo = isAPropertyOf(vtodo, VCPAlarmProp))) { |
834 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 844 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
835 | s = fakeCString(vObjectUStringZValue(a)); | 845 | s = fakeCString(vObjectUStringZValue(a)); |
836 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 846 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
837 | deleteStr(s); | 847 | deleteStr(s); |
838 | } | 848 | } |
839 | } | 849 | } |
840 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { | 850 | if ((vo = isAPropertyOf(vtodo, VCAAlarmProp))) { |
841 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 851 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
842 | s = fakeCString(vObjectUStringZValue(a)); | 852 | s = fakeCString(vObjectUStringZValue(a)); |
843 | alarm->setAudioAlarm(QFile::decodeName(s)); | 853 | alarm->setAudioAlarm(QFile::decodeName(s)); |
844 | deleteStr(s); | 854 | deleteStr(s); |
845 | } | 855 | } |
846 | } | 856 | } |
847 | } | 857 | } |
848 | 858 | ||
849 | // related todo | 859 | // related todo |
850 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { | 860 | if ((vo = isAPropertyOf(vtodo, VCRelatedToProp)) != 0) { |
851 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 861 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
852 | deleteStr(s); | 862 | deleteStr(s); |
853 | mTodosRelate.append(anEvent); | 863 | mTodosRelate.append(anEvent); |
854 | } | 864 | } |
855 | 865 | ||
856 | // categories | 866 | // categories |
857 | QStringList tmpStrList; | 867 | QStringList tmpStrList; |
858 | int index1 = 0; | 868 | int index1 = 0; |
859 | int index2 = 0; | 869 | int index2 = 0; |
860 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { | 870 | if ((vo = isAPropertyOf(vtodo, VCCategoriesProp)) != 0) { |
861 | s = fakeCString(vObjectUStringZValue(vo)); | 871 | s = fakeCString(vObjectUStringZValue(vo)); |
862 | QString categories = QString::fromLocal8Bit(s); | 872 | QString categories = QString::fromLocal8Bit(s); |
863 | deleteStr(s); | 873 | deleteStr(s); |
864 | //const char* category; | 874 | //const char* category; |
865 | QString category; | 875 | QString category; |
866 | while ((index2 = categories.find(',', index1)) != -1) { | 876 | while ((index2 = categories.find(',', index1)) != -1) { |
867 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 877 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
868 | category = categories.mid(index1, (index2 - index1)); | 878 | category = categories.mid(index1, (index2 - index1)); |
869 | tmpStrList.append(category); | 879 | tmpStrList.append(category); |
870 | index1 = index2+1; | 880 | index1 = index2+1; |
871 | } | 881 | } |
872 | // get last category | 882 | // get last category |
873 | category = categories.mid(index1, (categories.length()-index1)); | 883 | category = categories.mid(index1, (categories.length()-index1)); |
874 | tmpStrList.append(category); | 884 | tmpStrList.append(category); |
875 | anEvent->setCategories(tmpStrList); | 885 | anEvent->setCategories(tmpStrList); |
876 | } | 886 | } |
877 | 887 | ||
878 | /* PILOT SYNC STUFF */ | 888 | /* PILOT SYNC STUFF */ |
879 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { | 889 | if ((vo = isAPropertyOf(vtodo, XPilotIdProp))) { |
880 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 890 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
881 | deleteStr(s); | 891 | deleteStr(s); |
882 | } | 892 | } |
883 | else | 893 | else |
884 | anEvent->setPilotId(0); | 894 | anEvent->setPilotId(0); |
885 | 895 | ||
886 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { | 896 | if ((vo = isAPropertyOf(vtodo, XPilotStatusProp))) { |
887 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 897 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
888 | deleteStr(s); | 898 | deleteStr(s); |
889 | } | 899 | } |
890 | else | 900 | else |
891 | anEvent->setSyncStatus(Event::SYNCMOD); | 901 | anEvent->setSyncStatus(Event::SYNCMOD); |
892 | 902 | ||
893 | return anEvent; | 903 | return anEvent; |
894 | } | 904 | } |
895 | 905 | ||
896 | Event* VCalFormat::VEventToEvent(VObject *vevent) | 906 | Event* VCalFormat::VEventToEvent(VObject *vevent) |
897 | { | 907 | { |
898 | VObject *vo; | 908 | VObject *vo; |
899 | VObjectIterator voi; | 909 | VObjectIterator voi; |
900 | char *s; | 910 | char *s; |
901 | 911 | ||
902 | Event *anEvent = new Event; | 912 | Event *anEvent = new Event; |
903 | 913 | ||
904 | // creation date | 914 | // creation date |
905 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { | 915 | if ((vo = isAPropertyOf(vevent, VCDCreatedProp)) != 0) { |
906 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 916 | anEvent->setCreated(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
907 | deleteStr(s); | 917 | deleteStr(s); |
908 | } | 918 | } |
909 | 919 | ||
910 | // unique id | 920 | // unique id |
911 | vo = isAPropertyOf(vevent, VCUniqueStringProp); | 921 | vo = isAPropertyOf(vevent, VCUniqueStringProp); |
912 | // while the UID property is preferred, it is not required. We'll use the | 922 | // while the UID property is preferred, it is not required. We'll use the |
913 | // default Event UID if none is given. | 923 | // default Event UID if none is given. |
914 | if (vo) { | 924 | if (vo) { |
915 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); | 925 | anEvent->setUid(s = fakeCString(vObjectUStringZValue(vo))); |
916 | deleteStr(s); | 926 | deleteStr(s); |
917 | } | 927 | } |
918 | 928 | ||
919 | // revision | 929 | // revision |
920 | // again NSCAL doesn't give us much to work with, so we improvise... | 930 | // again NSCAL doesn't give us much to work with, so we improvise... |
921 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { | 931 | if ((vo = isAPropertyOf(vevent, VCSequenceProp)) != 0) { |
922 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 932 | anEvent->setRevision(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
923 | deleteStr(s); | 933 | deleteStr(s); |
924 | } | 934 | } |
925 | else | 935 | else |
926 | anEvent->setRevision(0); | 936 | anEvent->setRevision(0); |
927 | 937 | ||
928 | // last modification date | 938 | // last modification date |
929 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { | 939 | if ((vo = isAPropertyOf(vevent, VCLastModifiedProp)) != 0) { |
930 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 940 | anEvent->setLastModified(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
931 | deleteStr(s); | 941 | deleteStr(s); |
932 | } | 942 | } |
933 | else | 943 | else |
934 | anEvent->setLastModified(QDateTime(QDate::currentDate(), | 944 | anEvent->setLastModified(QDateTime(QDate::currentDate(), |
935 | QTime::currentTime())); | 945 | QTime::currentTime())); |
936 | 946 | ||
937 | // organizer | 947 | // organizer |
938 | // if our extension property for the event's ORGANIZER exists, add it. | 948 | // if our extension property for the event's ORGANIZER exists, add it. |
939 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { | 949 | if ((vo = isAPropertyOf(vevent, ICOrganizerProp)) != 0) { |
940 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); | 950 | anEvent->setOrganizer(s = fakeCString(vObjectUStringZValue(vo))); |
941 | deleteStr(s); | 951 | deleteStr(s); |
942 | } else { | 952 | } else { |
943 | anEvent->setOrganizer(mCalendar->getEmail()); | 953 | anEvent->setOrganizer(mCalendar->getEmail()); |
944 | } | 954 | } |
945 | 955 | ||
946 | // deal with attendees. | 956 | // deal with attendees. |
947 | initPropIterator(&voi, vevent); | 957 | initPropIterator(&voi, vevent); |
948 | while (moreIteration(&voi)) { | 958 | while (moreIteration(&voi)) { |
949 | vo = nextVObject(&voi); | 959 | vo = nextVObject(&voi); |
950 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { | 960 | if (strcmp(vObjectName(vo), VCAttendeeProp) == 0) { |
951 | Attendee *a; | 961 | Attendee *a; |
952 | VObject *vp; | 962 | VObject *vp; |
953 | s = fakeCString(vObjectUStringZValue(vo)); | 963 | s = fakeCString(vObjectUStringZValue(vo)); |
954 | QString tmpStr = QString::fromLocal8Bit(s); | 964 | QString tmpStr = QString::fromLocal8Bit(s); |
955 | deleteStr(s); | 965 | deleteStr(s); |
956 | tmpStr = tmpStr.simplifyWhiteSpace(); | 966 | tmpStr = tmpStr.simplifyWhiteSpace(); |
957 | int emailPos1, emailPos2; | 967 | int emailPos1, emailPos2; |
958 | if ((emailPos1 = tmpStr.find('<')) > 0) { | 968 | if ((emailPos1 = tmpStr.find('<')) > 0) { |
959 | // both email address and name | 969 | // both email address and name |
960 | emailPos2 = tmpStr.findRev('>'); | 970 | emailPos2 = tmpStr.findRev('>'); |
961 | a = new Attendee(tmpStr.left(emailPos1 - 1), | 971 | a = new Attendee(tmpStr.left(emailPos1 - 1), |
962 | tmpStr.mid(emailPos1 + 1, | 972 | tmpStr.mid(emailPos1 + 1, |
963 | emailPos2 - (emailPos1 + 1))); | 973 | emailPos2 - (emailPos1 + 1))); |
964 | } else if (tmpStr.find('@') > 0) { | 974 | } else if (tmpStr.find('@') > 0) { |
965 | // just an email address | 975 | // just an email address |
966 | a = new Attendee(0, tmpStr); | 976 | a = new Attendee(0, tmpStr); |
967 | } else { | 977 | } else { |
968 | // just a name | 978 | // just a name |
969 | QString email = tmpStr.replace( QRegExp(" "), "." ); | 979 | QString email = tmpStr.replace( QRegExp(" "), "." ); |
970 | a = new Attendee(tmpStr,email); | 980 | a = new Attendee(tmpStr,email); |
971 | } | 981 | } |
972 | 982 | ||
973 | // is there an RSVP property? | 983 | // is there an RSVP property? |
974 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) | 984 | if ((vp = isAPropertyOf(vo, VCRSVPProp)) != 0) |
975 | a->setRSVP(vObjectStringZValue(vp)); | 985 | a->setRSVP(vObjectStringZValue(vp)); |
976 | // is there a status property? | 986 | // is there a status property? |
977 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) | 987 | if ((vp = isAPropertyOf(vo, VCStatusProp)) != 0) |
978 | a->setStatus(readStatus(vObjectStringZValue(vp))); | 988 | a->setStatus(readStatus(vObjectStringZValue(vp))); |
979 | // add the attendee | 989 | // add the attendee |
980 | anEvent->addAttendee(a); | 990 | anEvent->addAttendee(a); |
981 | } | 991 | } |
982 | } | 992 | } |
983 | 993 | ||
984 | // This isn't strictly true. An event that doesn't have a start time | 994 | // This isn't strictly true. An event that doesn't have a start time |
985 | // or an end time doesn't "float", it has an anchor in time but it doesn't | 995 | // or an end time doesn't "float", it has an anchor in time but it doesn't |
986 | // "take up" any time. | 996 | // "take up" any time. |
987 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || | 997 | /*if ((isAPropertyOf(vevent, VCDTstartProp) == 0) || |
988 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { | 998 | (isAPropertyOf(vevent, VCDTendProp) == 0)) { |
989 | anEvent->setFloats(TRUE); | 999 | anEvent->setFloats(TRUE); |
990 | } else { | 1000 | } else { |
991 | }*/ | 1001 | }*/ |
992 | 1002 | ||
993 | anEvent->setFloats(FALSE); | 1003 | anEvent->setFloats(FALSE); |
994 | 1004 | ||
995 | // start time | 1005 | // start time |
996 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { | 1006 | if ((vo = isAPropertyOf(vevent, VCDTstartProp)) != 0) { |
997 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1007 | anEvent->setDtStart(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
998 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; | 1008 | // kdDebug(5800) << "s is " << // s << ", ISO is " << ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo))).toString() << endl; |
999 | deleteStr(s); | 1009 | deleteStr(s); |
1000 | if (anEvent->dtStart().time().isNull()) | 1010 | if (anEvent->dtStart().time().isNull()) |
1001 | anEvent->setFloats(TRUE); | 1011 | anEvent->setFloats(TRUE); |
1002 | } | 1012 | } |
1003 | 1013 | ||
1004 | // stop time | 1014 | // stop time |
1005 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { | 1015 | if ((vo = isAPropertyOf(vevent, VCDTendProp)) != 0) { |
1006 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); | 1016 | anEvent->setDtEnd(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(vo)))); |
1007 | deleteStr(s); | 1017 | deleteStr(s); |
1008 | if (anEvent->dtEnd().time().isNull()) | 1018 | if (anEvent->dtEnd().time().isNull()) |
1009 | anEvent->setFloats(TRUE); | 1019 | anEvent->setFloats(TRUE); |
1010 | } | 1020 | } |
1011 | 1021 | ||
1012 | // at this point, there should be at least a start or end time. | 1022 | // at this point, there should be at least a start or end time. |
1013 | // fix up for events that take up no time but have a time associated | 1023 | // fix up for events that take up no time but have a time associated |
1014 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) | 1024 | if (!(vo = isAPropertyOf(vevent, VCDTstartProp))) |
1015 | anEvent->setDtStart(anEvent->dtEnd()); | 1025 | anEvent->setDtStart(anEvent->dtEnd()); |
1016 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) | 1026 | if (!(vo = isAPropertyOf(vevent, VCDTendProp))) |
1017 | anEvent->setDtEnd(anEvent->dtStart()); | 1027 | anEvent->setDtEnd(anEvent->dtStart()); |
1018 | 1028 | ||
1019 | /////////////////////////////////////////////////////////////////////////// | 1029 | /////////////////////////////////////////////////////////////////////////// |
1020 | 1030 | ||
1021 | // repeat stuff | 1031 | // repeat stuff |
1022 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { | 1032 | if ((vo = isAPropertyOf(vevent, VCRRuleProp)) != 0) { |
1023 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); | 1033 | QString tmpStr = (s = fakeCString(vObjectUStringZValue(vo))); |
1024 | deleteStr(s); | 1034 | deleteStr(s); |
1025 | tmpStr.simplifyWhiteSpace(); | 1035 | tmpStr.simplifyWhiteSpace(); |
1026 | tmpStr = tmpStr.upper(); | 1036 | tmpStr = tmpStr.upper(); |
1027 | 1037 | ||
1028 | /********************************* DAILY ******************************/ | 1038 | /********************************* DAILY ******************************/ |
1029 | if (tmpStr.left(1) == "D") { | 1039 | if (tmpStr.left(1) == "D") { |
1030 | int index = tmpStr.find(' '); | 1040 | int index = tmpStr.find(' '); |
1031 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1041 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1032 | index = tmpStr.findRev(' ') + 1; // advance to last field | 1042 | index = tmpStr.findRev(' ') + 1; // advance to last field |
1033 | if (tmpStr.mid(index,1) == "#") index++; | 1043 | if (tmpStr.mid(index,1) == "#") index++; |
1034 | if (tmpStr.find('T', index) != -1) { | 1044 | if (tmpStr.find('T', index) != -1) { |
1035 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1045 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1036 | anEvent->recurrence()->setDaily(rFreq, rEndDate); | 1046 | anEvent->recurrence()->setDaily(rFreq, rEndDate); |
1037 | } else { | 1047 | } else { |
1038 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1048 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1039 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 | 1049 | if (rDuration == 0) // VEvents set this to 0 forever, we use -1 |
1040 | anEvent->recurrence()->setDaily(rFreq, -1); | 1050 | anEvent->recurrence()->setDaily(rFreq, -1); |
1041 | else | 1051 | else |
1042 | anEvent->recurrence()->setDaily(rFreq, rDuration); | 1052 | anEvent->recurrence()->setDaily(rFreq, rDuration); |
1043 | } | 1053 | } |
1044 | } | 1054 | } |
1045 | /********************************* WEEKLY ******************************/ | 1055 | /********************************* WEEKLY ******************************/ |
1046 | else if (tmpStr.left(1) == "W") { | 1056 | else if (tmpStr.left(1) == "W") { |
1047 | int index = tmpStr.find(' '); | 1057 | int index = tmpStr.find(' '); |
1048 | int last = tmpStr.findRev(' ') + 1; | 1058 | int last = tmpStr.findRev(' ') + 1; |
1049 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); | 1059 | int rFreq = tmpStr.mid(1, (index-1)).toInt(); |
1050 | index += 1; // advance to beginning of stuff after freq | 1060 | index += 1; // advance to beginning of stuff after freq |
1051 | QBitArray qba(7); | 1061 | QBitArray qba(7); |
1052 | QString dayStr; | 1062 | QString dayStr; |
1053 | if( index == last ) { | 1063 | if( index == last ) { |
1054 | // e.g. W1 #0 | 1064 | // e.g. W1 #0 |
1055 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1065 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1056 | } | 1066 | } |
1057 | else { | 1067 | else { |
1058 | // e.g. W1 SU #0 | 1068 | // e.g. W1 SU #0 |
1059 | while (index < last) { | 1069 | while (index < last) { |
1060 | dayStr = tmpStr.mid(index, 3); | 1070 | dayStr = tmpStr.mid(index, 3); |
1061 | int dayNum = numFromDay(dayStr); | 1071 | int dayNum = numFromDay(dayStr); |
1062 | qba.setBit(dayNum); | 1072 | qba.setBit(dayNum); |
1063 | index += 3; // advance to next day, or possibly "#" | 1073 | index += 3; // advance to next day, or possibly "#" |
1064 | } | 1074 | } |
1065 | } | 1075 | } |
1066 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1076 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1067 | if (tmpStr.find('T', index) != -1) { | 1077 | if (tmpStr.find('T', index) != -1) { |
1068 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1078 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1069 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); | 1079 | anEvent->recurrence()->setWeekly(rFreq, qba, rEndDate); |
1070 | } else { | 1080 | } else { |
1071 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1081 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1072 | if (rDuration == 0) | 1082 | if (rDuration == 0) |
1073 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); | 1083 | anEvent->recurrence()->setWeekly(rFreq, qba, -1); |
1074 | else | 1084 | else |
1075 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); | 1085 | anEvent->recurrence()->setWeekly(rFreq, qba, rDuration); |
1076 | } | 1086 | } |
1077 | } | 1087 | } |
1078 | /**************************** MONTHLY-BY-POS ***************************/ | 1088 | /**************************** MONTHLY-BY-POS ***************************/ |
1079 | else if (tmpStr.left(2) == "MP") { | 1089 | else if (tmpStr.left(2) == "MP") { |
1080 | int index = tmpStr.find(' '); | 1090 | int index = tmpStr.find(' '); |
1081 | int last = tmpStr.findRev(' ') + 1; | 1091 | int last = tmpStr.findRev(' ') + 1; |
1082 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1092 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1083 | index += 1; // advance to beginning of stuff after freq | 1093 | index += 1; // advance to beginning of stuff after freq |
1084 | QBitArray qba(7); | 1094 | QBitArray qba(7); |
1085 | short tmpPos; | 1095 | short tmpPos; |
1086 | if( index == last ) { | 1096 | if( index == last ) { |
1087 | // e.g. MP1 #0 | 1097 | // e.g. MP1 #0 |
1088 | tmpPos = anEvent->dtStart().date().day()/7 + 1; | 1098 | tmpPos = anEvent->dtStart().date().day()/7 + 1; |
1089 | if( tmpPos == 5 ) | 1099 | if( tmpPos == 5 ) |
1090 | tmpPos = -1; | 1100 | tmpPos = -1; |
1091 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); | 1101 | qba.setBit(anEvent->dtStart().date().dayOfWeek() - 1); |
1092 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1102 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1093 | } | 1103 | } |
1094 | else { | 1104 | else { |
1095 | // e.g. MP1 1+ SU #0 | 1105 | // e.g. MP1 1+ SU #0 |
1096 | while (index < last) { | 1106 | while (index < last) { |
1097 | tmpPos = tmpStr.mid(index,1).toShort(); | 1107 | tmpPos = tmpStr.mid(index,1).toShort(); |
1098 | index += 1; | 1108 | index += 1; |
1099 | if (tmpStr.mid(index,1) == "-") | 1109 | if (tmpStr.mid(index,1) == "-") |
1100 | // convert tmpPos to negative | 1110 | // convert tmpPos to negative |
1101 | tmpPos = 0 - tmpPos; | 1111 | tmpPos = 0 - tmpPos; |
1102 | index += 2; // advance to day(s) | 1112 | index += 2; // advance to day(s) |
1103 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { | 1113 | while (numFromDay(tmpStr.mid(index,3)) >= 0) { |
1104 | int dayNum = numFromDay(tmpStr.mid(index,3)); | 1114 | int dayNum = numFromDay(tmpStr.mid(index,3)); |
1105 | qba.setBit(dayNum); | 1115 | qba.setBit(dayNum); |
1106 | index += 3; // advance to next day, or possibly pos or "#" | 1116 | index += 3; // advance to next day, or possibly pos or "#" |
1107 | } | 1117 | } |
1108 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); | 1118 | anEvent->recurrence()->addMonthlyPos(tmpPos, qba); |
1109 | qba.detach(); | 1119 | qba.detach(); |
1110 | qba.fill(FALSE); // clear out | 1120 | qba.fill(FALSE); // clear out |
1111 | } // while != "#" | 1121 | } // while != "#" |
1112 | } | 1122 | } |
1113 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1123 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1114 | if (tmpStr.find('T', index) != -1) { | 1124 | if (tmpStr.find('T', index) != -1) { |
1115 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - | 1125 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length() - |
1116 | index))).date(); | 1126 | index))).date(); |
1117 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); | 1127 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rEndDate); |
1118 | } else { | 1128 | } else { |
1119 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1129 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1120 | if (rDuration == 0) | 1130 | if (rDuration == 0) |
1121 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); | 1131 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, -1); |
1122 | else | 1132 | else |
1123 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); | 1133 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyPos, rFreq, rDuration); |
1124 | } | 1134 | } |
1125 | } | 1135 | } |
1126 | 1136 | ||
1127 | /**************************** MONTHLY-BY-DAY ***************************/ | 1137 | /**************************** MONTHLY-BY-DAY ***************************/ |
1128 | else if (tmpStr.left(2) == "MD") { | 1138 | else if (tmpStr.left(2) == "MD") { |
1129 | int index = tmpStr.find(' '); | 1139 | int index = tmpStr.find(' '); |
1130 | int last = tmpStr.findRev(' ') + 1; | 1140 | int last = tmpStr.findRev(' ') + 1; |
1131 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1141 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1132 | index += 1; | 1142 | index += 1; |
1133 | short tmpDay; | 1143 | short tmpDay; |
1134 | if( index == last ) { | 1144 | if( index == last ) { |
1135 | // e.g. MD1 #0 | 1145 | // e.g. MD1 #0 |
1136 | tmpDay = anEvent->dtStart().date().day(); | 1146 | tmpDay = anEvent->dtStart().date().day(); |
1137 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1147 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1138 | } | 1148 | } |
1139 | else { | 1149 | else { |
1140 | // e.g. MD1 3 #0 | 1150 | // e.g. MD1 3 #0 |
1141 | while (index < last) { | 1151 | while (index < last) { |
1142 | int index2 = tmpStr.find(' ', index); | 1152 | int index2 = tmpStr.find(' ', index); |
1143 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1153 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1144 | index = index2-1; | 1154 | index = index2-1; |
1145 | if (tmpStr.mid(index, 1) == "-") | 1155 | if (tmpStr.mid(index, 1) == "-") |
1146 | tmpDay = 0 - tmpDay; | 1156 | tmpDay = 0 - tmpDay; |
1147 | index += 2; // advance the index; | 1157 | index += 2; // advance the index; |
1148 | anEvent->recurrence()->addMonthlyDay(tmpDay); | 1158 | anEvent->recurrence()->addMonthlyDay(tmpDay); |
1149 | } // while != # | 1159 | } // while != # |
1150 | } | 1160 | } |
1151 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1161 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1152 | if (tmpStr.find('T', index) != -1) { | 1162 | if (tmpStr.find('T', index) != -1) { |
1153 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1163 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1154 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); | 1164 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rEndDate); |
1155 | } else { | 1165 | } else { |
1156 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1166 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1157 | if (rDuration == 0) | 1167 | if (rDuration == 0) |
1158 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); | 1168 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, -1); |
1159 | else | 1169 | else |
1160 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); | 1170 | anEvent->recurrence()->setMonthly(Recurrence::rMonthlyDay, rFreq, rDuration); |
1161 | } | 1171 | } |
1162 | } | 1172 | } |
1163 | 1173 | ||
1164 | /*********************** YEARLY-BY-MONTH *******************************/ | 1174 | /*********************** YEARLY-BY-MONTH *******************************/ |
1165 | else if (tmpStr.left(2) == "YM") { | 1175 | else if (tmpStr.left(2) == "YM") { |
1166 | int index = tmpStr.find(' '); | 1176 | int index = tmpStr.find(' '); |
1167 | int last = tmpStr.findRev(' ') + 1; | 1177 | int last = tmpStr.findRev(' ') + 1; |
1168 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1178 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1169 | index += 1; | 1179 | index += 1; |
1170 | short tmpMonth; | 1180 | short tmpMonth; |
1171 | if( index == last ) { | 1181 | if( index == last ) { |
1172 | // e.g. YM1 #0 | 1182 | // e.g. YM1 #0 |
1173 | tmpMonth = anEvent->dtStart().date().month(); | 1183 | tmpMonth = anEvent->dtStart().date().month(); |
1174 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1184 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1175 | } | 1185 | } |
1176 | else { | 1186 | else { |
1177 | // e.g. YM1 3 #0 | 1187 | // e.g. YM1 3 #0 |
1178 | while (index < last) { | 1188 | while (index < last) { |
1179 | int index2 = tmpStr.find(' ', index); | 1189 | int index2 = tmpStr.find(' ', index); |
1180 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); | 1190 | tmpMonth = tmpStr.mid(index, (index2-index)).toShort(); |
1181 | index = index2+1; | 1191 | index = index2+1; |
1182 | anEvent->recurrence()->addYearlyNum(tmpMonth); | 1192 | anEvent->recurrence()->addYearlyNum(tmpMonth); |
1183 | } // while != # | 1193 | } // while != # |
1184 | } | 1194 | } |
1185 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1195 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1186 | if (tmpStr.find('T', index) != -1) { | 1196 | if (tmpStr.find('T', index) != -1) { |
1187 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1197 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1188 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); | 1198 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rEndDate); |
1189 | } else { | 1199 | } else { |
1190 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1200 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1191 | if (rDuration == 0) | 1201 | if (rDuration == 0) |
1192 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); | 1202 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, -1); |
1193 | else | 1203 | else |
1194 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); | 1204 | anEvent->recurrence()->setYearly(Recurrence::rYearlyMonth, rFreq, rDuration); |
1195 | } | 1205 | } |
1196 | } | 1206 | } |
1197 | 1207 | ||
1198 | /*********************** YEARLY-BY-DAY *********************************/ | 1208 | /*********************** YEARLY-BY-DAY *********************************/ |
1199 | else if (tmpStr.left(2) == "YD") { | 1209 | else if (tmpStr.left(2) == "YD") { |
1200 | int index = tmpStr.find(' '); | 1210 | int index = tmpStr.find(' '); |
1201 | int last = tmpStr.findRev(' ') + 1; | 1211 | int last = tmpStr.findRev(' ') + 1; |
1202 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); | 1212 | int rFreq = tmpStr.mid(2, (index-1)).toInt(); |
1203 | index += 1; | 1213 | index += 1; |
1204 | short tmpDay; | 1214 | short tmpDay; |
1205 | if( index == last ) { | 1215 | if( index == last ) { |
1206 | // e.g. YD1 #0 | 1216 | // e.g. YD1 #0 |
1207 | tmpDay = anEvent->dtStart().date().dayOfYear(); | 1217 | tmpDay = anEvent->dtStart().date().dayOfYear(); |
1208 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1218 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1209 | } | 1219 | } |
1210 | else { | 1220 | else { |
1211 | // e.g. YD1 123 #0 | 1221 | // e.g. YD1 123 #0 |
1212 | while (index < last) { | 1222 | while (index < last) { |
1213 | int index2 = tmpStr.find(' ', index); | 1223 | int index2 = tmpStr.find(' ', index); |
1214 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); | 1224 | tmpDay = tmpStr.mid(index, (index2-index)).toShort(); |
1215 | index = index2+1; | 1225 | index = index2+1; |
1216 | anEvent->recurrence()->addYearlyNum(tmpDay); | 1226 | anEvent->recurrence()->addYearlyNum(tmpDay); |
1217 | } // while != # | 1227 | } // while != # |
1218 | } | 1228 | } |
1219 | index = last; if (tmpStr.mid(index,1) == "#") index++; | 1229 | index = last; if (tmpStr.mid(index,1) == "#") index++; |
1220 | if (tmpStr.find('T', index) != -1) { | 1230 | if (tmpStr.find('T', index) != -1) { |
1221 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); | 1231 | QDate rEndDate = (ISOToQDateTime(tmpStr.mid(index, tmpStr.length()-index))).date(); |
1222 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); | 1232 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rEndDate); |
1223 | } else { | 1233 | } else { |
1224 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); | 1234 | int rDuration = tmpStr.mid(index, tmpStr.length()-index).toInt(); |
1225 | if (rDuration == 0) | 1235 | if (rDuration == 0) |
1226 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); | 1236 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, -1); |
1227 | else | 1237 | else |
1228 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); | 1238 | anEvent->recurrence()->setYearly(Recurrence::rYearlyDay, rFreq, rDuration); |
1229 | } | 1239 | } |
1230 | } else { | 1240 | } else { |
1231 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; | 1241 | kdDebug(5800) << "we don't understand this type of recurrence!" << endl; |
1232 | } // if | 1242 | } // if |
1233 | } // repeats | 1243 | } // repeats |
1234 | 1244 | ||
1235 | 1245 | ||
1236 | // recurrence exceptions | 1246 | // recurrence exceptions |
1237 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { | 1247 | if ((vo = isAPropertyOf(vevent, VCExpDateProp)) != 0) { |
1238 | s = fakeCString(vObjectUStringZValue(vo)); | 1248 | s = fakeCString(vObjectUStringZValue(vo)); |
1239 | QStringList exDates = QStringList::split(",",s); | 1249 | QStringList exDates = QStringList::split(",",s); |
1240 | QStringList::ConstIterator it; | 1250 | QStringList::ConstIterator it; |
1241 | for(it = exDates.begin(); it != exDates.end(); ++it ) { | 1251 | for(it = exDates.begin(); it != exDates.end(); ++it ) { |
1242 | anEvent->addExDate(ISOToQDate(*it)); | 1252 | anEvent->addExDate(ISOToQDate(*it)); |
1243 | } | 1253 | } |
1244 | deleteStr(s); | 1254 | deleteStr(s); |
1245 | } | 1255 | } |
1246 | 1256 | ||
1247 | // summary | 1257 | // summary |
1248 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { | 1258 | if ((vo = isAPropertyOf(vevent, VCSummaryProp))) { |
1249 | s = fakeCString(vObjectUStringZValue(vo)); | 1259 | s = fakeCString(vObjectUStringZValue(vo)); |
1250 | anEvent->setSummary(QString::fromLocal8Bit(s)); | 1260 | anEvent->setSummary(QString::fromLocal8Bit(s)); |
1251 | deleteStr(s); | 1261 | deleteStr(s); |
1252 | } | 1262 | } |
1253 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { | 1263 | if ((vo = isAPropertyOf(vevent, VCLocationProp))) { |
1254 | s = fakeCString(vObjectUStringZValue(vo)); | 1264 | s = fakeCString(vObjectUStringZValue(vo)); |
1255 | anEvent->setLocation(QString::fromLocal8Bit(s)); | 1265 | anEvent->setLocation(QString::fromLocal8Bit(s)); |
1256 | deleteStr(s); | 1266 | deleteStr(s); |
1257 | } | 1267 | } |
1258 | 1268 | ||
1259 | // description | 1269 | // description |
1260 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { | 1270 | if ((vo = isAPropertyOf(vevent, VCDescriptionProp)) != 0) { |
1261 | s = fakeCString(vObjectUStringZValue(vo)); | 1271 | s = fakeCString(vObjectUStringZValue(vo)); |
1262 | if (!anEvent->description().isEmpty()) { | 1272 | if (!anEvent->description().isEmpty()) { |
1263 | anEvent->setDescription(anEvent->description() + "\n" + | 1273 | anEvent->setDescription(anEvent->description() + "\n" + |
1264 | QString::fromLocal8Bit(s)); | 1274 | QString::fromLocal8Bit(s)); |
1265 | } else { | 1275 | } else { |
1266 | anEvent->setDescription(QString::fromLocal8Bit(s)); | 1276 | anEvent->setDescription(QString::fromLocal8Bit(s)); |
1267 | } | 1277 | } |
1268 | deleteStr(s); | 1278 | deleteStr(s); |
1269 | } | 1279 | } |
1270 | 1280 | ||
1271 | // some stupid vCal exporters ignore the standard and use Description | 1281 | // some stupid vCal exporters ignore the standard and use Description |
1272 | // instead of Summary for the default field. Correct for this. | 1282 | // instead of Summary for the default field. Correct for this. |
1273 | if (anEvent->summary().isEmpty() && | 1283 | if (anEvent->summary().isEmpty() && |
1274 | !(anEvent->description().isEmpty())) { | 1284 | !(anEvent->description().isEmpty())) { |
1275 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); | 1285 | QString tmpStr = anEvent->description().simplifyWhiteSpace(); |
1276 | anEvent->setDescription(""); | 1286 | anEvent->setDescription(""); |
1277 | anEvent->setSummary(tmpStr); | 1287 | anEvent->setSummary(tmpStr); |
1278 | } | 1288 | } |
1279 | 1289 | ||
1280 | #if 0 | 1290 | #if 0 |
1281 | // status | 1291 | // status |
1282 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { | 1292 | if ((vo = isAPropertyOf(vevent, VCStatusProp)) != 0) { |
1283 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); | 1293 | QString tmpStr(s = fakeCString(vObjectUStringZValue(vo))); |
1284 | deleteStr(s); | 1294 | deleteStr(s); |
1285 | // TODO: Define Event status | 1295 | // TODO: Define Event status |
1286 | // anEvent->setStatus(tmpStr); | 1296 | // anEvent->setStatus(tmpStr); |
1287 | } | 1297 | } |
1288 | else | 1298 | else |
1289 | // anEvent->setStatus("NEEDS ACTION"); | 1299 | // anEvent->setStatus("NEEDS ACTION"); |
1290 | #endif | 1300 | #endif |
1291 | 1301 | ||
1292 | // secrecy | 1302 | // secrecy |
1293 | int secrecy = Incidence::SecrecyPublic; | 1303 | int secrecy = Incidence::SecrecyPublic; |
1294 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { | 1304 | if ((vo = isAPropertyOf(vevent, VCClassProp)) != 0) { |
1295 | s = fakeCString(vObjectUStringZValue(vo)); | 1305 | s = fakeCString(vObjectUStringZValue(vo)); |
1296 | if (strcmp(s,"PRIVATE") == 0) { | 1306 | if (strcmp(s,"PRIVATE") == 0) { |
1297 | secrecy = Incidence::SecrecyPrivate; | 1307 | secrecy = Incidence::SecrecyPrivate; |
1298 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { | 1308 | } else if (strcmp(s,"CONFIDENTIAL") == 0) { |
1299 | secrecy = Incidence::SecrecyConfidential; | 1309 | secrecy = Incidence::SecrecyConfidential; |
1300 | } | 1310 | } |
1301 | deleteStr(s); | 1311 | deleteStr(s); |
1302 | } | 1312 | } |
1303 | anEvent->setSecrecy(secrecy); | 1313 | anEvent->setSecrecy(secrecy); |
1304 | 1314 | ||
1305 | // categories | 1315 | // categories |
1306 | QStringList tmpStrList; | 1316 | QStringList tmpStrList; |
1307 | int index1 = 0; | 1317 | int index1 = 0; |
1308 | int index2 = 0; | 1318 | int index2 = 0; |
1309 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { | 1319 | if ((vo = isAPropertyOf(vevent, VCCategoriesProp)) != 0) { |
1310 | s = fakeCString(vObjectUStringZValue(vo)); | 1320 | s = fakeCString(vObjectUStringZValue(vo)); |
1311 | QString categories = QString::fromLocal8Bit(s); | 1321 | QString categories = QString::fromLocal8Bit(s); |
1312 | deleteStr(s); | 1322 | deleteStr(s); |
1313 | //const char* category; | 1323 | //const char* category; |
1314 | QString category; | 1324 | QString category; |
1315 | while ((index2 = categories.find(',', index1)) != -1) { | 1325 | while ((index2 = categories.find(',', index1)) != -1) { |
1316 | //category = (const char *) categories.mid(index1, (index2 - index1)); | 1326 | //category = (const char *) categories.mid(index1, (index2 - index1)); |
1317 | category = categories.mid(index1, (index2 - index1)); | 1327 | category = categories.mid(index1, (index2 - index1)); |
1318 | tmpStrList.append(category); | 1328 | tmpStrList.append(category); |
1319 | index1 = index2+1; | 1329 | index1 = index2+1; |
1320 | } | 1330 | } |
1321 | // get last category | 1331 | // get last category |
1322 | category = categories.mid(index1, (categories.length()-index1)); | 1332 | category = categories.mid(index1, (categories.length()-index1)); |
1323 | tmpStrList.append(category); | 1333 | tmpStrList.append(category); |
1324 | anEvent->setCategories(tmpStrList); | 1334 | anEvent->setCategories(tmpStrList); |
1325 | } | 1335 | } |
1326 | 1336 | ||
1327 | // attachments | 1337 | // attachments |
1328 | tmpStrList.clear(); | 1338 | tmpStrList.clear(); |
1329 | initPropIterator(&voi, vevent); | 1339 | initPropIterator(&voi, vevent); |
1330 | while (moreIteration(&voi)) { | 1340 | while (moreIteration(&voi)) { |
1331 | vo = nextVObject(&voi); | 1341 | vo = nextVObject(&voi); |
1332 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { | 1342 | if (strcmp(vObjectName(vo), VCAttachProp) == 0) { |
1333 | s = fakeCString(vObjectUStringZValue(vo)); | 1343 | s = fakeCString(vObjectUStringZValue(vo)); |
1334 | anEvent->addAttachment(new Attachment(QString(s))); | 1344 | anEvent->addAttachment(new Attachment(QString(s))); |
1335 | deleteStr(s); | 1345 | deleteStr(s); |
1336 | } | 1346 | } |
1337 | } | 1347 | } |
1338 | 1348 | ||
1339 | // resources | 1349 | // resources |
1340 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { | 1350 | if ((vo = isAPropertyOf(vevent, VCResourcesProp)) != 0) { |
1341 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); | 1351 | QString resources = (s = fakeCString(vObjectUStringZValue(vo))); |
1342 | deleteStr(s); | 1352 | deleteStr(s); |
1343 | tmpStrList.clear(); | 1353 | tmpStrList.clear(); |
1344 | index1 = 0; | 1354 | index1 = 0; |
1345 | index2 = 0; | 1355 | index2 = 0; |
1346 | QString resource; | 1356 | QString resource; |
1347 | while ((index2 = resources.find(';', index1)) != -1) { | 1357 | while ((index2 = resources.find(';', index1)) != -1) { |
1348 | resource = resources.mid(index1, (index2 - index1)); | 1358 | resource = resources.mid(index1, (index2 - index1)); |
1349 | tmpStrList.append(resource); | 1359 | tmpStrList.append(resource); |
1350 | index1 = index2; | 1360 | index1 = index2; |
1351 | } | 1361 | } |
1352 | anEvent->setResources(tmpStrList); | 1362 | anEvent->setResources(tmpStrList); |
1353 | } | 1363 | } |
1354 | 1364 | ||
1355 | /* alarm stuff */ | 1365 | /* alarm stuff */ |
1356 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { | 1366 | if ((vo = isAPropertyOf(vevent, VCDAlarmProp))) { |
1357 | Alarm* alarm = anEvent->newAlarm(); | 1367 | Alarm* alarm = anEvent->newAlarm(); |
1358 | VObject *a; | 1368 | VObject *a; |
1359 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { | 1369 | if ((a = isAPropertyOf(vo, VCRunTimeProp))) { |
1360 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); | 1370 | alarm->setTime(ISOToQDateTime(s = fakeCString(vObjectUStringZValue(a)))); |
1361 | deleteStr(s); | 1371 | deleteStr(s); |
1362 | } | 1372 | } |
1363 | alarm->setEnabled(true); | 1373 | alarm->setEnabled(true); |
1364 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { | 1374 | if ((vo = isAPropertyOf(vevent, VCPAlarmProp))) { |
1365 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { | 1375 | if ((a = isAPropertyOf(vo, VCProcedureNameProp))) { |
1366 | s = fakeCString(vObjectUStringZValue(a)); | 1376 | s = fakeCString(vObjectUStringZValue(a)); |
1367 | alarm->setProcedureAlarm(QFile::decodeName(s)); | 1377 | alarm->setProcedureAlarm(QFile::decodeName(s)); |
1368 | deleteStr(s); | 1378 | deleteStr(s); |
1369 | } | 1379 | } |
1370 | } | 1380 | } |
1371 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { | 1381 | if ((vo = isAPropertyOf(vevent, VCAAlarmProp))) { |
1372 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { | 1382 | if ((a = isAPropertyOf(vo, VCAudioContentProp))) { |
1373 | s = fakeCString(vObjectUStringZValue(a)); | 1383 | s = fakeCString(vObjectUStringZValue(a)); |
1374 | alarm->setAudioAlarm(QFile::decodeName(s)); | 1384 | alarm->setAudioAlarm(QFile::decodeName(s)); |
1375 | deleteStr(s); | 1385 | deleteStr(s); |
1376 | } | 1386 | } |
1377 | } | 1387 | } |
1378 | } | 1388 | } |
1379 | 1389 | ||
1380 | // priority | 1390 | // priority |
1381 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { | 1391 | if ((vo = isAPropertyOf(vevent, VCPriorityProp))) { |
1382 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1392 | anEvent->setPriority(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1383 | deleteStr(s); | 1393 | deleteStr(s); |
1384 | } | 1394 | } |
1385 | 1395 | ||
1386 | // transparency | 1396 | // transparency |
1387 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { | 1397 | if ((vo = isAPropertyOf(vevent, VCTranspProp)) != 0) { |
1388 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); | 1398 | int i = atoi(s = fakeCString(vObjectUStringZValue(vo))); |
1389 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); | 1399 | anEvent->setTransparency( i == 1 ? Event::Transparent : Event::Opaque ); |
1390 | deleteStr(s); | 1400 | deleteStr(s); |
1391 | } | 1401 | } |
1392 | 1402 | ||
1393 | // related event | 1403 | // related event |
1394 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { | 1404 | if ((vo = isAPropertyOf(vevent, VCRelatedToProp)) != 0) { |
1395 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); | 1405 | anEvent->setRelatedToUid(s = fakeCString(vObjectUStringZValue(vo))); |
1396 | deleteStr(s); | 1406 | deleteStr(s); |
1397 | mEventsRelate.append(anEvent); | 1407 | mEventsRelate.append(anEvent); |
1398 | } | 1408 | } |
1399 | 1409 | ||
1400 | /* PILOT SYNC STUFF */ | 1410 | /* PILOT SYNC STUFF */ |
1401 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { | 1411 | if ((vo = isAPropertyOf(vevent, XPilotIdProp))) { |
1402 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1412 | anEvent->setPilotId(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1403 | deleteStr(s); | 1413 | deleteStr(s); |
1404 | } | 1414 | } |
1405 | else | 1415 | else |
1406 | anEvent->setPilotId(0); | 1416 | anEvent->setPilotId(0); |
1407 | 1417 | ||
1408 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { | 1418 | if ((vo = isAPropertyOf(vevent, XPilotStatusProp))) { |
1409 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); | 1419 | anEvent->setSyncStatus(atoi(s = fakeCString(vObjectUStringZValue(vo)))); |
1410 | deleteStr(s); | 1420 | deleteStr(s); |
1411 | } | 1421 | } |
1412 | else | 1422 | else |
1413 | anEvent->setSyncStatus(Event::SYNCMOD); | 1423 | anEvent->setSyncStatus(Event::SYNCMOD); |
1414 | 1424 | ||
1415 | return anEvent; | 1425 | return anEvent; |
1416 | } | 1426 | } |
1417 | 1427 | ||
1418 | 1428 | ||
1419 | QString VCalFormat::qDateToISO(const QDate &qd) | 1429 | QString VCalFormat::qDateToISO(const QDate &qd) |
1420 | { | 1430 | { |
1421 | QString tmpStr; | 1431 | QString tmpStr; |
1422 | 1432 | ||
1423 | ASSERT(qd.isValid()); | 1433 | ASSERT(qd.isValid()); |
1424 | 1434 | ||
1425 | tmpStr.sprintf("%.2d%.2d%.2d", | 1435 | tmpStr.sprintf("%.2d%.2d%.2d", |
1426 | qd.year(), qd.month(), qd.day()); | 1436 | qd.year(), qd.month(), qd.day()); |
1427 | return tmpStr; | 1437 | return tmpStr; |
1428 | 1438 | ||
1429 | } | 1439 | } |
1430 | 1440 | ||
1431 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) | 1441 | QString VCalFormat::qDateTimeToISO(const QDateTime &qdt, bool zulu) |
1432 | { | 1442 | { |
1433 | QString tmpStr; | 1443 | QString tmpStr; |
1434 | 1444 | ||
1435 | ASSERT(qdt.date().isValid()); | 1445 | ASSERT(qdt.date().isValid()); |
1436 | ASSERT(qdt.time().isValid()); | 1446 | ASSERT(qdt.time().isValid()); |
1437 | if (zulu) { | 1447 | if (zulu && !useLocalTime ) { |
1438 | QDateTime tmpDT(qdt); | 1448 | QDateTime tmpDT = qdt.addSecs ( -KGlobal::locale()->localTimeOffset( qdt )*60); |
1439 | tmpDT = tmpDT.addSecs(60*(-mCalendar->getTimeZone())); // correct to GMT. | ||
1440 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", | 1449 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2dZ", |
1441 | tmpDT.date().year(), tmpDT.date().month(), | 1450 | tmpDT.date().year(), tmpDT.date().month(), |
1442 | tmpDT.date().day(), tmpDT.time().hour(), | 1451 | tmpDT.date().day(), tmpDT.time().hour(), |
1443 | tmpDT.time().minute(), tmpDT.time().second()); | 1452 | tmpDT.time().minute(), tmpDT.time().second()); |
1444 | } else { | 1453 | } else { |
1445 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", | 1454 | tmpStr.sprintf("%.2d%.2d%.2dT%.2d%.2d%.2d", |
1446 | qdt.date().year(), qdt.date().month(), | 1455 | qdt.date().year(), qdt.date().month(), |
1447 | qdt.date().day(), qdt.time().hour(), | 1456 | qdt.date().day(), qdt.time().hour(), |
1448 | qdt.time().minute(), qdt.time().second()); | 1457 | qdt.time().minute(), qdt.time().second()); |
1449 | } | 1458 | } |
1450 | return tmpStr; | 1459 | return tmpStr; |
1451 | } | 1460 | } |
1452 | 1461 | ||
1453 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) | 1462 | QDateTime VCalFormat::ISOToQDateTime(const QString & dtStr) |
1454 | { | 1463 | { |
1455 | QDate tmpDate; | 1464 | QDate tmpDate; |
1456 | QTime tmpTime; | 1465 | QTime tmpTime; |
1457 | QString tmpStr; | 1466 | QString tmpStr; |
1458 | int year, month, day, hour, minute, second; | 1467 | int year, month, day, hour, minute, second; |
1459 | 1468 | ||
1460 | tmpStr = dtStr; | 1469 | tmpStr = dtStr; |
1461 | year = tmpStr.left(4).toInt(); | 1470 | year = tmpStr.left(4).toInt(); |
1462 | month = tmpStr.mid(4,2).toInt(); | 1471 | month = tmpStr.mid(4,2).toInt(); |
1463 | day = tmpStr.mid(6,2).toInt(); | 1472 | day = tmpStr.mid(6,2).toInt(); |
1464 | hour = tmpStr.mid(9,2).toInt(); | 1473 | hour = tmpStr.mid(9,2).toInt(); |
1465 | minute = tmpStr.mid(11,2).toInt(); | 1474 | minute = tmpStr.mid(11,2).toInt(); |
1466 | second = tmpStr.mid(13,2).toInt(); | 1475 | second = tmpStr.mid(13,2).toInt(); |
1467 | tmpDate.setYMD(year, month, day); | 1476 | tmpDate.setYMD(year, month, day); |
1468 | tmpTime.setHMS(hour, minute, second); | 1477 | tmpTime.setHMS(hour, minute, second); |
1469 | 1478 | ||
1470 | ASSERT(tmpDate.isValid()); | 1479 | ASSERT(tmpDate.isValid()); |
1471 | ASSERT(tmpTime.isValid()); | 1480 | ASSERT(tmpTime.isValid()); |
1472 | QDateTime tmpDT(tmpDate, tmpTime); | 1481 | QDateTime tmpDT(tmpDate, tmpTime); |
1473 | // correct for GMT if string is in Zulu format | 1482 | // correct for GMT if string is in Zulu format |
1474 | if (dtStr.at(dtStr.length()-1) == 'Z') | 1483 | if (dtStr.at(dtStr.length()-1) == 'Z') |
1475 | tmpDT = tmpDT.addSecs(60*mCalendar->getTimeZone()); | 1484 | tmpDT = tmpDT.addSecs(60*mCalendar->getTimeZone()); |
1476 | return tmpDT; | 1485 | return tmpDT; |
1477 | } | 1486 | } |
1478 | 1487 | ||
1479 | QDate VCalFormat::ISOToQDate(const QString &dateStr) | 1488 | QDate VCalFormat::ISOToQDate(const QString &dateStr) |
1480 | { | 1489 | { |
1481 | int year, month, day; | 1490 | int year, month, day; |
1482 | 1491 | ||
1483 | year = dateStr.left(4).toInt(); | 1492 | year = dateStr.left(4).toInt(); |
1484 | month = dateStr.mid(4,2).toInt(); | 1493 | month = dateStr.mid(4,2).toInt(); |
1485 | day = dateStr.mid(6,2).toInt(); | 1494 | day = dateStr.mid(6,2).toInt(); |
1486 | 1495 | ||
1487 | return(QDate(year, month, day)); | 1496 | return(QDate(year, month, day)); |
1488 | } | 1497 | } |
1489 | 1498 | ||
1490 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. | 1499 | // take a raw vcalendar (i.e. from a file on disk, clipboard, etc. etc. |
1491 | // and break it down from it's tree-like format into the dictionary format | 1500 | // and break it down from it's tree-like format into the dictionary format |
1492 | // that is used internally in the VCalFormat. | 1501 | // that is used internally in the VCalFormat. |
1493 | void VCalFormat::populate(VObject *vcal) | 1502 | void VCalFormat::populate(VObject *vcal) |
1494 | { | 1503 | { |
1495 | // this function will populate the caldict dictionary and other event | 1504 | // this function will populate the caldict dictionary and other event |
1496 | // lists. It turns vevents into Events and then inserts them. | 1505 | // lists. It turns vevents into Events and then inserts them. |
1497 | 1506 | ||
1498 | VObjectIterator i; | 1507 | VObjectIterator i; |
1499 | VObject *curVO, *curVOProp; | 1508 | VObject *curVO, *curVOProp; |
1500 | Event *anEvent; | 1509 | Event *anEvent; |
1501 | 1510 | ||
1502 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { | 1511 | if ((curVO = isAPropertyOf(vcal, ICMethodProp)) != 0) { |
1503 | char *methodType = 0; | 1512 | char *methodType = 0; |
1504 | methodType = fakeCString(vObjectUStringZValue(curVO)); | 1513 | methodType = fakeCString(vObjectUStringZValue(curVO)); |
1505 | kdDebug() << "This calendar is an iTIP transaction of type '" | 1514 | kdDebug() << "This calendar is an iTIP transaction of type '" |
1506 | << methodType << "'" << endl; | 1515 | << methodType << "'" << endl; |
1507 | delete methodType; | 1516 | delete methodType; |
1508 | } | 1517 | } |
1509 | 1518 | ||
1510 | // warn the user that we might have trouble reading non-known calendar. | 1519 | // warn the user that we might have trouble reading non-known calendar. |
1511 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { | 1520 | if ((curVO = isAPropertyOf(vcal, VCProdIdProp)) != 0) { |
1512 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1521 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1513 | if (strcmp(productId().local8Bit(), s) != 0) | 1522 | if (strcmp(productId().local8Bit(), s) != 0) |
1514 | kdDebug() << "This vCalendar file was not created by KOrganizer " | 1523 | kdDebug() << "This vCalendar file was not created by KOrganizer " |
1515 | "or any other product we support. Loading anyway..." << endl; | 1524 | "or any other product we support. Loading anyway..." << endl; |
1516 | mLoadedProductId = s; | 1525 | mLoadedProductId = s; |
1517 | deleteStr(s); | 1526 | deleteStr(s); |
1518 | } | 1527 | } |
1519 | 1528 | ||
1520 | // warn the user we might have trouble reading this unknown version. | 1529 | // warn the user we might have trouble reading this unknown version. |
1521 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { | 1530 | if ((curVO = isAPropertyOf(vcal, VCVersionProp)) != 0) { |
1522 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1531 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1523 | if (strcmp(_VCAL_VERSION, s) != 0) | 1532 | if (strcmp(_VCAL_VERSION, s) != 0) |
1524 | kdDebug() << "This vCalendar file has version " << s | 1533 | kdDebug() << "This vCalendar file has version " << s |
1525 | << "We only support " << _VCAL_VERSION << endl; | 1534 | << "We only support " << _VCAL_VERSION << endl; |
1526 | deleteStr(s); | 1535 | deleteStr(s); |
1527 | } | 1536 | } |
1528 | 1537 | ||
1529 | // set the time zone | 1538 | // set the time zone |
1530 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { | 1539 | if ((curVO = isAPropertyOf(vcal, VCTimeZoneProp)) != 0) { |
1531 | char *s = fakeCString(vObjectUStringZValue(curVO)); | 1540 | char *s = fakeCString(vObjectUStringZValue(curVO)); |
1532 | mCalendar->setTimeZone(s); | 1541 | mCalendar->setTimeZone(s); |
1533 | deleteStr(s); | 1542 | deleteStr(s); |
1534 | } | 1543 | } |
1535 | 1544 | ||
1536 | 1545 | ||
1537 | // Store all events with a relatedTo property in a list for post-processing | 1546 | // Store all events with a relatedTo property in a list for post-processing |
1538 | mEventsRelate.clear(); | 1547 | mEventsRelate.clear(); |
1539 | mTodosRelate.clear(); | 1548 | mTodosRelate.clear(); |
1540 | 1549 | ||
1541 | initPropIterator(&i, vcal); | 1550 | initPropIterator(&i, vcal); |
1542 | 1551 | ||
1543 | // go through all the vobjects in the vcal | 1552 | // go through all the vobjects in the vcal |
1544 | while (moreIteration(&i)) { | 1553 | while (moreIteration(&i)) { |
1545 | curVO = nextVObject(&i); | 1554 | curVO = nextVObject(&i); |
1546 | 1555 | ||
1547 | /************************************************************************/ | 1556 | /************************************************************************/ |
1548 | 1557 | ||
1549 | // now, check to see that the object is an event or todo. | 1558 | // now, check to see that the object is an event or todo. |
1550 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { | 1559 | if (strcmp(vObjectName(curVO), VCEventProp) == 0) { |
1551 | 1560 | ||
1552 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { | 1561 | if ((curVOProp = isAPropertyOf(curVO, XPilotStatusProp)) != 0) { |
1553 | char *s; | 1562 | char *s; |
1554 | s = fakeCString(vObjectUStringZValue(curVOProp)); | 1563 | s = fakeCString(vObjectUStringZValue(curVOProp)); |
1555 | // check to see if event was deleted by the kpilot conduit | 1564 | // check to see if event was deleted by the kpilot conduit |
1556 | if (atoi(s) == Event::SYNCDEL) { | 1565 | if (atoi(s) == Event::SYNCDEL) { |
1557 | deleteStr(s); | 1566 | deleteStr(s); |
1558 | kdDebug(5800) << "skipping pilot-deleted event" << endl; | 1567 | kdDebug(5800) << "skipping pilot-deleted event" << endl; |
1559 | goto SKIP; | 1568 | goto SKIP; |
1560 | } | 1569 | } |
1561 | deleteStr(s); | 1570 | deleteStr(s); |
1562 | } | 1571 | } |
1563 | 1572 | ||
1564 | // this code checks to see if we are trying to read in an event | 1573 | // this code checks to see if we are trying to read in an event |
1565 | // that we already find to be in the calendar. If we find this | 1574 | // that we already find to be in the calendar. If we find this |
1566 | // to be the case, we skip the event. | 1575 | // to be the case, we skip the event. |
1567 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { | 1576 | if ((curVOProp = isAPropertyOf(curVO, VCUniqueStringProp)) != 0) { |
1568 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); | 1577 | char *s = fakeCString(vObjectUStringZValue(curVOProp)); |
1569 | QString tmpStr(s); | 1578 | QString tmpStr(s); |
1570 | deleteStr(s); | 1579 | deleteStr(s); |
1571 | 1580 | ||
1572 | if (mCalendar->event(tmpStr)) { | 1581 | if (mCalendar->event(tmpStr)) { |
1573 | goto SKIP; | 1582 | goto SKIP; |
1574 | } | 1583 | } |
1575 | if (mCalendar->todo(tmpStr)) { | 1584 | if (mCalendar->todo(tmpStr)) { |
1576 | goto SKIP; | 1585 | goto SKIP; |
1577 | } | 1586 | } |
1578 | } | 1587 | } |
1579 | 1588 | ||
1580 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && | 1589 | if ((!(curVOProp = isAPropertyOf(curVO, VCDTstartProp))) && |
1581 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { | 1590 | (!(curVOProp = isAPropertyOf(curVO, VCDTendProp)))) { |
1582 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; | 1591 | kdDebug(5800) << "found a VEvent with no DTSTART and no DTEND! Skipping..." << endl; |
1583 | goto SKIP; | 1592 | goto SKIP; |
1584 | } | 1593 | } |
1585 | 1594 | ||
1586 | anEvent = VEventToEvent(curVO); | 1595 | anEvent = VEventToEvent(curVO); |
1587 | // we now use addEvent instead of insertEvent so that the | 1596 | // we now use addEvent instead of insertEvent so that the |
1588 | // signal/slot get connected. | 1597 | // signal/slot get connected. |
1589 | if (anEvent) { | 1598 | if (anEvent) { |
1590 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { | 1599 | if ( !anEvent->dtStart().isValid() || !anEvent->dtEnd().isValid() ) { |
1591 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." | 1600 | kdDebug() << "VCalFormat::populate(): Event has invalid dates." |
1592 | << endl; | 1601 | << endl; |
1593 | } else { | 1602 | } else { |
1594 | mCalendar->addEvent(anEvent); | 1603 | mCalendar->addEvent(anEvent); |
1595 | } | 1604 | } |
1596 | } else { | 1605 | } else { |
1597 | // some sort of error must have occurred while in translation. | 1606 | // some sort of error must have occurred while in translation. |
1598 | goto SKIP; | 1607 | goto SKIP; |
1599 | } | 1608 | } |
1600 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { | 1609 | } else if (strcmp(vObjectName(curVO), VCTodoProp) == 0) { |
1601 | Todo *aTodo = VTodoToEvent(curVO); | 1610 | Todo *aTodo = VTodoToEvent(curVO); |
1602 | mCalendar->addTodo(aTodo); | 1611 | mCalendar->addTodo(aTodo); |
1603 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || | 1612 | } else if ((strcmp(vObjectName(curVO), VCVersionProp) == 0) || |
1604 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || | 1613 | (strcmp(vObjectName(curVO), VCProdIdProp) == 0) || |
1605 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { | 1614 | (strcmp(vObjectName(curVO), VCTimeZoneProp) == 0)) { |
1606 | // do nothing, we know these properties and we want to skip them. | 1615 | // do nothing, we know these properties and we want to skip them. |
1607 | // we have either already processed them or are ignoring them. | 1616 | // we have either already processed them or are ignoring them. |
1608 | ; | 1617 | ; |
1609 | } else { | 1618 | } else { |
1610 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; | 1619 | kdDebug(5800) << "Ignoring unknown vObject \"" << vObjectName(curVO) << "\"" << endl; |
1611 | } | 1620 | } |
1612 | SKIP: | 1621 | SKIP: |
1613 | ; | 1622 | ; |
1614 | } // while | 1623 | } // while |
1615 | 1624 | ||
1616 | // Post-Process list of events with relations, put Event objects in relation | 1625 | // Post-Process list of events with relations, put Event objects in relation |
1617 | Event *ev; | 1626 | Event *ev; |
1618 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { | 1627 | for ( ev=mEventsRelate.first(); ev != 0; ev=mEventsRelate.next() ) { |
1619 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); | 1628 | ev->setRelatedTo(mCalendar->event(ev->relatedToUid())); |
1620 | } | 1629 | } |
1621 | Todo *todo; | 1630 | Todo *todo; |
1622 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { | 1631 | for ( todo=mTodosRelate.first(); todo != 0; todo=mTodosRelate.next() ) { |
1623 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); | 1632 | todo->setRelatedTo(mCalendar->todo(todo->relatedToUid())); |
1624 | } | 1633 | } |
1625 | } | 1634 | } |
1626 | 1635 | ||
1627 | const char *VCalFormat::dayFromNum(int day) | 1636 | const char *VCalFormat::dayFromNum(int day) |
1628 | { | 1637 | { |
1629 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; | 1638 | const char *days[7] = { "MO ", "TU ", "WE ", "TH ", "FR ", "SA ", "SU " }; |
1630 | 1639 | ||
1631 | return days[day]; | 1640 | return days[day]; |
1632 | } | 1641 | } |
1633 | 1642 | ||
1634 | int VCalFormat::numFromDay(const QString &day) | 1643 | int VCalFormat::numFromDay(const QString &day) |
1635 | { | 1644 | { |
1636 | if (day == "MO ") return 0; | 1645 | if (day == "MO ") return 0; |
1637 | if (day == "TU ") return 1; | 1646 | if (day == "TU ") return 1; |
1638 | if (day == "WE ") return 2; | 1647 | if (day == "WE ") return 2; |
1639 | if (day == "TH ") return 3; | 1648 | if (day == "TH ") return 3; |
1640 | if (day == "FR ") return 4; | 1649 | if (day == "FR ") return 4; |
1641 | if (day == "SA ") return 5; | 1650 | if (day == "SA ") return 5; |
1642 | if (day == "SU ") return 6; | 1651 | if (day == "SU ") return 6; |
1643 | 1652 | ||
1644 | return -1; // something bad happened. :) | 1653 | return -1; // something bad happened. :) |
1645 | } | 1654 | } |
1646 | 1655 | ||
1647 | Attendee::PartStat VCalFormat::readStatus(const char *s) const | 1656 | Attendee::PartStat VCalFormat::readStatus(const char *s) const |
1648 | { | 1657 | { |
1649 | QString statStr = s; | 1658 | QString statStr = s; |
1650 | statStr = statStr.upper(); | 1659 | statStr = statStr.upper(); |
1651 | Attendee::PartStat status; | 1660 | Attendee::PartStat status; |
1652 | 1661 | ||
1653 | if (statStr == "X-ACTION") | 1662 | if (statStr == "X-ACTION") |
1654 | status = Attendee::NeedsAction; | 1663 | status = Attendee::NeedsAction; |
1655 | else if (statStr == "NEEDS ACTION") | 1664 | else if (statStr == "NEEDS ACTION") |
1656 | status = Attendee::NeedsAction; | 1665 | status = Attendee::NeedsAction; |
1657 | else if (statStr== "ACCEPTED") | 1666 | else if (statStr== "ACCEPTED") |
1658 | status = Attendee::Accepted; | 1667 | status = Attendee::Accepted; |
1659 | else if (statStr== "SENT") | 1668 | else if (statStr== "SENT") |
1660 | status = Attendee::NeedsAction; | 1669 | status = Attendee::NeedsAction; |
1661 | else if (statStr== "TENTATIVE") | 1670 | else if (statStr== "TENTATIVE") |
1662 | status = Attendee::Tentative; | 1671 | status = Attendee::Tentative; |
1663 | else if (statStr== "CONFIRMED") | 1672 | else if (statStr== "CONFIRMED") |
1664 | status = Attendee::Accepted; | 1673 | status = Attendee::Accepted; |
1665 | else if (statStr== "DECLINED") | 1674 | else if (statStr== "DECLINED") |
1666 | status = Attendee::Declined; | 1675 | status = Attendee::Declined; |
1667 | else if (statStr== "COMPLETED") | 1676 | else if (statStr== "COMPLETED") |
1668 | status = Attendee::Completed; | 1677 | status = Attendee::Completed; |
1669 | else if (statStr== "DELEGATED") | 1678 | else if (statStr== "DELEGATED") |
1670 | status = Attendee::Delegated; | 1679 | status = Attendee::Delegated; |
1671 | else { | 1680 | else { |
1672 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; | 1681 | kdDebug(5800) << "error setting attendee mStatus, unknown mStatus!" << endl; |
1673 | status = Attendee::NeedsAction; | 1682 | status = Attendee::NeedsAction; |
1674 | } | 1683 | } |
1675 | 1684 | ||
1676 | return status; | 1685 | return status; |
1677 | } | 1686 | } |
1678 | 1687 | ||
1679 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const | 1688 | QCString VCalFormat::writeStatus(Attendee::PartStat status) const |
1680 | { | 1689 | { |
1681 | switch(status) { | 1690 | switch(status) { |
1682 | default: | 1691 | default: |
1683 | case Attendee::NeedsAction: | 1692 | case Attendee::NeedsAction: |
1684 | return "NEEDS ACTION"; | 1693 | return "NEEDS ACTION"; |
1685 | break; | 1694 | break; |
1686 | case Attendee::Accepted: | 1695 | case Attendee::Accepted: |
1687 | return "ACCEPTED"; | 1696 | return "ACCEPTED"; |
1688 | break; | 1697 | break; |
1689 | case Attendee::Declined: | 1698 | case Attendee::Declined: |
1690 | return "DECLINED"; | 1699 | return "DECLINED"; |
1691 | break; | 1700 | break; |
1692 | case Attendee::Tentative: | 1701 | case Attendee::Tentative: |
1693 | return "TENTATIVE"; | 1702 | return "TENTATIVE"; |
1694 | break; | 1703 | break; |
1695 | case Attendee::Delegated: | 1704 | case Attendee::Delegated: |
1696 | return "DELEGATED"; | 1705 | return "DELEGATED"; |
1697 | break; | 1706 | break; |
1698 | case Attendee::Completed: | 1707 | case Attendee::Completed: |
1699 | return "COMPLETED"; | 1708 | return "COMPLETED"; |
1700 | break; | 1709 | break; |
1701 | case Attendee::InProcess: | 1710 | case Attendee::InProcess: |
1702 | return "NEEDS ACTION"; | 1711 | return "NEEDS ACTION"; |
1703 | break; | 1712 | break; |
1704 | } | 1713 | } |
1705 | } | 1714 | } |
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h index 7b9ca26..848be78 100644 --- a/libkcal/vcalformat.h +++ b/libkcal/vcalformat.h | |||
@@ -1,110 +1,111 @@ | |||
1 | /* | 1 | /* |
2 | This file is part of libkcal. | 2 | This file is part of libkcal. |
3 | Copyright (c) 1998 Preston Brown | 3 | Copyright (c) 1998 Preston Brown |
4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> | 4 | Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> |
5 | 5 | ||
6 | This library is free software; you can redistribute it and/or | 6 | This library is free software; you can redistribute it and/or |
7 | modify it under the terms of the GNU Library General Public | 7 | modify it under the terms of the GNU Library General Public |
8 | License as published by the Free Software Foundation; either | 8 | License as published by the Free Software Foundation; either |
9 | version 2 of the License, or (at your option) any later version. | 9 | version 2 of the License, or (at your option) any later version. |
10 | 10 | ||
11 | This library is distributed in the hope that it will be useful, | 11 | This library is distributed in the hope that it will be useful, |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
14 | Library General Public License for more details. | 14 | Library General Public License for more details. |
15 | 15 | ||
16 | You should have received a copy of the GNU Library General Public License | 16 | You should have received a copy of the GNU Library General Public License |
17 | along with this library; see the file COPYING.LIB. If not, write to | 17 | along with this library; see the file COPYING.LIB. If not, write to |
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, | 18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
19 | Boston, MA 02111-1307, USA. | 19 | Boston, MA 02111-1307, USA. |
20 | */ | 20 | */ |
21 | 21 | ||
22 | #ifndef _VCALFORMAT_H | 22 | #ifndef _VCALFORMAT_H |
23 | #define _VCALFORMAT_H | 23 | #define _VCALFORMAT_H |
24 | 24 | ||
25 | #include "calformat.h" | 25 | #include "calformat.h" |
26 | 26 | ||
27 | #define _VCAL_VERSION "1.0" | 27 | #define _VCAL_VERSION "1.0" |
28 | 28 | ||
29 | class VObject; | 29 | class VObject; |
30 | 30 | ||
31 | namespace KCal { | 31 | namespace KCal { |
32 | 32 | ||
33 | /** | 33 | /** |
34 | This class implements the vCalendar format. It provides methods for | 34 | This class implements the vCalendar format. It provides methods for |
35 | loading/saving/converting vCalendar format data into the internal KOrganizer | 35 | loading/saving/converting vCalendar format data into the internal KOrganizer |
36 | representation as Calendar and Events. | 36 | representation as Calendar and Events. |
37 | 37 | ||
38 | @short vCalendar format implementation | 38 | @short vCalendar format implementation |
39 | */ | 39 | */ |
40 | class VCalFormat : public CalFormat { | 40 | class VCalFormat : public CalFormat { |
41 | public: | 41 | public: |
42 | VCalFormat(); | 42 | VCalFormat(); |
43 | virtual ~VCalFormat(); | 43 | virtual ~VCalFormat(); |
44 | 44 | ||
45 | /** loads a calendar on disk in vCalendar format into the current calendar. | 45 | /** loads a calendar on disk in vCalendar format into the current calendar. |
46 | * any information already present is lost. Returns TRUE if successful, | 46 | * any information already present is lost. Returns TRUE if successful, |
47 | * else returns FALSE. | 47 | * else returns FALSE. |
48 | * @param fileName the name of the calendar on disk. | 48 | * @param fileName the name of the calendar on disk. |
49 | */ | 49 | */ |
50 | bool load(Calendar *,const QString &fileName); | 50 | bool load(Calendar *,const QString &fileName); |
51 | /** writes out the calendar to disk in vCalendar format. Returns true if | 51 | /** writes out the calendar to disk in vCalendar format. Returns true if |
52 | * successful and false on error. | 52 | * successful and false on error. |
53 | * @param fileName the name of the file | 53 | * @param fileName the name of the file |
54 | */ | 54 | */ |
55 | bool save(Calendar *,const QString &fileName); | 55 | bool save(Calendar *,const QString &fileName); |
56 | 56 | ||
57 | /** | 57 | /** |
58 | Parse string and populate calendar with that information. | 58 | Parse string and populate calendar with that information. |
59 | */ | 59 | */ |
60 | bool fromString( Calendar *, const QString & ); | 60 | bool fromString( Calendar *, const QString & ); |
61 | /** | 61 | /** |
62 | Return calendar information as string. | 62 | Return calendar information as string. |
63 | */ | 63 | */ |
64 | QString toString( Calendar * ); | 64 | QString toString( Calendar * ); |
65 | QString eventToString( Event *, Calendar *calendar ); | 65 | QString eventToString( Event *, Calendar *calendar, bool useLocalTime = true ); |
66 | QString todoToString( Todo * ,Calendar *calendar ); | 66 | QString todoToString( Todo * ,Calendar *calendar, bool useLocalTime = true ); |
67 | 67 | ||
68 | protected: | 68 | protected: |
69 | /** translates a VObject of the TODO type into a Event */ | 69 | /** translates a VObject of the TODO type into a Event */ |
70 | Todo *VTodoToEvent(VObject *vtodo); | 70 | Todo *VTodoToEvent(VObject *vtodo); |
71 | /** translates a VObject into a Event and returns a pointer to it. */ | 71 | /** translates a VObject into a Event and returns a pointer to it. */ |
72 | Event *VEventToEvent(VObject *vevent); | 72 | Event *VEventToEvent(VObject *vevent); |
73 | /** translate a Event into a VTodo-type VObject and return pointer */ | 73 | /** translate a Event into a VTodo-type VObject and return pointer */ |
74 | VObject *eventToVTodo(const Todo *anEvent); | 74 | VObject *eventToVTodo(const Todo *anEvent); |
75 | /** translate a Event into a VObject and returns a pointer to it. */ | 75 | /** translate a Event into a VObject and returns a pointer to it. */ |
76 | VObject* eventToVEvent(const Event *anEvent); | 76 | VObject* eventToVEvent(const Event *anEvent); |
77 | 77 | ||
78 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ | 78 | /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ |
79 | QString qDateToISO(const QDate &); | 79 | QString qDateToISO(const QDate &); |
80 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ | 80 | /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ |
81 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); | 81 | QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); |
82 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a | 82 | /** takes a string in the format YYYYMMDDTHHMMSS and returns a |
83 | * valid QDateTime. */ | 83 | * valid QDateTime. */ |
84 | QDateTime ISOToQDateTime(const QString & dtStr); | 84 | QDateTime ISOToQDateTime(const QString & dtStr); |
85 | /** takes a string in the format YYYYMMDD and returns a | 85 | /** takes a string in the format YYYYMMDD and returns a |
86 | * valid QDate. */ | 86 | * valid QDate. */ |
87 | QDate ISOToQDate(const QString & dtStr); | 87 | QDate ISOToQDate(const QString & dtStr); |
88 | /** takes a vCalendar tree of VObjects, and puts all of them that have | 88 | /** takes a vCalendar tree of VObjects, and puts all of them that have |
89 | * the "event" property into the dictionary, todos in the todo-list, etc. */ | 89 | * the "event" property into the dictionary, todos in the todo-list, etc. */ |
90 | void populate(VObject *vcal); | 90 | void populate(VObject *vcal); |
91 | 91 | ||
92 | /** takes a number 0 - 6 and returns the two letter string of that day, | 92 | /** takes a number 0 - 6 and returns the two letter string of that day, |
93 | * i.e. MO, TU, WE, etc. */ | 93 | * i.e. MO, TU, WE, etc. */ |
94 | const char *dayFromNum(int day); | 94 | const char *dayFromNum(int day); |
95 | /** the reverse of the above function. */ | 95 | /** the reverse of the above function. */ |
96 | int numFromDay(const QString &day); | 96 | int numFromDay(const QString &day); |
97 | 97 | ||
98 | Attendee::PartStat readStatus(const char *s) const; | 98 | Attendee::PartStat readStatus(const char *s) const; |
99 | QCString writeStatus(Attendee::PartStat status) const; | 99 | QCString writeStatus(Attendee::PartStat status) const; |
100 | 100 | ||
101 | private: | 101 | private: |
102 | Calendar *mCalendar; | 102 | Calendar *mCalendar; |
103 | bool useLocalTime; | ||
103 | 104 | ||
104 | QPtrList<Event> mEventsRelate; // events with relations | 105 | QPtrList<Event> mEventsRelate; // events with relations |
105 | QPtrList<Todo> mTodosRelate; // todos with relations | 106 | QPtrList<Todo> mTodosRelate; // todos with relations |
106 | }; | 107 | }; |
107 | 108 | ||
108 | } | 109 | } |
109 | 110 | ||
110 | #endif | 111 | #endif |