author | zautrix <zautrix> | 2004-08-09 16:25:52 (UTC) |
---|---|---|
committer | zautrix <zautrix> | 2004-08-09 16:25:52 (UTC) |
commit | ecdcad49975976ff877ff506fae3b14934c01898 (patch) (unidiff) | |
tree | 55d79a2b7d90c4c7ce097063449946f2b2504d6a /libkcal | |
parent | ad99dd380750834b3ccc4dd6fdcdd446ca5ba7ee (diff) | |
download | kdepimpi-ecdcad49975976ff877ff506fae3b14934c01898.zip kdepimpi-ecdcad49975976ff877ff506fae3b14934c01898.tar.gz kdepimpi-ecdcad49975976ff877ff506fae3b14934c01898.tar.bz2 |
more phone sync
-rw-r--r-- | libkcal/phoneformat.cpp | 194 | ||||
-rw-r--r-- | libkcal/phoneformat.h | 4 |
2 files changed, 165 insertions, 33 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp index b8fed47..e43a507 100644 --- a/libkcal/phoneformat.cpp +++ b/libkcal/phoneformat.cpp | |||
@@ -1,324 +1,312 @@ | |||
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 = 1; break; | 69 | case GSM_Priority_Low : priority = 1; break; |
70 | case GSM_Priority_Medium : priority = 3; break; | 70 | case GSM_Priority_Medium : priority = 3; break; |
71 | case GSM_Priority_High : priority = 5; break; | 71 | case GSM_Priority_High : priority = 5; 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 | QString completedString = "no"; | ||
84 | for (j=0;j<ToDo->EntriesNum;j++) { | 83 | for (j=0;j<ToDo->EntriesNum;j++) { |
85 | 84 | ||
86 | //qDebug(" for todo %d",ToDo->Location ); | 85 | //qDebug(" for todo %d",ToDo->Location ); |
87 | switch (ToDo->Entries[j].EntryType) { | 86 | switch (ToDo->Entries[j].EntryType) { |
88 | case TODO_END_DATETIME: | 87 | case TODO_END_DATETIME: |
89 | dtp = &ToDo->Entries[j].Date ; | 88 | dtp = &ToDo->Entries[j].Date ; |
90 | todo->setDtDue (fromGSM ( dtp )); | 89 | todo->setDtDue (fromGSM ( dtp )); |
91 | break; | 90 | break; |
92 | case TODO_COMPLETED: | 91 | case TODO_COMPLETED: |
93 | if ( ToDo->Entries[j].Number == 1 ) { | 92 | if ( ToDo->Entries[j].Number == 1 ) { |
94 | todo->setCompleted( true ); | 93 | todo->setCompleted( true ); |
95 | completedString = "yes"; | ||
96 | } | 94 | } |
97 | else { | 95 | else { |
98 | todo->setCompleted( false ); | 96 | todo->setCompleted( false ); |
99 | } | 97 | } |
100 | break; | 98 | break; |
101 | case TODO_ALARM_DATETIME: | 99 | case TODO_ALARM_DATETIME: |
102 | dtp = &ToDo->Entries[j].Date ; | 100 | dtp = &ToDo->Entries[j].Date ; |
103 | alarm = true; | 101 | alarm = true; |
104 | alarmDt = fromGSM ( dtp ); | 102 | alarmDt = fromGSM ( dtp ); |
105 | break; | 103 | break; |
106 | case TODO_SILENT_ALARM_DATETIME: | 104 | case TODO_SILENT_ALARM_DATETIME: |
107 | dtp = &ToDo->Entries[j].Date ; | 105 | dtp = &ToDo->Entries[j].Date ; |
108 | alarm = true; | 106 | alarm = true; |
109 | alarmDt = fromGSM ( dtp ); | 107 | alarmDt = fromGSM ( dtp ); |
110 | break; | 108 | break; |
111 | case TODO_TEXT: | 109 | case TODO_TEXT: |
112 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); | 110 | //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); |
113 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); | 111 | todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); |
114 | break; | 112 | break; |
115 | case TODO_PRIVATE: | 113 | case TODO_PRIVATE: |
116 | if ( ToDo->Entries[j].Number == 1 ) | 114 | if ( ToDo->Entries[j].Number == 1 ) |
117 | todo->setSecrecy( Incidence::SecrecyPrivate ); | 115 | todo->setSecrecy( Incidence::SecrecyPrivate ); |
118 | else | 116 | else |
119 | todo->setSecrecy( Incidence::SecrecyPublic ); | 117 | todo->setSecrecy( Incidence::SecrecyPublic ); |
120 | break; | 118 | break; |
121 | case TODO_CATEGORY: | 119 | case TODO_CATEGORY: |
122 | Category.Location = ToDo->Entries[j].Number; | 120 | Category.Location = ToDo->Entries[j].Number; |
123 | Category.Type = Category_ToDo; | 121 | Category.Type = Category_ToDo; |
124 | error=Phone->GetCategory(s, &Category); | 122 | error=Phone->GetCategory(s, &Category); |
125 | if (error == ERR_NONE) { | 123 | if (error == ERR_NONE) { |
126 | QStringList cat = todo->categories(); | 124 | QStringList cat = todo->categories(); |
127 | QString nCat = QString ( (const char*)Category.Name ); | 125 | QString nCat = QString ( (const char*)Category.Name ); |
128 | if ( !nCat.isEmpty() ) | 126 | if ( !nCat.isEmpty() ) |
129 | if ( !cat.contains( nCat )) { | 127 | if ( !cat.contains( nCat )) { |
130 | cat << nCat; | 128 | cat << nCat; |
131 | todo->setCategories( cat ); | 129 | todo->setCategories( cat ); |
132 | } | 130 | } |
133 | } | 131 | } |
134 | break; | 132 | break; |
135 | case TODO_CONTACTID: | 133 | case TODO_CONTACTID: |
136 | #if 0 | 134 | #if 0 |
137 | // not supported | 135 | // not supported |
138 | entry.Location = ToDo->Entries[j].Number; | 136 | entry.Location = ToDo->Entries[j].Number; |
139 | entry.MemoryType = MEM_ME; | 137 | entry.MemoryType = MEM_ME; |
140 | error=Phone->GetMemory(s, &entry); | 138 | error=Phone->GetMemory(s, &entry); |
141 | if (error == ERR_NONE) { | 139 | if (error == ERR_NONE) { |
142 | name = GSM_PhonebookGetEntryName(&entry); | 140 | name = GSM_PhonebookGetEntryName(&entry); |
143 | if (name != NULL) { | 141 | if (name != NULL) { |
144 | 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); |
145 | } else { | 143 | } else { |
146 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); | 144 | printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); |
147 | } | 145 | } |
148 | } else { | 146 | } else { |
149 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); | 147 | printmsg("Contact : %d\n",ToDo->Entries[j].Number); |
150 | } | 148 | } |
151 | #endif | 149 | #endif |
152 | break; | 150 | break; |
153 | case TODO_PHONE: | 151 | case TODO_PHONE: |
154 | #if 0 | 152 | #if 0 |
155 | // not supported | 153 | // not supported |
156 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); | 154 | printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); |
157 | #endif | 155 | #endif |
158 | break; | 156 | break; |
159 | } | 157 | } |
160 | } | 158 | } |
161 | QString alarmString = "na"; | 159 | QString alarmString = "na"; |
162 | if ( alarm ) { | 160 | if ( alarm ) { |
163 | Alarm *alarm; | 161 | Alarm *alarm; |
164 | if ( todo->alarms().count() > 0 ) | 162 | if ( todo->alarms().count() > 0 ) |
165 | alarm = todo->alarms().first(); | 163 | alarm = todo->alarms().first(); |
166 | else { | 164 | else { |
167 | alarm = new Alarm( todo ); | 165 | alarm = new Alarm( todo ); |
168 | todo->addAlarm( alarm ); | 166 | todo->addAlarm( alarm ); |
169 | } | 167 | } |
170 | alarm->setType( Alarm::Audio ); | 168 | alarm->setType( Alarm::Audio ); |
171 | alarm->setEnabled( true ); | 169 | alarm->setEnabled( true ); |
172 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); | 170 | int alarmOffset = alarmDt.secsTo( todo->dtStart() ); |
173 | alarm->setStartOffset( -alarmOffset ); | 171 | alarm->setStartOffset( -alarmOffset ); |
174 | alarmString = QString::number( alarmOffset ); | 172 | alarmString = QString::number( alarmOffset ); |
175 | } else { | 173 | } else { |
176 | Alarm *alarm; | 174 | Alarm *alarm; |
177 | if ( todo->alarms().count() > 0 ) { | 175 | if ( todo->alarms().count() > 0 ) { |
178 | alarm = todo->alarms().first(); | 176 | alarm = todo->alarms().first(); |
179 | alarm->setType( Alarm::Audio ); | 177 | alarm->setType( Alarm::Audio ); |
180 | alarm->setStartOffset( -60*15 ); | 178 | alarm->setStartOffset( -60*15 ); |
181 | alarm->setEnabled( false ); | 179 | alarm->setEnabled( false ); |
182 | } | 180 | } |
183 | } | 181 | } |
184 | // csum ***************************************** | 182 | // csum ***************************************** |
185 | QStringList attList; | ||
186 | uint cSum; | 183 | uint cSum; |
187 | if ( todo->hasDueDate() ) | 184 | cSum = PhoneFormat::getCsumTodo( todo ); |
188 | attList << dtToString ( todo->dtDue() ); | ||
189 | attList << QString::number( id ); | ||
190 | attList << todo->summary(); | ||
191 | attList << completedString; | ||
192 | attList << QString::number( todo->priority() ); | ||
193 | attList << alarmString; | ||
194 | attList << todo->categoriesStr(); | ||
195 | attList << todo->secrecyStr(); | ||
196 | cSum = PhoneFormat::getCsum(attList ); | ||
197 | todo->setCsum( mProfileName, QString::number( cSum )); | 185 | todo->setCsum( mProfileName, QString::number( cSum )); |
198 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 186 | todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
199 | mCalendar->addTodo( todo); | 187 | mCalendar->addTodo( todo); |
200 | 188 | ||
201 | return true; | 189 | return true; |
202 | } | 190 | } |
203 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) | 191 | bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) |
204 | { | 192 | { |
205 | 193 | ||
206 | int id = Note->Location; | 194 | int id = Note->Location; |
207 | Event *event; | 195 | Event *event; |
208 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); | 196 | event = existingCalendar->event( mProfileName ,QString::number( id ) ); |
209 | if ( event ) | 197 | if ( event ) |
210 | event = (Event*)event->clone(); | 198 | event = (Event*)event->clone(); |
211 | else | 199 | else |
212 | event = new Event; | 200 | event = new Event; |
213 | event->setID( mProfileName,QString::number( id ) ); | 201 | event->setID( mProfileName,QString::number( id ) ); |
214 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); | 202 | event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); |
215 | 203 | ||
216 | 204 | ||
217 | int i = 0; | 205 | int i = 0; |
218 | bool repeating = false; | 206 | bool repeating = false; |
219 | int repeat_dayofweek = -1; | 207 | int repeat_dayofweek = -1; |
220 | int repeat_day = -1; | 208 | int repeat_day = -1; |
221 | int repeat_weekofmonth = -1; | 209 | int repeat_weekofmonth = -1; |
222 | int repeat_month = -1; | 210 | int repeat_month = -1; |
223 | int repeat_frequency = -1; | 211 | int repeat_frequency = -1; |
224 | int rec_type = -1; | 212 | int rec_type = -1; |
225 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 213 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
226 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 214 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
227 | GSM_DateTime* dtp; | 215 | GSM_DateTime* dtp; |
228 | bool alarm = false; | 216 | bool alarm = false; |
229 | QDateTime alarmDt; | 217 | QDateTime alarmDt; |
230 | repeat_startdate.Day= 0; | 218 | repeat_startdate.Day= 0; |
231 | repeat_stopdate.Day = 0; | 219 | repeat_stopdate.Day = 0; |
232 | for (i=0;i<Note->EntriesNum;i++) { | 220 | for (i=0;i<Note->EntriesNum;i++) { |
233 | 221 | ||
234 | //qDebug(" for ev"); | 222 | //qDebug(" for ev"); |
235 | switch (Note->Entries[i].EntryType) { | 223 | switch (Note->Entries[i].EntryType) { |
236 | case CAL_START_DATETIME: | 224 | case CAL_START_DATETIME: |
237 | dtp = &Note->Entries[i].Date ; | 225 | dtp = &Note->Entries[i].Date ; |
238 | if ( dtp->Hour > 24 ) { | 226 | if ( dtp->Hour > 24 ) { |
239 | event->setFloats( true ); | 227 | event->setFloats( true ); |
240 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 228 | event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
241 | } else { | 229 | } else { |
242 | event->setDtStart (fromGSM ( dtp )); | 230 | event->setDtStart (fromGSM ( dtp )); |
243 | 231 | ||
244 | } | 232 | } |
245 | break; | 233 | break; |
246 | case CAL_END_DATETIME: | 234 | case CAL_END_DATETIME: |
247 | dtp = &Note->Entries[i].Date ; | 235 | dtp = &Note->Entries[i].Date ; |
248 | if ( dtp->Hour > 24 ) { | 236 | if ( dtp->Hour > 24 ) { |
249 | event->setFloats( true ); | 237 | event->setFloats( true ); |
250 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); | 238 | event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); |
251 | } else { | 239 | } else { |
252 | event->setDtEnd (fromGSM ( dtp )); | 240 | event->setDtEnd (fromGSM ( dtp )); |
253 | } | 241 | } |
254 | break; | 242 | break; |
255 | case CAL_ALARM_DATETIME: | 243 | case CAL_ALARM_DATETIME: |
256 | dtp = &Note->Entries[i].Date ; | 244 | dtp = &Note->Entries[i].Date ; |
257 | alarm = true; | 245 | alarm = true; |
258 | alarmDt = fromGSM ( dtp ); | 246 | alarmDt = fromGSM ( dtp ); |
259 | break; | 247 | break; |
260 | case CAL_SILENT_ALARM_DATETIME: | 248 | case CAL_SILENT_ALARM_DATETIME: |
261 | dtp = &Note->Entries[i].Date ; | 249 | dtp = &Note->Entries[i].Date ; |
262 | alarm = true; | 250 | alarm = true; |
263 | alarmDt = fromGSM ( dtp ); | 251 | alarmDt = fromGSM ( dtp ); |
264 | break; | 252 | break; |
265 | case CAL_RECURRANCE: | 253 | case CAL_RECURRANCE: |
266 | rec_type = Note->Entries[i].Number; | 254 | rec_type = Note->Entries[i].Number; |
267 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); | 255 | //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); |
268 | break; | 256 | break; |
269 | case CAL_TEXT: | 257 | case CAL_TEXT: |
270 | //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); | 258 | //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); |
271 | event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); | 259 | event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); |
272 | break; | 260 | break; |
273 | case CAL_LOCATION: | 261 | case CAL_LOCATION: |
274 | event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); | 262 | event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); |
275 | break; | 263 | break; |
276 | case CAL_PHONE: | 264 | case CAL_PHONE: |
277 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); | 265 | //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); |
278 | break; | 266 | break; |
279 | case CAL_PRIVATE: | 267 | case CAL_PRIVATE: |
280 | if ( Note->Entries[i].Number == 1 ) | 268 | if ( Note->Entries[i].Number == 1 ) |
281 | event->setSecrecy( Incidence::SecrecyPrivate ); | 269 | event->setSecrecy( Incidence::SecrecyPrivate ); |
282 | else | 270 | else |
283 | event->setSecrecy( Incidence::SecrecyPublic ); | 271 | event->setSecrecy( Incidence::SecrecyPublic ); |
284 | 272 | ||
285 | break; | 273 | break; |
286 | case CAL_CONTACTID: | 274 | case CAL_CONTACTID: |
287 | #if 0 | 275 | #if 0 |
288 | entry.Location = Note->Entries[i].Number; | 276 | entry.Location = Note->Entries[i].Number; |
289 | entry.MemoryType = MEM_ME; | 277 | entry.MemoryType = MEM_ME; |
290 | error=Phone->GetMemory(&s, &entry); | 278 | error=Phone->GetMemory(&s, &entry); |
291 | if (error == ERR_NONE) { | 279 | if (error == ERR_NONE) { |
292 | name = GSM_PhonebookGetEntryName(&entry); | 280 | name = GSM_PhonebookGetEntryName(&entry); |
293 | if (name != NULL) { | 281 | if (name != NULL) { |
294 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); | 282 | //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); |
295 | } else { | 283 | } else { |
296 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 284 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
297 | } | 285 | } |
298 | } else { | 286 | } else { |
299 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); | 287 | //printmsg("Contact ID : %d\n",Note->Entries[i].Number); |
300 | } | 288 | } |
301 | #endif | 289 | #endif |
302 | break; | 290 | break; |
303 | case CAL_REPEAT_DAYOFWEEK: | 291 | case CAL_REPEAT_DAYOFWEEK: |
304 | repeat_dayofweek = Note->Entries[i].Number; | 292 | repeat_dayofweek = Note->Entries[i].Number; |
305 | repeating = true; | 293 | repeating = true; |
306 | break; | 294 | break; |
307 | case CAL_REPEAT_DAY: | 295 | case CAL_REPEAT_DAY: |
308 | repeat_day = Note->Entries[i].Number; | 296 | repeat_day = Note->Entries[i].Number; |
309 | repeating = true; | 297 | repeating = true; |
310 | break; | 298 | break; |
311 | case CAL_REPEAT_WEEKOFMONTH: | 299 | case CAL_REPEAT_WEEKOFMONTH: |
312 | repeat_weekofmonth = Note->Entries[i].Number; | 300 | repeat_weekofmonth = Note->Entries[i].Number; |
313 | repeating = true; | 301 | repeating = true; |
314 | break; | 302 | break; |
315 | case CAL_REPEAT_MONTH: | 303 | case CAL_REPEAT_MONTH: |
316 | repeat_month = Note->Entries[i].Number; | 304 | repeat_month = Note->Entries[i].Number; |
317 | repeating = true; | 305 | repeating = true; |
318 | break; | 306 | break; |
319 | case CAL_REPEAT_FREQUENCY: | 307 | case CAL_REPEAT_FREQUENCY: |
320 | repeat_frequency = Note->Entries[i].Number; | 308 | repeat_frequency = Note->Entries[i].Number; |
321 | repeating = true; | 309 | repeating = true; |
322 | break; | 310 | break; |
323 | case CAL_REPEAT_STARTDATE: | 311 | case CAL_REPEAT_STARTDATE: |
324 | repeat_startdate = Note->Entries[i].Date; | 312 | repeat_startdate = Note->Entries[i].Date; |
@@ -335,696 +323,838 @@ public: | |||
335 | bool repeating = false; | 323 | bool repeating = false; |
336 | int repeat_dayofweek = -1; | 324 | int repeat_dayofweek = -1; |
337 | int repeat_day = -1; | 325 | int repeat_day = -1; |
338 | int repeat_weekofmonth = -1; | 326 | int repeat_weekofmonth = -1; |
339 | int repeat_month = -1; | 327 | int repeat_month = -1; |
340 | int repeat_frequency = -1; | 328 | int repeat_frequency = -1; |
341 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; | 329 | GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; |
342 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; | 330 | GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; |
343 | 331 | ||
344 | #endif | 332 | #endif |
345 | 333 | ||
346 | QString recurString = "no"; | 334 | QString recurString = "no"; |
347 | if ( repeating && repeat_frequency != -1) { | 335 | if ( repeating && repeat_frequency != -1) { |
348 | recurString = "y"; | 336 | recurString = "y"; |
349 | if ( repeat_dayofweek >= 0 ) | 337 | if ( repeat_dayofweek >= 0 ) |
350 | recurString += "dow" + QString::number (repeat_dayofweek); | 338 | recurString += "dow" + QString::number (repeat_dayofweek); |
351 | if ( repeat_day >= 0 ) | 339 | if ( repeat_day >= 0 ) |
352 | recurString += "d" + QString::number (repeat_day); | 340 | recurString += "d" + QString::number (repeat_day); |
353 | if ( repeat_weekofmonth >= 0 ) | 341 | if ( repeat_weekofmonth >= 0 ) |
354 | recurString += "w" + QString::number (repeat_weekofmonth); | 342 | recurString += "w" + QString::number (repeat_weekofmonth); |
355 | if ( repeat_month >= 0 ) | 343 | if ( repeat_month >= 0 ) |
356 | recurString += "m" + QString::number ( repeat_month ); | 344 | recurString += "m" + QString::number ( repeat_month ); |
357 | if ( repeat_frequency >= 0 ) | 345 | if ( repeat_frequency >= 0 ) |
358 | recurString += "f" + QString::number (repeat_frequency ); | 346 | recurString += "f" + QString::number (repeat_frequency ); |
359 | 347 | ||
360 | int rtype = 0; | 348 | int rtype = 0; |
361 | // qDebug("recurs "); | 349 | // qDebug("recurs "); |
362 | QDate startDate, endDate; | 350 | QDate startDate, endDate; |
363 | if ( repeat_startdate.Day > 0 ) { | 351 | if ( repeat_startdate.Day > 0 ) { |
364 | startDate = datefromGSM ( &repeat_startdate ); | 352 | startDate = datefromGSM ( &repeat_startdate ); |
365 | event->setDtStart(QDateTime ( startDate, event->dtStart().time())); | 353 | event->setDtStart(QDateTime ( startDate, event->dtStart().time())); |
366 | } else { | 354 | } else { |
367 | startDate = event->dtStart().date(); | 355 | startDate = event->dtStart().date(); |
368 | } | 356 | } |
369 | int freq = repeat_frequency; | 357 | int freq = repeat_frequency; |
370 | bool hasEndDate = false; | 358 | bool hasEndDate = false; |
371 | if ( repeat_stopdate.Day > 0 ) { | 359 | if ( repeat_stopdate.Day > 0 ) { |
372 | endDate = datefromGSM ( &repeat_stopdate ); | 360 | endDate = datefromGSM ( &repeat_stopdate ); |
373 | hasEndDate = true; | 361 | hasEndDate = true; |
374 | } | 362 | } |
375 | 363 | ||
376 | uint weekDaysNum = repeat_dayofweek ; | 364 | uint weekDaysNum = repeat_dayofweek ; |
377 | // 1 == monday, 7 == sunday | 365 | // 1 == monday, 7 == sunday |
378 | QBitArray weekDays( 7 ); | 366 | QBitArray weekDays( 7 ); |
379 | int i; | 367 | int i; |
380 | int bb = 1; | 368 | int bb = 1; |
381 | for( i = 1; i <= 7; ++i ) { | 369 | for( i = 1; i <= 7; ++i ) { |
382 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); | 370 | weekDays.setBit( i - 1, ( bb & weekDaysNum )); |
383 | bb = 2 << (i-1); | 371 | bb = 2 << (i-1); |
384 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); | 372 | //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); |
385 | } | 373 | } |
386 | // qDebug("next "); | 374 | // qDebug("next "); |
387 | int pos = 0; | 375 | int pos = 0; |
388 | Recurrence *r = event->recurrence(); | 376 | Recurrence *r = event->recurrence(); |
389 | /* | 377 | /* |
390 | 0 daily; | 378 | 0 daily; |
391 | 1 weekly;x | 379 | 1 weekly;x |
392 | 2 monthpos;x | 380 | 2 monthpos;x |
393 | 3 monthlyday; | 381 | 3 monthlyday; |
394 | 4 rYearlyMont | 382 | 4 rYearlyMont |
395 | bool repeating = false; | 383 | bool repeating = false; |
396 | int repeat_dayofweek = -1; | 384 | int repeat_dayofweek = -1; |
397 | int repeat_day = -1; | 385 | int repeat_day = -1; |
398 | int repeat_weekofmonth = -1; | 386 | int repeat_weekofmonth = -1; |
399 | int repeat_month = -1; | 387 | int repeat_month = -1; |
400 | int repeat_frequency = -1; | 388 | int repeat_frequency = -1; |
401 | */ | 389 | */ |
402 | int dayOfWeek = startDate.dayOfWeek(); | 390 | int dayOfWeek = startDate.dayOfWeek(); |
403 | if ( repeat_weekofmonth >= 0 ) { | 391 | if ( repeat_weekofmonth >= 0 ) { |
404 | rtype = 2; // ************************ 2 MonthlyPos | 392 | rtype = 2; // ************************ 2 MonthlyPos |
405 | pos = repeat_weekofmonth; | 393 | pos = repeat_weekofmonth; |
406 | if ( repeat_dayofweek >= 0 ) | 394 | if ( repeat_dayofweek >= 0 ) |
407 | dayOfWeek = repeat_dayofweek; | 395 | dayOfWeek = repeat_dayofweek; |
408 | if (repeat_month > 0) { | 396 | if (repeat_month > 0) { |
409 | if ( repeat_month != event->dtStart().date().month() ) { | 397 | if ( repeat_month != event->dtStart().date().month() ) { |
410 | QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() ); | 398 | QDate date (event->dtStart().date().year(),repeat_month,event->dtStart().date().day() ); |
411 | event->setDtStart(QDateTime ( date , event->dtStart().time()) ); | 399 | event->setDtStart(QDateTime ( date , event->dtStart().time()) ); |
412 | } | 400 | } |
413 | if ( freq == 1 ) | 401 | if ( freq == 1 ) |
414 | freq = 12; | 402 | freq = 12; |
415 | } | 403 | } |
416 | } else if ( repeat_dayofweek >= 0 ) { | 404 | } else if ( repeat_dayofweek >= 0 ) { |
417 | rtype = 1;// ************************ 1 Weekly | 405 | rtype = 1;// ************************ 1 Weekly |
418 | } else if ( repeat_day >= 0 ) { | 406 | } else if ( repeat_day >= 0 ) { |
419 | if ( repeat_month > 0) { | 407 | if ( repeat_month > 0) { |
420 | rtype = 4; | 408 | rtype = 4; |
421 | } else { | 409 | } else { |
422 | rtype = 3; | 410 | rtype = 3; |
423 | } | 411 | } |
424 | } else { | 412 | } else { |
425 | rtype = 0 ; | 413 | rtype = 0 ; |
426 | } | 414 | } |
427 | 415 | ||
428 | if ( rtype == 0 ) { | 416 | if ( rtype == 0 ) { |
429 | if ( hasEndDate ) r->setDaily( freq, endDate ); | 417 | if ( hasEndDate ) r->setDaily( freq, endDate ); |
430 | else r->setDaily( freq, -1 ); | 418 | else r->setDaily( freq, -1 ); |
431 | } else if ( rtype == 1 ) { | 419 | } else if ( rtype == 1 ) { |
432 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); | 420 | if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); |
433 | else r->setWeekly( freq, weekDays, -1 ); | 421 | else r->setWeekly( freq, weekDays, -1 ); |
434 | } else if ( rtype == 3 ) { | 422 | } else if ( rtype == 3 ) { |
435 | if ( hasEndDate ) | 423 | if ( hasEndDate ) |
436 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); | 424 | r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); |
437 | else | 425 | else |
438 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); | 426 | r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); |
439 | r->addMonthlyDay( startDate.day() ); | 427 | r->addMonthlyDay( startDate.day() ); |
440 | } else if ( rtype == 2 ) { | 428 | } else if ( rtype == 2 ) { |
441 | if ( hasEndDate ) | 429 | if ( hasEndDate ) |
442 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); | 430 | r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); |
443 | else | 431 | else |
444 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); | 432 | r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); |
445 | QBitArray days( 7 ); | 433 | QBitArray days( 7 ); |
446 | days.fill( false ); | 434 | days.fill( false ); |
447 | days.setBit( dayOfWeek - 1 ); | 435 | days.setBit( dayOfWeek - 1 ); |
448 | r->addMonthlyPos( pos, days ); | 436 | r->addMonthlyPos( pos, days ); |
449 | } else if ( rtype == 4 ) { | 437 | } else if ( rtype == 4 ) { |
450 | if ( hasEndDate ) | 438 | if ( hasEndDate ) |
451 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); | 439 | r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); |
452 | else | 440 | else |
453 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); | 441 | r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); |
454 | r->addYearlyNum( startDate.month() ); | 442 | r->addYearlyNum( startDate.month() ); |
455 | } | 443 | } |
456 | } else { | 444 | } else { |
457 | event->recurrence()->unsetRecurs(); | 445 | event->recurrence()->unsetRecurs(); |
458 | } | 446 | } |
459 | 447 | ||
460 | QStringList categoryList; | 448 | QStringList categoryList; |
461 | categoryList << getCategory( Note ); | 449 | categoryList << getCategory( Note ); |
462 | event->setCategories( categoryList ); | 450 | event->setCategories( categoryList ); |
463 | QString alarmString = "na"; | ||
464 | // strange 0 semms to mean: alarm enabled | 451 | // strange 0 semms to mean: alarm enabled |
465 | if ( alarm ) { | 452 | if ( alarm ) { |
466 | Alarm *alarm; | 453 | Alarm *alarm; |
467 | if ( event->alarms().count() > 0 ) | 454 | if ( event->alarms().count() > 0 ) |
468 | alarm = event->alarms().first(); | 455 | alarm = event->alarms().first(); |
469 | else { | 456 | else { |
470 | alarm = new Alarm( event ); | 457 | alarm = new Alarm( event ); |
471 | event->addAlarm( alarm ); | 458 | event->addAlarm( alarm ); |
472 | } | 459 | } |
473 | alarm->setType( Alarm::Audio ); | 460 | alarm->setType( Alarm::Audio ); |
474 | alarm->setEnabled( true ); | 461 | alarm->setEnabled( true ); |
475 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); | 462 | int alarmOffset = alarmDt.secsTo( event->dtStart() ); |
476 | alarm->setStartOffset( -alarmOffset ); | 463 | alarm->setStartOffset( -alarmOffset ); |
477 | alarmString = QString::number( alarmOffset ); | ||
478 | } else { | 464 | } else { |
479 | Alarm *alarm; | 465 | Alarm *alarm; |
480 | if ( event->alarms().count() > 0 ) { | 466 | if ( event->alarms().count() > 0 ) { |
481 | alarm = event->alarms().first(); | 467 | alarm = event->alarms().first(); |
482 | alarm->setType( Alarm::Audio ); | 468 | alarm->setType( Alarm::Audio ); |
483 | alarm->setStartOffset( -60*15 ); | 469 | alarm->setStartOffset( -60*15 ); |
484 | alarm->setEnabled( false ); | 470 | alarm->setEnabled( false ); |
485 | } | 471 | } |
486 | } | 472 | } |
487 | // csum ***************************************** | 473 | // csum ***************************************** |
488 | QStringList attList; | 474 | |
489 | uint cSum; | 475 | uint cSum; |
490 | attList << dtToString ( event->dtStart() ); | 476 | cSum = PhoneFormat::getCsumEvent( event ); |
491 | attList << dtToString ( event->dtEnd() ); | ||
492 | attList << QString::number( id ); | ||
493 | attList << event->summary(); | ||
494 | attList << event->location(); | ||
495 | attList << alarmString; | ||
496 | attList << recurString; | ||
497 | attList << event->categoriesStr(); | ||
498 | attList << event->secrecyStr(); | ||
499 | cSum = PhoneFormat::getCsum(attList ); | ||
500 | event->setCsum( mProfileName, QString::number( cSum )); | 477 | event->setCsum( mProfileName, QString::number( cSum )); |
501 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); | 478 | event->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); |
502 | mCalendar->addEvent( event); | 479 | mCalendar->addEvent( event); |
503 | 480 | ||
504 | return true; | 481 | return true; |
505 | } | 482 | } |
506 | 483 | ||
507 | 484 | ||
508 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { | 485 | QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { |
509 | QDateTime dt; | 486 | QDateTime dt; |
510 | int y,m,t,h,min,sec; | 487 | int y,m,t,h,min,sec; |
511 | y = dtp->Year; | 488 | y = dtp->Year; |
512 | m = dtp->Month; | 489 | m = dtp->Month; |
513 | t = dtp->Day; | 490 | t = dtp->Day; |
514 | h = dtp->Hour; | 491 | h = dtp->Hour; |
515 | min = dtp->Minute; | 492 | min = dtp->Minute; |
516 | sec = dtp->Second; | 493 | sec = dtp->Second; |
517 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); | 494 | dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); |
518 | // dtp->Timezone: offset in hours | 495 | // dtp->Timezone: offset in hours |
519 | int offset = KGlobal::locale()->localTimeOffset( dt ); | 496 | int offset = KGlobal::locale()->localTimeOffset( dt ); |
520 | if ( useTz ) | 497 | if ( useTz ) |
521 | dt = dt.addSecs ( offset*60); | 498 | dt = dt.addSecs ( offset*60); |
522 | return dt; | 499 | return dt; |
523 | 500 | ||
524 | } | 501 | } |
525 | 502 | ||
526 | QString dtToString( const QDateTime& dti, bool useTZ = false ) | 503 | static QString dtToString( const QDateTime& dti, bool useTZ = false ) |
527 | { | 504 | { |
528 | QString datestr; | 505 | QString datestr; |
529 | QString timestr; | 506 | QString timestr; |
530 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 507 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
531 | QDateTime dt; | 508 | QDateTime dt; |
532 | if (useTZ) | 509 | if (useTZ) |
533 | dt = dti.addSecs ( -(offset*60)); | 510 | dt = dti.addSecs ( -(offset*60)); |
534 | else | 511 | else |
535 | dt = dti; | 512 | dt = dti; |
536 | if(dt.date().isValid()){ | 513 | if(dt.date().isValid()){ |
537 | const QDate& date = dt.date(); | 514 | const QDate& date = dt.date(); |
538 | datestr.sprintf("%04d%02d%02d", | 515 | datestr.sprintf("%04d%02d%02d", |
539 | date.year(), date.month(), date.day()); | 516 | date.year(), date.month(), date.day()); |
540 | } | 517 | } |
541 | if(dt.time().isValid()){ | 518 | if(dt.time().isValid()){ |
542 | const QTime& time = dt.time(); | 519 | const QTime& time = dt.time(); |
543 | timestr.sprintf("T%02d%02d%02d", | 520 | timestr.sprintf("T%02d%02d%02d", |
544 | time.hour(), time.minute(), time.second()); | 521 | time.hour(), time.minute(), time.second()); |
545 | } | 522 | } |
546 | return datestr + timestr; | 523 | return datestr + timestr; |
547 | } | 524 | } |
548 | QDate datefromGSM ( GSM_DateTime*dtp ) { | 525 | QDate datefromGSM ( GSM_DateTime*dtp ) { |
549 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); | 526 | return QDate ( dtp->Year, dtp->Month, dtp->Day ); |
550 | } | 527 | } |
551 | QString getCategory( GSM_CalendarEntry*Note) | 528 | QString getCategory( GSM_CalendarEntry*Note) |
552 | { | 529 | { |
553 | QString CATEGORY; | 530 | QString CATEGORY; |
554 | switch (Note->Type) { | 531 | switch (Note->Type) { |
555 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; | 532 | case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; |
556 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; | 533 | case GSM_CAL_CALL : CATEGORY = QString("Call"); break; |
557 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; | 534 | case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; |
558 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; | 535 | case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; |
559 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; | 536 | case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; |
560 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; | 537 | case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; |
561 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; | 538 | case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; |
562 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; | 539 | case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; |
563 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; | 540 | case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; |
564 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; | 541 | case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; |
565 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; | 542 | case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; |
566 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; | 543 | case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; |
567 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; | 544 | case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; |
568 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; | 545 | case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; |
569 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; | 546 | case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; |
570 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; | 547 | case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; |
571 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; | 548 | case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; |
572 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; | 549 | case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; |
573 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; | 550 | case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; |
574 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; | 551 | case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; |
575 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; | 552 | case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; |
576 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; | 553 | case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; |
577 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; | 554 | case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; |
578 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; | 555 | case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; |
579 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; | 556 | case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; |
580 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; | 557 | case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; |
581 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; | 558 | case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; |
582 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; | 559 | case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; |
583 | default : CATEGORY = QString(""); | 560 | default : CATEGORY = QString(""); |
584 | } | 561 | } |
585 | 562 | ||
586 | return CATEGORY; | 563 | return CATEGORY; |
587 | } | 564 | } |
588 | 565 | ||
589 | protected: | 566 | protected: |
590 | private: | 567 | private: |
591 | Calendar *mCalendar; | 568 | Calendar *mCalendar; |
592 | QString mProfileName ; | 569 | QString mProfileName ; |
593 | }; | 570 | }; |
594 | 571 | ||
595 | 572 | ||
596 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) | 573 | PhoneFormat::PhoneFormat(QString profileName, QString device,QString connection, QString model ) |
597 | { | 574 | { |
598 | mProfileName = profileName; | 575 | mProfileName = profileName; |
599 | mDevice = device; | 576 | mDevice = device; |
600 | mConnection = connection; | 577 | mConnection = connection; |
601 | mModel = model; | 578 | mModel = model; |
602 | } | 579 | } |
603 | 580 | ||
604 | PhoneFormat::~PhoneFormat() | 581 | PhoneFormat::~PhoneFormat() |
605 | { | 582 | { |
606 | } | 583 | } |
607 | int PhoneFormat::initDevice(GSM_StateMachine *s) | 584 | int PhoneFormat::initDevice(GSM_StateMachine *s) |
608 | { | 585 | { |
609 | GSM_ReadConfig(NULL, &s->Config[0], 0); | 586 | GSM_ReadConfig(NULL, &s->Config[0], 0); |
610 | s->ConfigNum = 1; | 587 | s->ConfigNum = 1; |
611 | GSM_Config *cfg = &s->Config[0]; | 588 | GSM_Config *cfg = &s->Config[0]; |
612 | if ( ! mConnection.isEmpty() ) { | 589 | if ( ! mConnection.isEmpty() ) { |
613 | cfg->Connection = strdup(mConnection.latin1()); | 590 | cfg->Connection = strdup(mConnection.latin1()); |
614 | cfg->DefaultConnection = false; | 591 | cfg->DefaultConnection = false; |
615 | qDebug("Connection set %s ", cfg->Connection ); | 592 | qDebug("Connection set %s ", cfg->Connection ); |
616 | 593 | ||
617 | } | 594 | } |
618 | if ( ! mDevice.isEmpty() ) { | 595 | if ( ! mDevice.isEmpty() ) { |
619 | cfg->Device = strdup(mDevice.latin1()); | 596 | cfg->Device = strdup(mDevice.latin1()); |
620 | cfg->DefaultDevice = false; | 597 | cfg->DefaultDevice = false; |
621 | qDebug("Device set %s ", cfg->Device); | 598 | qDebug("Device set %s ", cfg->Device); |
622 | 599 | ||
623 | } | 600 | } |
624 | if ( ! mModel.isEmpty() ) { | 601 | if ( ! mModel.isEmpty() ) { |
625 | strcpy(cfg->Model,mModel.latin1() ); | 602 | strcpy(cfg->Model,mModel.latin1() ); |
626 | cfg->DefaultModel = false; | 603 | cfg->DefaultModel = false; |
627 | qDebug("Model set %s ",cfg->Model ); | 604 | qDebug("Model set %s ",cfg->Model ); |
628 | } | 605 | } |
629 | int error=GSM_InitConnection(s,3); | 606 | int error=GSM_InitConnection(s,3); |
630 | return error; | 607 | return error; |
631 | } | 608 | } |
609 | ulong PhoneFormat::getCsumTodo( Todo* todo ) | ||
610 | { | ||
611 | QStringList attList; | ||
612 | if ( todo->hasDueDate() ) | ||
613 | attList << PhoneParser::dtToString ( todo->dtDue() ); | ||
614 | attList << todo->summary(); | ||
615 | QString completedString = "no"; | ||
616 | if ( todo->isCompleted() ) | ||
617 | completedString = "yes"; | ||
618 | attList << completedString; | ||
619 | attList << QString::number( todo->priority() ); | ||
620 | QString alarmString = "na"; | ||
621 | Alarm *alarm; | ||
622 | if ( todo->alarms().count() > 0 ) { | ||
623 | alarm = todo->alarms().first(); | ||
624 | if ( alarm->enabled() ) { | ||
625 | alarmString = QString::number(alarm->startOffset().asSeconds() ); | ||
626 | } | ||
627 | } | ||
628 | attList << alarmString; | ||
629 | attList << todo->categoriesStr(); | ||
630 | attList << todo->secrecyStr(); | ||
631 | return PhoneFormat::getCsum(attList ); | ||
632 | |||
633 | } | ||
634 | ulong PhoneFormat::getCsumEvent( Event* event ) | ||
635 | { | ||
636 | QStringList attList; | ||
637 | attList << PhoneParser::dtToString ( event->dtStart() ); | ||
638 | attList << PhoneParser::dtToString ( event->dtEnd() ); | ||
639 | attList << event->summary(); | ||
640 | attList << event->location(); | ||
641 | QString alarmString = "na"; | ||
642 | Alarm *alarm; | ||
643 | if ( event->alarms().count() > 0 ) { | ||
644 | alarm = event->alarms().first(); | ||
645 | if ( alarm->enabled() ) { | ||
646 | alarmString = QString::number( alarm->startOffset().asSeconds() ); | ||
647 | } | ||
648 | } | ||
649 | attList << alarmString; | ||
650 | Recurrence* rec = event->recurrence(); | ||
651 | QStringList list; | ||
652 | bool writeEndDate = false; | ||
653 | switch ( rec->doesRecur() ) | ||
654 | { | ||
655 | case Recurrence::rDaily: // 0 | ||
656 | list.append( "0" ); | ||
657 | list.append( QString::number( rec->frequency() ));//12 | ||
658 | list.append( "0" ); | ||
659 | list.append( "0" ); | ||
660 | writeEndDate = true; | ||
661 | break; | ||
662 | case Recurrence::rWeekly:// 1 | ||
663 | list.append( "1" ); | ||
664 | list.append( QString::number( rec->frequency()) );//12 | ||
665 | list.append( "0" ); | ||
666 | { | ||
667 | int days = 0; | ||
668 | QBitArray weekDays = rec->days(); | ||
669 | int i; | ||
670 | for( i = 1; i <= 7; ++i ) { | ||
671 | if ( weekDays[i-1] ) { | ||
672 | days += 1 << (i-1); | ||
673 | } | ||
674 | } | ||
675 | list.append( QString::number( days ) ); | ||
676 | } | ||
677 | //pending weekdays | ||
678 | writeEndDate = true; | ||
679 | |||
680 | break; | ||
681 | case Recurrence::rMonthlyPos:// 2 | ||
682 | list.append( "2" ); | ||
683 | list.append( QString::number( rec->frequency()) );//12 | ||
684 | |||
685 | writeEndDate = true; | ||
686 | { | ||
687 | int count = 1; | ||
688 | QPtrList<Recurrence::rMonthPos> rmp; | ||
689 | rmp = rec->monthPositions(); | ||
690 | if ( rmp.first()->negative ) | ||
691 | count = 5 - rmp.first()->rPos - 1; | ||
692 | else | ||
693 | count = rmp.first()->rPos - 1; | ||
694 | list.append( QString::number( count ) ); | ||
695 | |||
696 | } | ||
697 | |||
698 | list.append( "0" ); | ||
699 | break; | ||
700 | case Recurrence::rMonthlyDay:// 3 | ||
701 | list.append( "3" ); | ||
702 | list.append( QString::number( rec->frequency()) );//12 | ||
703 | list.append( "0" ); | ||
704 | list.append( "0" ); | ||
705 | writeEndDate = true; | ||
706 | break; | ||
707 | case Recurrence::rYearlyMonth://4 | ||
708 | list.append( "4" ); | ||
709 | list.append( QString::number( rec->frequency()) );//12 | ||
710 | list.append( "0" ); | ||
711 | list.append( "0" ); | ||
712 | writeEndDate = true; | ||
713 | break; | ||
714 | |||
715 | default: | ||
716 | list.append( "255" ); | ||
717 | list.append( QString() ); | ||
718 | list.append( "0" ); | ||
719 | list.append( QString() ); | ||
720 | list.append( "0" ); | ||
721 | list.append( "20991231T000000" ); | ||
722 | break; | ||
723 | } | ||
724 | if ( writeEndDate ) { | ||
725 | |||
726 | if ( rec->endDate().isValid() ) { // 15 + 16 | ||
727 | list.append( "1" ); | ||
728 | list.append( PhoneParser::dtToString( rec->endDate()) ); | ||
729 | } else { | ||
730 | list.append( "0" ); | ||
731 | list.append( "20991231T000000" ); | ||
732 | } | ||
733 | |||
734 | } | ||
735 | attList << list.join(""); | ||
736 | attList << event->categoriesStr(); | ||
737 | attList << event->secrecyStr(); | ||
738 | return PhoneFormat::getCsum(attList ); | ||
739 | } | ||
632 | ulong PhoneFormat::getCsum( const QStringList & attList) | 740 | ulong PhoneFormat::getCsum( const QStringList & attList) |
633 | { | 741 | { |
634 | int max = attList.count() -1; | 742 | int max = attList.count() -1; |
635 | ulong cSum = 0; | 743 | ulong cSum = 0; |
636 | int j,k,i; | 744 | int j,k,i; |
637 | int add; | 745 | int add; |
638 | for ( i = 1; i < max ; ++i ) { | 746 | for ( i = 1; i < max ; ++i ) { |
639 | QString s = attList[i]; | 747 | QString s = attList[i]; |
640 | if ( ! s.isEmpty() ){ | 748 | if ( ! s.isEmpty() ){ |
641 | j = s.length(); | 749 | j = s.length(); |
642 | for ( k = 0; k < j; ++k ) { | 750 | for ( k = 0; k < j; ++k ) { |
643 | int mul = k +1; | 751 | int mul = k +1; |
644 | add = s[k].unicode (); | 752 | add = s[k].unicode (); |
645 | if ( k < 16 ) | 753 | if ( k < 16 ) |
646 | mul = mul * mul; | 754 | mul = mul * mul; |
647 | add = add * mul *i*i*i; | 755 | add = add * mul *i*i*i; |
648 | cSum += add; | 756 | cSum += add; |
649 | } | 757 | } |
650 | } | 758 | } |
651 | } | 759 | } |
652 | return cSum; | 760 | return cSum; |
653 | 761 | ||
654 | } | 762 | } |
655 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); | 763 | //extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); |
656 | #include <stdlib.h> | 764 | #include <stdlib.h> |
657 | #define DEBUGMODE false | 765 | #define DEBUGMODE false |
658 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) | 766 | bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) |
659 | { | 767 | { |
660 | GSM_StateMachines; | 768 | GSM_StateMachines; |
661 | qDebug(" load "); | 769 | qDebug(" load "); |
662 | s.opened = false; | 770 | s.opened = false; |
663 | s.msg = NULL; | 771 | s.msg = NULL; |
664 | s.ConfigNum = 0; | 772 | s.ConfigNum = 0; |
665 | #if 0 | 773 | #if 0 |
666 | static char*cp; | 774 | static char*cp; |
667 | static INI_Section *cfg = NULL; | 775 | static INI_Section *cfg = NULL; |
668 | cfg=GSM_FindGammuRC(); | 776 | cfg=GSM_FindGammuRC(); |
669 | int i; | 777 | int i; |
670 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { | 778 | for (i = 0; i <= MAX_CONFIG_NUM; i++) { |
671 | if (cfg!=NULL) { | 779 | if (cfg!=NULL) { |
672 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); | 780 | cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); |
673 | if (cp) di.coding = cp; | 781 | if (cp) di.coding = cp; |
674 | 782 | ||
675 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); | 783 | s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); |
676 | if (s.Config[i].Localize) { | 784 | if (s.Config[i].Localize) { |
677 | s.msg=INI_ReadFile(s.Config[i].Localize, true); | 785 | s.msg=INI_ReadFile(s.Config[i].Localize, true); |
678 | } else { | 786 | } else { |
679 | #if !defined(WIN32) && defined(LOCALE_PATH) | 787 | #if !defined(WIN32) && defined(LOCALE_PATH) |
680 | locale = setlocale(LC_MESSAGES, NULL); | 788 | locale = setlocale(LC_MESSAGES, NULL); |
681 | if (locale != NULL) { | 789 | if (locale != NULL) { |
682 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", | 790 | snprintf(locale_file, 200, "%s/gammu_%c%c.txt", |
683 | LOCALE_PATH, | 791 | LOCALE_PATH, |
684 | tolower(locale[0]), | 792 | tolower(locale[0]), |
685 | tolower(locale[1])); | 793 | tolower(locale[1])); |
686 | s.msg = INI_ReadFile(locale_file, true); | 794 | s.msg = INI_ReadFile(locale_file, true); |
687 | } | 795 | } |
688 | #endif | 796 | #endif |
689 | } | 797 | } |
690 | } | 798 | } |
691 | 799 | ||
692 | /* Wanted user specific configuration? */ | 800 | /* Wanted user specific configuration? */ |
693 | 801 | ||
694 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; | 802 | if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; |
695 | 803 | ||
696 | s.ConfigNum++; | 804 | s.ConfigNum++; |
697 | 805 | ||
698 | /* We want to use only one file descriptor for global and state machine debug output */ | 806 | /* We want to use only one file descriptor for global and state machine debug output */ |
699 | s.Config[i].UseGlobalDebugFile = true; | 807 | s.Config[i].UseGlobalDebugFile = true; |
700 | 808 | ||
701 | 809 | ||
702 | 810 | ||
703 | /* We wanted to read just user specified configuration. */ | 811 | /* We wanted to read just user specified configuration. */ |
704 | {break;} | 812 | {break;} |
705 | } | 813 | } |
706 | 814 | ||
707 | #endif | 815 | #endif |
708 | int error=initDevice(&s); | 816 | int error=initDevice(&s); |
709 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); | 817 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); |
710 | if ( error != ERR_NONE ) | 818 | if ( error != ERR_NONE ) |
711 | return false; | 819 | return false; |
712 | GSM_Phone_Functions*Phone; | 820 | GSM_Phone_Functions*Phone; |
713 | GSM_CalendarEntrynote; | 821 | GSM_CalendarEntrynote; |
714 | bool start = true; | 822 | bool start = true; |
715 | Phone=s.Phone.Functions; | 823 | Phone=s.Phone.Functions; |
716 | bool gshutdown = false; | 824 | bool gshutdown = false; |
717 | PhoneParser handler( calendar, mProfileName ); | 825 | PhoneParser handler( calendar, mProfileName ); |
718 | int ccc = 0; | 826 | int ccc = 0; |
719 | qDebug("Debug: only 10 calender items are downloaded "); | 827 | qDebug("Debug: only 10 calender items are downloaded "); |
720 | while (!gshutdown && ccc++ < 10) { | 828 | while (!gshutdown && ccc++ < 10) { |
721 | 829 | ||
722 | qDebug("readEvent %d ", ccc); | 830 | qDebug("readEvent %d ", ccc); |
723 | error=Phone->GetNextCalendar(&s,¬e,start); | 831 | error=Phone->GetNextCalendar(&s,¬e,start); |
724 | if (error == ERR_EMPTY) break; | 832 | if (error == ERR_EMPTY) break; |
725 | start = false; | 833 | start = false; |
726 | handler.readEvent( existingCal, ¬e ); | 834 | handler.readEvent( existingCal, ¬e ); |
727 | } | 835 | } |
728 | 836 | ||
729 | start = true; | 837 | start = true; |
730 | GSM_ToDoEntry ToDo; | 838 | GSM_ToDoEntry ToDo; |
731 | ccc = 0; | 839 | ccc = 0; |
732 | while (!gshutdown) { | 840 | while (!gshutdown) { |
733 | error = Phone->GetNextToDo(&s, &ToDo, start); | 841 | error = Phone->GetNextToDo(&s, &ToDo, start); |
734 | if (error == ERR_EMPTY) break; | 842 | if (error == ERR_EMPTY) break; |
735 | start = false; | 843 | start = false; |
736 | qDebug("ReadTodo %d ", ++ccc); | 844 | qDebug("ReadTodo %d ", ++ccc); |
737 | handler.readTodo( existingCal, &ToDo, &s); | 845 | handler.readTodo( existingCal, &ToDo, &s); |
738 | 846 | ||
739 | } | 847 | } |
740 | 848 | ||
741 | error=GSM_TerminateConnection(&s); | 849 | error=GSM_TerminateConnection(&s); |
742 | 850 | ||
743 | return true; | 851 | return true; |
744 | } | 852 | } |
745 | void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) | 853 | void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) |
746 | { | 854 | { |
747 | 855 | ||
748 | } | 856 | } |
749 | void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsm ) | 857 | void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsm ) |
750 | { | 858 | { |
751 | #if 0 | 859 | #if 0 |
752 | QStringList list; | 860 | QStringList list; |
753 | list.append( QString::number( todo->zaurusId() ) ); | 861 | list.append( QString::number( todo->zaurusId() ) ); |
754 | list.append( todo->categories().join(",") ); | 862 | list.append( todo->categories().join(",") ); |
755 | 863 | ||
756 | if ( todo->hasStartDate() ) { | 864 | if ( todo->hasStartDate() ) { |
757 | list.append( dtToString( todo->dtStart()) ); | 865 | list.append( dtToString( todo->dtStart()) ); |
758 | } else | 866 | } else |
759 | list.append( QString() ); | 867 | list.append( QString() ); |
760 | 868 | ||
761 | if ( todo->hasDueDate() ) { | 869 | if ( todo->hasDueDate() ) { |
762 | QTime tim; | 870 | QTime tim; |
763 | if ( todo->doesFloat()) { | 871 | if ( todo->doesFloat()) { |
764 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; | 872 | list.append( dtToString( QDateTime(todo->dtDue().date(),QTime( 0,0,0 )), false)) ; |
765 | } else { | 873 | } else { |
766 | list.append( dtToString(todo->dtDue() ) ); | 874 | list.append( dtToString(todo->dtDue() ) ); |
767 | } | 875 | } |
768 | } else | 876 | } else |
769 | list.append( QString() ); | 877 | list.append( QString() ); |
770 | 878 | ||
771 | if ( todo->isCompleted() ) { | 879 | if ( todo->isCompleted() ) { |
772 | list.append( dtToString( todo->completed()) ); | 880 | list.append( dtToString( todo->completed()) ); |
773 | list.append( "0" ); // yes 0 == completed | 881 | list.append( "0" ); // yes 0 == completed |
774 | } else { | 882 | } else { |
775 | list.append( dtToString( todo->completed()) ); | 883 | list.append( dtToString( todo->completed()) ); |
776 | list.append( "1" ); | 884 | list.append( "1" ); |
777 | } | 885 | } |
778 | list.append( QString::number( todo->priority() )); | 886 | list.append( QString::number( todo->priority() )); |
779 | if( ! todo->summary().isEmpty() ) | 887 | if( ! todo->summary().isEmpty() ) |
780 | list.append( todo->summary() ); | 888 | list.append( todo->summary() ); |
781 | else | 889 | else |
782 | list.append( "" ); | 890 | list.append( "" ); |
783 | if (! todo->description().isEmpty() ) | 891 | if (! todo->description().isEmpty() ) |
784 | list.append( todo->description() ); | 892 | list.append( todo->description() ); |
785 | else | 893 | else |
786 | list.append( "" ); | 894 | list.append( "" ); |
787 | for(QStringList::Iterator it=list.begin(); | 895 | for(QStringList::Iterator it=list.begin(); |
788 | it!=list.end(); ++it){ | 896 | it!=list.end(); ++it){ |
789 | QString& s = (*it); | 897 | QString& s = (*it); |
790 | s.replace(QRegExp("\""), "\"\""); | 898 | s.replace(QRegExp("\""), "\"\""); |
791 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ | 899 | if(s.contains(QRegExp("[,\"\r\n]")) || s.stripWhiteSpace() != s){ |
792 | s.prepend('\"'); | 900 | s.prepend('\"'); |
793 | s.append('\"'); | 901 | s.append('\"'); |
794 | } else if(s.isEmpty() && !s.isNull()){ | 902 | } else if(s.isEmpty() && !s.isNull()){ |
795 | s = "\"\""; | 903 | s = "\"\""; |
796 | } | 904 | } |
797 | } | 905 | } |
798 | return list.join(","); | 906 | return list.join(","); |
799 | #endif | 907 | #endif |
800 | } | 908 | } |
909 | void PhoneFormat::afterSave( Incidence* inc) | ||
910 | { | ||
911 | uint csum; | ||
912 | if ( inc->type() == "Event") | ||
913 | csum = PhoneFormat::getCsumEvent( (Event*) inc ); | ||
914 | else | ||
915 | csum = PhoneFormat::getCsumTodo( (Todo*) inc ); | ||
916 | inc->setCsum( mProfileName, QString::number( csum )); | ||
917 | inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); | ||
918 | |||
919 | } | ||
801 | bool PhoneFormat::save( Calendar *calendar) | 920 | bool PhoneFormat::save( Calendar *calendar) |
802 | { | 921 | { |
803 | GSM_StateMachines; | 922 | GSM_StateMachines; |
804 | qDebug(" save "); | 923 | qDebug(" save "); |
805 | s.opened = false; | 924 | s.opened = false; |
806 | s.msg = NULL; | 925 | s.msg = NULL; |
807 | s.ConfigNum = 0; | 926 | s.ConfigNum = 0; |
808 | QLabel status ( i18n("Writing data. Opening device ..."), 0 ); | 927 | QLabel status ( i18n("Writing data. Opening device ..."), 0 ); |
809 | int w = status.sizeHint().width()+20 ; | 928 | int w = status.sizeHint().width()+20 ; |
810 | if ( w < 200 ) w = 200; | 929 | if ( w < 200 ) w = 200; |
811 | int h = status.sizeHint().height()+20 ; | 930 | int h = status.sizeHint().height()+20 ; |
812 | int dw = QApplication::desktop()->width(); | 931 | int dw = QApplication::desktop()->width(); |
813 | int dh = QApplication::desktop()->height(); | 932 | int dh = QApplication::desktop()->height(); |
814 | status.setCaption(i18n("Writing DTM Data") ); | 933 | status.setCaption(i18n("Writing DTM Data") ); |
815 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); | 934 | status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); |
816 | status.show(); | 935 | status.show(); |
817 | status.raise(); | 936 | status.raise(); |
818 | qApp->processEvents(); | 937 | qApp->processEvents(); |
819 | 938 | ||
820 | int error=initDevice(&s); | 939 | int error=initDevice(&s); |
821 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); | 940 | qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); |
822 | if ( error != ERR_NONE ) | 941 | if ( error != ERR_NONE ) |
823 | return false; | 942 | return false; |
824 | GSM_Phone_Functions*Phone; | 943 | GSM_Phone_Functions*Phone; |
825 | GSM_CalendarEntryNote; | 944 | GSM_CalendarEntryNote; |
826 | bool start = true; | 945 | bool start = true; |
827 | Phone=s.Phone.Functions; | 946 | Phone=s.Phone.Functions; |
828 | bool gshutdown = false; | 947 | bool gshutdown = false; |
829 | QPtrList<Event> er = calendar->rawEvents(); | 948 | QPtrList<Event> er = calendar->rawEvents(); |
830 | Event* ev = er.first(); | 949 | Event* ev = er.first(); |
831 | QString message = i18n("Processing event # "); | 950 | QString message = i18n("Processing event # "); |
832 | int procCount = 0; | 951 | int procCount = 0; |
833 | while ( ev ) { | 952 | while ( ev ) { |
834 | //qDebug("i %d ", ++i); | 953 | //qDebug("i %d ", ++i); |
835 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one | 954 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one |
836 | 955 | ||
837 | status.setText ( message + QString::number ( ++procCount ) ); | 956 | status.setText ( message + QString::number ( ++procCount ) ); |
838 | qApp->processEvents(); | 957 | qApp->processEvents(); |
839 | event2GSM( ev, &Note ); | 958 | event2GSM( ev, &Note ); |
840 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 959 | if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
841 | error = Phone->DeleteCalendar(&s, &Note); | 960 | error = Phone->DeleteCalendar(&s, &Note); |
842 | } | 961 | } |
843 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new | 962 | else if ( ev->getID(mProfileName).isEmpty() ) { // add new |
844 | // we have to do this later after deleting | 963 | // we have to do this later after deleting |
845 | 964 | ||
846 | } | 965 | } |
847 | else { // change existing | 966 | else { // change existing |
848 | error = Phone->AddCalendar(&s, &Note); | 967 | error = Phone->SetCalendar(&s, &Note); |
849 | } | 968 | } |
850 | } | 969 | } |
851 | ev = er.next(); | 970 | ev = er.next(); |
852 | } | 971 | } |
853 | ev = er.first(); | 972 | ev = er.first(); |
854 | // pending get empty slots | 973 | // pending get empty slots |
855 | while ( ev ) { | 974 | while ( ev ) { |
856 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 975 | if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
857 | if ( ev->getID(mProfileName).isEmpty() ) { | 976 | if ( ev->getID(mProfileName).isEmpty() ) { |
858 | status.setText ( message + QString::number ( ++procCount ) ); | 977 | status.setText ( message + QString::number ( ++procCount ) ); |
859 | qApp->processEvents(); | 978 | qApp->processEvents(); |
860 | int newID ;//= pending | 979 | //int newID ;//= pending |
861 | ev->setID(mProfileName, QString::number( newID )); | 980 | //ev->setID(mProfileName, QString::number( newID )); |
862 | event2GSM( ev, &Note ); | 981 | event2GSM( ev, &Note ); |
982 | Note.Location = 0; | ||
863 | error = Phone->AddCalendar(&s, &Note); | 983 | error = Phone->AddCalendar(&s, &Note); |
984 | ev->setID( mProfileName, QString::number( Note.Location ) ); | ||
985 | afterSave( ev ); | ||
986 | } else { | ||
987 | afterSave( ev ); // setting temp sync stat for changed items | ||
864 | } | 988 | } |
865 | } | 989 | } |
866 | ev = er.next(); | 990 | ev = er.next(); |
867 | } | 991 | } |
868 | GSM_ToDoEntry ToDoEntry; | 992 | GSM_ToDoEntry ToDoEntry; |
869 | QPtrList<Todo> tl = calendar->rawTodos(); | 993 | QPtrList<Todo> tl = calendar->rawTodos(); |
870 | Todo* to = tl.first(); | 994 | Todo* to = tl.first(); |
871 | 995 | ||
872 | message = i18n("Processing todo # "); | 996 | message = i18n("Processing todo # "); |
873 | procCount = 0; | 997 | procCount = 0; |
874 | while ( to ) { | 998 | while ( to ) { |
875 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { | 999 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { |
876 | status.setText ( message + QString::number ( ++procCount ) ); | 1000 | status.setText ( message + QString::number ( ++procCount ) ); |
877 | qApp->processEvents(); | 1001 | qApp->processEvents(); |
878 | todo2GSM( to, &ToDoEntry ); | 1002 | todo2GSM( to, &ToDoEntry ); |
879 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete | 1003 | if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete |
880 | error=Phone->DeleteToDo(&s,&ToDoEntry); | 1004 | error=Phone->DeleteToDo(&s,&ToDoEntry); |
881 | } | 1005 | } |
882 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new | 1006 | else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new |
883 | ; | 1007 | ; |
884 | } | 1008 | } |
885 | else { // change existing | 1009 | else { // change existing |
886 | error=Phone->AddToDo(&s,&ToDoEntry); | 1010 | error=Phone->AddToDo(&s,&ToDoEntry); |
887 | } | 1011 | } |
888 | } | 1012 | } |
889 | to = tl.next(); | 1013 | to = tl.next(); |
890 | } | 1014 | } |
891 | 1015 | ||
892 | // pending get empty slots | 1016 | // pending get empty slots |
893 | to = tl.first(); | 1017 | to = tl.first(); |
894 | while ( to ) { | 1018 | while ( to ) { |
895 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { | 1019 | if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { |
896 | if ( to->getID(mProfileName).isEmpty() ) { | 1020 | if ( to->getID(mProfileName).isEmpty() ) { |
897 | status.setText ( message + QString::number ( ++procCount ) ); | 1021 | status.setText ( message + QString::number ( ++procCount ) ); |
898 | qApp->processEvents(); | 1022 | qApp->processEvents(); |
899 | int newID ;//= pending | 1023 | //int newID ;//= pending |
900 | to->setID(mProfileName, QString::number( newID )); | 1024 | //to->setID(mProfileName, QString::number( newID )); |
901 | todo2GSM( to, &ToDoEntry ); | 1025 | todo2GSM( to, &ToDoEntry ); |
1026 | ToDoEntry.Location = 0; | ||
902 | error=Phone->AddToDo(&s,&ToDoEntry); | 1027 | error=Phone->AddToDo(&s,&ToDoEntry); |
1028 | to->setID(mProfileName, QString::number( ToDoEntry.Location )); | ||
1029 | afterSave( to ); | ||
1030 | qDebug("New Todo. Location %d ",ToDoEntry.Location ); | ||
1031 | } else { | ||
1032 | afterSave( to ); | ||
903 | } | 1033 | } |
904 | } | 1034 | } |
905 | to = tl.next(); | 1035 | to = tl.next(); |
906 | } | 1036 | } |
907 | return true; | 1037 | return true; |
908 | } | 1038 | } |
909 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) | 1039 | QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) |
910 | { | 1040 | { |
911 | QString datestr; | 1041 | QString datestr; |
912 | QString timestr; | 1042 | QString timestr; |
913 | int offset = KGlobal::locale()->localTimeOffset( dti ); | 1043 | int offset = KGlobal::locale()->localTimeOffset( dti ); |
914 | QDateTime dt; | 1044 | QDateTime dt; |
915 | if (useTZ) | 1045 | if (useTZ) |
916 | dt = dti.addSecs ( -(offset*60)); | 1046 | dt = dti.addSecs ( -(offset*60)); |
917 | else | 1047 | else |
918 | dt = dti; | 1048 | dt = dti; |
919 | if(dt.date().isValid()){ | 1049 | if(dt.date().isValid()){ |
920 | const QDate& date = dt.date(); | 1050 | const QDate& date = dt.date(); |
921 | datestr.sprintf("%04d%02d%02d", | 1051 | datestr.sprintf("%04d%02d%02d", |
922 | date.year(), date.month(), date.day()); | 1052 | date.year(), date.month(), date.day()); |
923 | } | 1053 | } |
924 | if(dt.time().isValid()){ | 1054 | if(dt.time().isValid()){ |
925 | const QTime& time = dt.time(); | 1055 | const QTime& time = dt.time(); |
926 | timestr.sprintf("T%02d%02d%02d", | 1056 | timestr.sprintf("T%02d%02d%02d", |
927 | time.hour(), time.minute(), time.second()); | 1057 | time.hour(), time.minute(), time.second()); |
928 | } | 1058 | } |
929 | return datestr + timestr; | 1059 | return datestr + timestr; |
930 | } | 1060 | } |
931 | QString PhoneFormat::getEventString( Event* event ) | 1061 | QString PhoneFormat::getEventString( Event* event ) |
932 | { | 1062 | { |
933 | #if 0 | 1063 | #if 0 |
934 | QStringList list; | 1064 | QStringList list; |
935 | list.append( QString::number(event->zaurusId() ) ); | 1065 | list.append( QString::number(event->zaurusId() ) ); |
936 | list.append( event->categories().join(",") ); | 1066 | list.append( event->categories().join(",") ); |
937 | if ( !event->summary().isEmpty() ) | 1067 | if ( !event->summary().isEmpty() ) |
938 | list.append( event->summary() ); | 1068 | list.append( event->summary() ); |
939 | else | 1069 | else |
940 | list.append("" ); | 1070 | list.append("" ); |
941 | if ( !event->location().isEmpty() ) | 1071 | if ( !event->location().isEmpty() ) |
942 | list.append( event->location() ); | 1072 | list.append( event->location() ); |
943 | else | 1073 | else |
944 | list.append("" ); | 1074 | list.append("" ); |
945 | if ( !event->description().isEmpty() ) | 1075 | if ( !event->description().isEmpty() ) |
946 | list.append( event->description() ); | 1076 | list.append( event->description() ); |
947 | else | 1077 | else |
948 | list.append( "" ); | 1078 | list.append( "" ); |
949 | if ( event->doesFloat () ) { | 1079 | if ( event->doesFloat () ) { |
950 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); | 1080 | list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); |
951 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 | 1081 | list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 |
952 | list.append( "1" ); | 1082 | list.append( "1" ); |
953 | 1083 | ||
954 | } | 1084 | } |
955 | else { | 1085 | else { |
956 | list.append( dtToString( event->dtStart()) ); | 1086 | list.append( dtToString( event->dtStart()) ); |
957 | list.append( dtToString( event->dtEnd()) ); //6 | 1087 | list.append( dtToString( event->dtEnd()) ); //6 |
958 | list.append( "0" ); | 1088 | list.append( "0" ); |
959 | } | 1089 | } |
960 | bool noAlarm = true; | 1090 | bool noAlarm = true; |
961 | if ( event->alarms().count() > 0 ) { | 1091 | if ( event->alarms().count() > 0 ) { |
962 | Alarm * al = event->alarms().first(); | 1092 | Alarm * al = event->alarms().first(); |
963 | if ( al->enabled() ) { | 1093 | if ( al->enabled() ) { |
964 | noAlarm = false; | 1094 | noAlarm = false; |
965 | list.append( "0" ); // yes, 0 == alarm | 1095 | list.append( "0" ); // yes, 0 == alarm |
966 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); | 1096 | list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); |
967 | if ( al->type() == Alarm::Audio ) | 1097 | if ( al->type() == Alarm::Audio ) |
968 | list.append( "1" ); // type audio | 1098 | list.append( "1" ); // type audio |
969 | else | 1099 | else |
970 | list.append( "0" ); // type silent | 1100 | list.append( "0" ); // type silent |
971 | } | 1101 | } |
972 | } | 1102 | } |
973 | if ( noAlarm ) { | 1103 | if ( noAlarm ) { |
974 | list.append( "1" ); // yes, 1 == no alarm | 1104 | list.append( "1" ); // yes, 1 == no alarm |
975 | list.append( "0" ); // no alarm offset | 1105 | list.append( "0" ); // no alarm offset |
976 | list.append( "1" ); // type | 1106 | list.append( "1" ); // type |
977 | } | 1107 | } |
978 | // next is: 11 | 1108 | // next is: 11 |
979 | // next is: 11-16 are recurrence | 1109 | // next is: 11-16 are recurrence |
980 | Recurrence* rec = event->recurrence(); | 1110 | Recurrence* rec = event->recurrence(); |
981 | 1111 | ||
982 | bool writeEndDate = false; | 1112 | bool writeEndDate = false; |
983 | switch ( rec->doesRecur() ) | 1113 | switch ( rec->doesRecur() ) |
984 | { | 1114 | { |
985 | case Recurrence::rDaily: // 0 | 1115 | case Recurrence::rDaily: // 0 |
986 | list.append( "0" ); | 1116 | list.append( "0" ); |
987 | list.append( QString::number( rec->frequency() ));//12 | 1117 | list.append( QString::number( rec->frequency() ));//12 |
988 | list.append( "0" ); | 1118 | list.append( "0" ); |
989 | list.append( "0" ); | 1119 | list.append( "0" ); |
990 | writeEndDate = true; | 1120 | writeEndDate = true; |
991 | break; | 1121 | break; |
992 | case Recurrence::rWeekly:// 1 | 1122 | case Recurrence::rWeekly:// 1 |
993 | list.append( "1" ); | 1123 | list.append( "1" ); |
994 | list.append( QString::number( rec->frequency()) );//12 | 1124 | list.append( QString::number( rec->frequency()) );//12 |
995 | list.append( "0" ); | 1125 | list.append( "0" ); |
996 | { | 1126 | { |
997 | int days = 0; | 1127 | int days = 0; |
998 | QBitArray weekDays = rec->days(); | 1128 | QBitArray weekDays = rec->days(); |
999 | int i; | 1129 | int i; |
1000 | for( i = 1; i <= 7; ++i ) { | 1130 | for( i = 1; i <= 7; ++i ) { |
1001 | if ( weekDays[i-1] ) { | 1131 | if ( weekDays[i-1] ) { |
1002 | days += 1 << (i-1); | 1132 | days += 1 << (i-1); |
1003 | } | 1133 | } |
1004 | } | 1134 | } |
1005 | list.append( QString::number( days ) ); | 1135 | list.append( QString::number( days ) ); |
1006 | } | 1136 | } |
1007 | //pending weekdays | 1137 | //pending weekdays |
1008 | writeEndDate = true; | 1138 | writeEndDate = true; |
1009 | 1139 | ||
1010 | break; | 1140 | break; |
1011 | case Recurrence::rMonthlyPos:// 2 | 1141 | case Recurrence::rMonthlyPos:// 2 |
1012 | list.append( "2" ); | 1142 | list.append( "2" ); |
1013 | list.append( QString::number( rec->frequency()) );//12 | 1143 | list.append( QString::number( rec->frequency()) );//12 |
1014 | 1144 | ||
1015 | writeEndDate = true; | 1145 | writeEndDate = true; |
1016 | { | 1146 | { |
1017 | int count = 1; | 1147 | int count = 1; |
1018 | QPtrList<Recurrence::rMonthPos> rmp; | 1148 | QPtrList<Recurrence::rMonthPos> rmp; |
1019 | rmp = rec->monthPositions(); | 1149 | rmp = rec->monthPositions(); |
1020 | if ( rmp.first()->negative ) | 1150 | if ( rmp.first()->negative ) |
1021 | count = 5 - rmp.first()->rPos - 1; | 1151 | count = 5 - rmp.first()->rPos - 1; |
1022 | else | 1152 | else |
1023 | count = rmp.first()->rPos - 1; | 1153 | count = rmp.first()->rPos - 1; |
1024 | list.append( QString::number( count ) ); | 1154 | list.append( QString::number( count ) ); |
1025 | 1155 | ||
1026 | } | 1156 | } |
1027 | 1157 | ||
1028 | list.append( "0" ); | 1158 | list.append( "0" ); |
1029 | break; | 1159 | break; |
1030 | case Recurrence::rMonthlyDay:// 3 | 1160 | case Recurrence::rMonthlyDay:// 3 |
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h index 1472880..7b7dd04 100644 --- a/libkcal/phoneformat.h +++ b/libkcal/phoneformat.h | |||
@@ -1,63 +1,65 @@ | |||
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 | #ifndef PHONEFORMAT_H | 21 | #ifndef PHONEFORMAT_H |
22 | #define PHONEFORMAT_H | 22 | #define PHONEFORMAT_H |
23 | 23 | ||
24 | #include <qstring.h> | 24 | #include <qstring.h> |
25 | 25 | ||
26 | #include "scheduler.h" | 26 | #include "scheduler.h" |
27 | 27 | ||
28 | #include "calformat.h" | 28 | #include "calformat.h" |
29 | extern "C" { | 29 | extern "C" { |
30 | #include "../gammu/emb/common/gammu.h" | 30 | #include "../gammu/emb/common/gammu.h" |
31 | } | 31 | } |
32 | namespace KCal { | 32 | namespace KCal { |
33 | 33 | ||
34 | /** | 34 | /** |
35 | This class implements the calendar format used by Phone. | 35 | This class implements the calendar format used by Phone. |
36 | */ | 36 | */ |
37 | class Event; | 37 | class Event; |
38 | class Todo; | 38 | class Todo; |
39 | class PhoneFormat : public QObject { | 39 | class PhoneFormat : public QObject { |
40 | public: | 40 | public: |
41 | /** Create new iCalendar format. */ | 41 | /** Create new iCalendar format. */ |
42 | PhoneFormat(QString profileName, QString device,QString connection, QString model); | 42 | PhoneFormat(QString profileName, QString device,QString connection, QString model); |
43 | virtual ~PhoneFormat(); | 43 | virtual ~PhoneFormat(); |
44 | 44 | ||
45 | bool load( Calendar * ,Calendar * ); | 45 | bool load( Calendar * ,Calendar * ); |
46 | bool save( Calendar * ); | 46 | bool save( Calendar * ); |
47 | bool fromString( Calendar *, const QString & ); | 47 | bool fromString( Calendar *, const QString & ); |
48 | QString toString( Calendar * ); | 48 | QString toString( Calendar * ); |
49 | static ulong getCsum( const QStringList & ); | 49 | static ulong getCsum( const QStringList & ); |
50 | 50 | static ulong getCsumTodo( Todo* to ); | |
51 | static ulong getCsumEvent( Event* ev ); | ||
51 | private: | 52 | private: |
52 | void event2GSM( Event* ev, GSM_CalendarEntry*Note ); | 53 | void event2GSM( Event* ev, GSM_CalendarEntry*Note ); |
53 | void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); | 54 | void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); |
54 | int initDevice(GSM_StateMachine *s); | 55 | int initDevice(GSM_StateMachine *s); |
55 | QString getEventString( Event* ); | 56 | QString getEventString( Event* ); |
56 | QString getTodoString( Todo* ); | 57 | QString getTodoString( Todo* ); |
57 | QString dtToGSM( const QDateTime& dt, bool useTZ = true ); | 58 | QString dtToGSM( const QDateTime& dt, bool useTZ = true ); |
58 | QString mProfileName, mDevice, mConnection, mModel; | 59 | QString mProfileName, mDevice, mConnection, mModel; |
60 | void afterSave( Incidence* ); | ||
59 | }; | 61 | }; |
60 | 62 | ||
61 | } | 63 | } |
62 | 64 | ||
63 | #endif | 65 | #endif |