summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/phoneformat.cpp8
-rw-r--r--libkcal/sharpformat.cpp2
2 files changed, 8 insertions, 2 deletions
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index 94744fb..bc1b863 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,654 +1,658 @@
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
47using namespace KCal; 47using namespace KCal;
48 48
49class PhoneParser : public QObject 49class PhoneParser : public QObject
50{ 50{
51public: 51public:
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"; 83 QString completedString = "no";
84 for (j=0;j<ToDo->EntriesNum;j++) { 84 for (j=0;j<ToDo->EntriesNum;j++) {
85 85
86 //qDebug(" for todo %d",ToDo->Location ); 86 //qDebug(" for todo %d",ToDo->Location );
87 switch (ToDo->Entries[j].EntryType) { 87 switch (ToDo->Entries[j].EntryType) {
88 case TODO_END_DATETIME: 88 case TODO_END_DATETIME:
89 dtp = &ToDo->Entries[j].Date ; 89 dtp = &ToDo->Entries[j].Date ;
90 todo->setDtDue (fromGSM ( dtp )); 90 todo->setDtDue (fromGSM ( dtp ));
91 break; 91 break;
92 case TODO_COMPLETED: 92 case TODO_COMPLETED:
93 if ( ToDo->Entries[j].Number == 1 ) { 93 if ( ToDo->Entries[j].Number == 1 ) {
94 todo->setCompleted( true ); 94 todo->setCompleted( true );
95 completedString = "yes"; 95 completedString = "yes";
96 } 96 }
97 else { 97 else {
98 todo->setCompleted( false ); 98 todo->setCompleted( false );
99 } 99 }
100 break; 100 break;
101 case TODO_ALARM_DATETIME: 101 case TODO_ALARM_DATETIME:
102 dtp = &ToDo->Entries[j].Date ; 102 dtp = &ToDo->Entries[j].Date ;
103 alarm = true; 103 alarm = true;
104 alarmDt = fromGSM ( dtp ); 104 alarmDt = fromGSM ( dtp );
105 break; 105 break;
106 case TODO_SILENT_ALARM_DATETIME: 106 case TODO_SILENT_ALARM_DATETIME:
107 dtp = &ToDo->Entries[j].Date ; 107 dtp = &ToDo->Entries[j].Date ;
108 alarm = true; 108 alarm = true;
109 alarmDt = fromGSM ( dtp ); 109 alarmDt = fromGSM ( dtp );
110 break; 110 break;
111 case TODO_TEXT: 111 case TODO_TEXT:
112 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); 112 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text ));
113 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); 113 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text )));
114 break; 114 break;
115 case TODO_PRIVATE: 115 case TODO_PRIVATE:
116 if ( ToDo->Entries[j].Number == 1 ) 116 if ( ToDo->Entries[j].Number == 1 )
117 todo->setSecrecy( Incidence::SecrecyPrivate ); 117 todo->setSecrecy( Incidence::SecrecyPrivate );
118 else 118 else
119 todo->setSecrecy( Incidence::SecrecyPublic ); 119 todo->setSecrecy( Incidence::SecrecyPublic );
120 break; 120 break;
121 case TODO_CATEGORY: 121 case TODO_CATEGORY:
122 Category.Location = ToDo->Entries[j].Number; 122 Category.Location = ToDo->Entries[j].Number;
123 Category.Type = Category_ToDo; 123 Category.Type = Category_ToDo;
124 error=Phone->GetCategory(s, &Category); 124 error=Phone->GetCategory(s, &Category);
125 if (error == ERR_NONE) { 125 if (error == ERR_NONE) {
126 QStringList cat = todo->categories(); 126 QStringList cat = todo->categories();
127 QString nCat = QString ( (const char*)Category.Name ); 127 QString nCat = QString ( (const char*)Category.Name );
128 if ( !nCat.isEmpty() ) 128 if ( !nCat.isEmpty() )
129 if ( !cat.contains( nCat )) { 129 if ( !cat.contains( nCat )) {
130 cat << nCat; 130 cat << nCat;
131 todo->setCategories( cat ); 131 todo->setCategories( cat );
132 } 132 }
133 } 133 }
134 break; 134 break;
135 case TODO_CONTACTID: 135 case TODO_CONTACTID:
136#if 0 136#if 0
137 // not supported 137 // not supported
138 entry.Location = ToDo->Entries[j].Number; 138 entry.Location = ToDo->Entries[j].Number;
139 entry.MemoryType = MEM_ME; 139 entry.MemoryType = MEM_ME;
140 error=Phone->GetMemory(s, &entry); 140 error=Phone->GetMemory(s, &entry);
141 if (error == ERR_NONE) { 141 if (error == ERR_NONE) {
142 name = GSM_PhonebookGetEntryName(&entry); 142 name = GSM_PhonebookGetEntryName(&entry);
143 if (name != NULL) { 143 if (name != NULL) {
144 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 144 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
145 } else { 145 } else {
146 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 146 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
147 } 147 }
148 } else { 148 } else {
149 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 149 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
150 } 150 }
151#endif 151#endif
152 break; 152 break;
153 case TODO_PHONE: 153 case TODO_PHONE:
154#if 0 154#if 0
155 // not supported 155 // not supported
156 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 156 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
157#endif 157#endif
158 break; 158 break;
159 } 159 }
160 } 160 }
161 QString alarmString = ""; 161 QString alarmString = "na";
162 if ( alarm ) { 162 if ( alarm ) {
163 Alarm *alarm; 163 Alarm *alarm;
164 if ( todo->alarms().count() > 0 ) 164 if ( todo->alarms().count() > 0 )
165 alarm = todo->alarms().first(); 165 alarm = todo->alarms().first();
166 else { 166 else {
167 alarm = new Alarm( todo ); 167 alarm = new Alarm( todo );
168 todo->addAlarm( alarm ); 168 todo->addAlarm( alarm );
169 } 169 }
170 alarm->setType( Alarm::Audio ); 170 alarm->setType( Alarm::Audio );
171 alarm->setEnabled( true ); 171 alarm->setEnabled( true );
172 int alarmOffset = alarmDt.secsTo( todo->dtStart() ); 172 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
173 alarm->setStartOffset( -alarmOffset ); 173 alarm->setStartOffset( -alarmOffset );
174 alarmString = QString::number( alarmOffset ); 174 alarmString = QString::number( alarmOffset );
175 } else { 175 } else {
176 Alarm *alarm; 176 Alarm *alarm;
177 if ( todo->alarms().count() > 0 ) { 177 if ( todo->alarms().count() > 0 ) {
178 alarm = todo->alarms().first(); 178 alarm = todo->alarms().first();
179 alarm->setType( Alarm::Audio );
180 alarm->setStartOffset( -60*15 );
179 alarm->setEnabled( false ); 181 alarm->setEnabled( false );
180 } 182 }
181 } 183 }
182 // csum ***************************************** 184 // csum *****************************************
183 QStringList attList; 185 QStringList attList;
184 uint cSum; 186 uint cSum;
185 if ( todo->hasDueDate() ) 187 if ( todo->hasDueDate() )
186 attList << dtToString ( todo->dtDue() ); 188 attList << dtToString ( todo->dtDue() );
187 attList << QString::number( id ); 189 attList << QString::number( id );
188 attList << todo->summary(); 190 attList << todo->summary();
189 attList << completedString; 191 attList << completedString;
190 attList << QString::number( todo->priority() ); 192 attList << QString::number( todo->priority() );
191 attList << alarmString; 193 attList << alarmString;
192 attList << todo->categoriesStr(); 194 attList << todo->categoriesStr();
193 attList << todo->secrecyStr(); 195 attList << todo->secrecyStr();
194 cSum = PhoneFormat::getCsum(attList ); 196 cSum = PhoneFormat::getCsum(attList );
195 todo->setCsum( mProfileName, QString::number( cSum )); 197 todo->setCsum( mProfileName, QString::number( cSum ));
196 mCalendar->addTodo( todo); 198 mCalendar->addTodo( todo);
197 199
198 return true; 200 return true;
199 } 201 }
200 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) 202 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note)
201 { 203 {
202 204
203 int id = Note->Location; 205 int id = Note->Location;
204 Event *event; 206 Event *event;
205 event = existingCalendar->event( mProfileName ,QString::number( id ) ); 207 event = existingCalendar->event( mProfileName ,QString::number( id ) );
206 if ( event ) 208 if ( event )
207 event = (Event*)event->clone(); 209 event = (Event*)event->clone();
208 else 210 else
209 event = new Event; 211 event = new Event;
210 event->setID( mProfileName,QString::number( id ) ); 212 event->setID( mProfileName,QString::number( id ) );
211 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 213 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
212 214
213 215
214 int i = 0; 216 int i = 0;
215 bool repeating = false; 217 bool repeating = false;
216 int repeat_dayofweek = -1; 218 int repeat_dayofweek = -1;
217 int repeat_day = -1; 219 int repeat_day = -1;
218 int repeat_weekofmonth = -1; 220 int repeat_weekofmonth = -1;
219 int repeat_month = -1; 221 int repeat_month = -1;
220 int repeat_frequency = -1; 222 int repeat_frequency = -1;
221 int rec_type = -1; 223 int rec_type = -1;
222 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 224 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
223 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 225 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
224 GSM_DateTime* dtp; 226 GSM_DateTime* dtp;
225 bool alarm = false; 227 bool alarm = false;
226 QDateTime alarmDt; 228 QDateTime alarmDt;
227 repeat_startdate.Day= 0; 229 repeat_startdate.Day= 0;
228 repeat_stopdate.Day = 0; 230 repeat_stopdate.Day = 0;
229 for (i=0;i<Note->EntriesNum;i++) { 231 for (i=0;i<Note->EntriesNum;i++) {
230 232
231 //qDebug(" for ev"); 233 //qDebug(" for ev");
232 switch (Note->Entries[i].EntryType) { 234 switch (Note->Entries[i].EntryType) {
233 case CAL_START_DATETIME: 235 case CAL_START_DATETIME:
234 dtp = &Note->Entries[i].Date ; 236 dtp = &Note->Entries[i].Date ;
235 if ( dtp->Hour > 24 ) { 237 if ( dtp->Hour > 24 ) {
236 event->setFloats( true ); 238 event->setFloats( true );
237 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 239 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
238 } else { 240 } else {
239 event->setDtStart (fromGSM ( dtp )); 241 event->setDtStart (fromGSM ( dtp ));
240 242
241 } 243 }
242 break; 244 break;
243 case CAL_END_DATETIME: 245 case CAL_END_DATETIME:
244 dtp = &Note->Entries[i].Date ; 246 dtp = &Note->Entries[i].Date ;
245 if ( dtp->Hour > 24 ) { 247 if ( dtp->Hour > 24 ) {
246 event->setFloats( true ); 248 event->setFloats( true );
247 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 249 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
248 } else { 250 } else {
249 event->setDtEnd (fromGSM ( dtp )); 251 event->setDtEnd (fromGSM ( dtp ));
250 } 252 }
251 break; 253 break;
252 case CAL_ALARM_DATETIME: 254 case CAL_ALARM_DATETIME:
253 dtp = &Note->Entries[i].Date ; 255 dtp = &Note->Entries[i].Date ;
254 alarm = true; 256 alarm = true;
255 alarmDt = fromGSM ( dtp ); 257 alarmDt = fromGSM ( dtp );
256 break; 258 break;
257 case CAL_SILENT_ALARM_DATETIME: 259 case CAL_SILENT_ALARM_DATETIME:
258 dtp = &Note->Entries[i].Date ; 260 dtp = &Note->Entries[i].Date ;
259 alarm = true; 261 alarm = true;
260 alarmDt = fromGSM ( dtp ); 262 alarmDt = fromGSM ( dtp );
261 break; 263 break;
262 case CAL_RECURRANCE: 264 case CAL_RECURRANCE:
263 rec_type = Note->Entries[i].Number; 265 rec_type = Note->Entries[i].Number;
264 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); 266 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
265 break; 267 break;
266 case CAL_TEXT: 268 case CAL_TEXT:
267 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); 269 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) );
268 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); 270 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text )));
269 break; 271 break;
270 case CAL_LOCATION: 272 case CAL_LOCATION:
271 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); 273 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) ));
272 break; 274 break;
273 case CAL_PHONE: 275 case CAL_PHONE:
274 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 276 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
275 break; 277 break;
276 case CAL_PRIVATE: 278 case CAL_PRIVATE:
277 if ( Note->Entries[i].Number == 1 ) 279 if ( Note->Entries[i].Number == 1 )
278 event->setSecrecy( Incidence::SecrecyPrivate ); 280 event->setSecrecy( Incidence::SecrecyPrivate );
279 else 281 else
280 event->setSecrecy( Incidence::SecrecyPublic ); 282 event->setSecrecy( Incidence::SecrecyPublic );
281 283
282 break; 284 break;
283 case CAL_CONTACTID: 285 case CAL_CONTACTID:
284#if 0 286#if 0
285 entry.Location = Note->Entries[i].Number; 287 entry.Location = Note->Entries[i].Number;
286 entry.MemoryType = MEM_ME; 288 entry.MemoryType = MEM_ME;
287 error=Phone->GetMemory(&s, &entry); 289 error=Phone->GetMemory(&s, &entry);
288 if (error == ERR_NONE) { 290 if (error == ERR_NONE) {
289 name = GSM_PhonebookGetEntryName(&entry); 291 name = GSM_PhonebookGetEntryName(&entry);
290 if (name != NULL) { 292 if (name != NULL) {
291 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 293 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
292 } else { 294 } else {
293 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 295 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
294 } 296 }
295 } else { 297 } else {
296 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 298 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
297 } 299 }
298#endif 300#endif
299 break; 301 break;
300 case CAL_REPEAT_DAYOFWEEK: 302 case CAL_REPEAT_DAYOFWEEK:
301 repeat_dayofweek = Note->Entries[i].Number; 303 repeat_dayofweek = Note->Entries[i].Number;
302 repeating = true; 304 repeating = true;
303 break; 305 break;
304 case CAL_REPEAT_DAY: 306 case CAL_REPEAT_DAY:
305 repeat_day = Note->Entries[i].Number; 307 repeat_day = Note->Entries[i].Number;
306 repeating = true; 308 repeating = true;
307 break; 309 break;
308 case CAL_REPEAT_WEEKOFMONTH: 310 case CAL_REPEAT_WEEKOFMONTH:
309 repeat_weekofmonth = Note->Entries[i].Number; 311 repeat_weekofmonth = Note->Entries[i].Number;
310 repeating = true; 312 repeating = true;
311 break; 313 break;
312 case CAL_REPEAT_MONTH: 314 case CAL_REPEAT_MONTH:
313 repeat_month = Note->Entries[i].Number; 315 repeat_month = Note->Entries[i].Number;
314 repeating = true; 316 repeating = true;
315 break; 317 break;
316 case CAL_REPEAT_FREQUENCY: 318 case CAL_REPEAT_FREQUENCY:
317 repeat_frequency = Note->Entries[i].Number; 319 repeat_frequency = Note->Entries[i].Number;
318 repeating = true; 320 repeating = true;
319 break; 321 break;
320 case CAL_REPEAT_STARTDATE: 322 case CAL_REPEAT_STARTDATE:
321 repeat_startdate = Note->Entries[i].Date; 323 repeat_startdate = Note->Entries[i].Date;
322 repeating = true; 324 repeating = true;
323 break; 325 break;
324 case CAL_REPEAT_STOPDATE: 326 case CAL_REPEAT_STOPDATE:
325 repeat_stopdate = Note->Entries[i].Date; 327 repeat_stopdate = Note->Entries[i].Date;
326 repeating = true; 328 repeating = true;
327 break; 329 break;
328 } 330 }
329 } 331 }
330#if 0 332#if 0
331 event->setDescription( attList[4] ); 333 event->setDescription( attList[4] );
332 bool repeating = false; 334 bool repeating = false;
333 int repeat_dayofweek = -1; 335 int repeat_dayofweek = -1;
334 int repeat_day = -1; 336 int repeat_day = -1;
335 int repeat_weekofmonth = -1; 337 int repeat_weekofmonth = -1;
336 int repeat_month = -1; 338 int repeat_month = -1;
337 int repeat_frequency = -1; 339 int repeat_frequency = -1;
338 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 340 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
339 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 341 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
340 342
341#endif 343#endif
342 344
343 QString recurString = "no"; 345 QString recurString = "no";
344 if ( repeating ) { 346 if ( repeating ) {
345 recurString = "y"; 347 recurString = "y";
346 if ( repeat_dayofweek >= 0 ) 348 if ( repeat_dayofweek >= 0 )
347 recurString += "dow" + QString::number (repeat_dayofweek); 349 recurString += "dow" + QString::number (repeat_dayofweek);
348 if ( repeat_day >= 0 ) 350 if ( repeat_day >= 0 )
349 recurString += "d" + QString::number (repeat_day); 351 recurString += "d" + QString::number (repeat_day);
350 if ( repeat_weekofmonth >= 0 ) 352 if ( repeat_weekofmonth >= 0 )
351 recurString += "w" + QString::number (repeat_weekofmonth); 353 recurString += "w" + QString::number (repeat_weekofmonth);
352 if ( repeat_month >= 0 ) 354 if ( repeat_month >= 0 )
353 recurString += "m" + QString::number ( repeat_month ); 355 recurString += "m" + QString::number ( repeat_month );
354 if ( repeat_frequency >= 0 ) 356 if ( repeat_frequency >= 0 )
355 recurString += "f" + QString::number (repeat_frequency ); 357 recurString += "f" + QString::number (repeat_frequency );
356 358
357 int rtype = 0; 359 int rtype = 0;
358 // qDebug("recurs "); 360 // qDebug("recurs ");
359 QDate startDate, endDate; 361 QDate startDate, endDate;
360 if ( repeat_startdate.Day > 0 ) 362 if ( repeat_startdate.Day > 0 )
361 startDate = datefromGSM ( &repeat_startdate ); 363 startDate = datefromGSM ( &repeat_startdate );
362 else 364 else
363 startDate = event->dtStart().date(); 365 startDate = event->dtStart().date();
364 int freq = repeat_frequency; 366 int freq = repeat_frequency;
365 bool hasEndDate = false; 367 bool hasEndDate = false;
366 if ( repeat_stopdate.Day > 0 ) { 368 if ( repeat_stopdate.Day > 0 ) {
367 endDate = datefromGSM ( &repeat_stopdate ); 369 endDate = datefromGSM ( &repeat_stopdate );
368 hasEndDate = true; 370 hasEndDate = true;
369 } 371 }
370 372
371 uint weekDaysNum = repeat_dayofweek ; 373 uint weekDaysNum = repeat_dayofweek ;
372 374
373 QBitArray weekDays( 7 ); 375 QBitArray weekDays( 7 );
374 int i; 376 int i;
375 int bb = 1; 377 int bb = 1;
376 for( i = 1; i <= 7; ++i ) { 378 for( i = 1; i <= 7; ++i ) {
377 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 379 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
378 bb = 2 << (i-1); 380 bb = 2 << (i-1);
379 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 381 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
380 } 382 }
381 // qDebug("next "); 383 // qDebug("next ");
382 int pos = 0; 384 int pos = 0;
383 Recurrence *r = event->recurrence(); 385 Recurrence *r = event->recurrence();
384 /* 386 /*
385 0 daily; 387 0 daily;
386 1 weekly;x 388 1 weekly;x
387 2 monthpos;x 389 2 monthpos;x
388 3 monthlyday; 390 3 monthlyday;
389 4 rYearlyMont 391 4 rYearlyMont
390 bool repeating = false; 392 bool repeating = false;
391 int repeat_dayofweek = -1; 393 int repeat_dayofweek = -1;
392 int repeat_day = -1; 394 int repeat_day = -1;
393 int repeat_weekofmonth = -1; 395 int repeat_weekofmonth = -1;
394 int repeat_month = -1; 396 int repeat_month = -1;
395 int repeat_frequency = -1; 397 int repeat_frequency = -1;
396 */ 398 */
397 int dayOfWeek = startDate.dayOfWeek(); 399 int dayOfWeek = startDate.dayOfWeek();
398 if ( repeat_weekofmonth >= 0 ) { 400 if ( repeat_weekofmonth >= 0 ) {
399 rtype = 2; 401 rtype = 2;
400 pos = repeat_weekofmonth; 402 pos = repeat_weekofmonth;
401 if ( repeat_dayofweek >= 0 ) 403 if ( repeat_dayofweek >= 0 )
402 dayOfWeek = repeat_dayofweek; 404 dayOfWeek = repeat_dayofweek;
403 } else if ( repeat_dayofweek >= 0 ) { 405 } else if ( repeat_dayofweek >= 0 ) {
404 rtype = 1; 406 rtype = 1;
405 } if ( repeat_dayofweek >= 0 ) { 407 } if ( repeat_dayofweek >= 0 ) {
406 rtype = 1; 408 rtype = 1;
407 } 409 }
408 410
409 if ( rtype == 0 ) { 411 if ( rtype == 0 ) {
410 if ( hasEndDate ) r->setDaily( freq, endDate ); 412 if ( hasEndDate ) r->setDaily( freq, endDate );
411 else r->setDaily( freq, -1 ); 413 else r->setDaily( freq, -1 );
412 } else if ( rtype == 1 ) { 414 } else if ( rtype == 1 ) {
413 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 415 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
414 else r->setWeekly( freq, weekDays, -1 ); 416 else r->setWeekly( freq, weekDays, -1 );
415 } else if ( rtype == 3 ) { 417 } else if ( rtype == 3 ) {
416 if ( hasEndDate ) 418 if ( hasEndDate )
417 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 419 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
418 else 420 else
419 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 421 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
420 r->addMonthlyDay( startDate.day() ); 422 r->addMonthlyDay( startDate.day() );
421 } else if ( rtype == 2 ) { 423 } else if ( rtype == 2 ) {
422 if ( hasEndDate ) 424 if ( hasEndDate )
423 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 425 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
424 else 426 else
425 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 427 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
426 QBitArray days( 7 ); 428 QBitArray days( 7 );
427 days.fill( false ); 429 days.fill( false );
428 days.setBit( dayOfWeek - 1 ); 430 days.setBit( dayOfWeek - 1 );
429 r->addMonthlyPos( pos, days ); 431 r->addMonthlyPos( pos, days );
430 } else if ( rtype == 4 ) { 432 } else if ( rtype == 4 ) {
431 if ( hasEndDate ) 433 if ( hasEndDate )
432 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 434 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
433 else 435 else
434 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 436 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
435 r->addYearlyNum( startDate.month() ); 437 r->addYearlyNum( startDate.month() );
436 } 438 }
437 } else { 439 } else {
438 event->recurrence()->unsetRecurs(); 440 event->recurrence()->unsetRecurs();
439 } 441 }
440 442
441 QStringList categoryList; 443 QStringList categoryList;
442 categoryList << getCategory( Note ); 444 categoryList << getCategory( Note );
443 event->setCategories( categoryList ); 445 event->setCategories( categoryList );
444 QString alarmString = ""; 446 QString alarmString = "na";
445 // strange 0 semms to mean: alarm enabled 447 // strange 0 semms to mean: alarm enabled
446 if ( alarm ) { 448 if ( alarm ) {
447 Alarm *alarm; 449 Alarm *alarm;
448 if ( event->alarms().count() > 0 ) 450 if ( event->alarms().count() > 0 )
449 alarm = event->alarms().first(); 451 alarm = event->alarms().first();
450 else { 452 else {
451 alarm = new Alarm( event ); 453 alarm = new Alarm( event );
452 event->addAlarm( alarm ); 454 event->addAlarm( alarm );
453 } 455 }
454 alarm->setType( Alarm::Audio ); 456 alarm->setType( Alarm::Audio );
455 alarm->setEnabled( true ); 457 alarm->setEnabled( true );
456 int alarmOffset = alarmDt.secsTo( event->dtStart() ); 458 int alarmOffset = alarmDt.secsTo( event->dtStart() );
457 alarm->setStartOffset( -alarmOffset ); 459 alarm->setStartOffset( -alarmOffset );
458 alarmString = QString::number( alarmOffset ); 460 alarmString = QString::number( alarmOffset );
459 } else { 461 } else {
460 Alarm *alarm; 462 Alarm *alarm;
461 if ( event->alarms().count() > 0 ) { 463 if ( event->alarms().count() > 0 ) {
462 alarm = event->alarms().first(); 464 alarm = event->alarms().first();
465 alarm->setType( Alarm::Audio );
466 alarm->setStartOffset( -60*15 );
463 alarm->setEnabled( false ); 467 alarm->setEnabled( false );
464 } 468 }
465 } 469 }
466 // csum ***************************************** 470 // csum *****************************************
467 QStringList attList; 471 QStringList attList;
468 uint cSum; 472 uint cSum;
469 attList << dtToString ( event->dtStart() ); 473 attList << dtToString ( event->dtStart() );
470 attList << dtToString ( event->dtEnd() ); 474 attList << dtToString ( event->dtEnd() );
471 attList << QString::number( id ); 475 attList << QString::number( id );
472 attList << event->summary(); 476 attList << event->summary();
473 attList << event->location(); 477 attList << event->location();
474 attList << alarmString; 478 attList << alarmString;
475 attList << recurString; 479 attList << recurString;
476 attList << event->categoriesStr(); 480 attList << event->categoriesStr();
477 attList << event->secrecyStr(); 481 attList << event->secrecyStr();
478 cSum = PhoneFormat::getCsum(attList ); 482 cSum = PhoneFormat::getCsum(attList );
479 event->setCsum( mProfileName, QString::number( cSum )); 483 event->setCsum( mProfileName, QString::number( cSum ));
480 mCalendar->addEvent( event); 484 mCalendar->addEvent( event);
481 485
482 return true; 486 return true;
483 } 487 }
484 488
485 489
486 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) { 490 QDateTime fromGSM ( GSM_DateTime*dtp, bool useTz = true ) {
487 QDateTime dt; 491 QDateTime dt;
488 int y,m,t,h,min,sec; 492 int y,m,t,h,min,sec;
489 y = dtp->Year; 493 y = dtp->Year;
490 m = dtp->Month; 494 m = dtp->Month;
491 t = dtp->Day; 495 t = dtp->Day;
492 h = dtp->Hour; 496 h = dtp->Hour;
493 min = dtp->Minute; 497 min = dtp->Minute;
494 sec = dtp->Second; 498 sec = dtp->Second;
495 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 499 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
496 // dtp->Timezone: offset in hours 500 // dtp->Timezone: offset in hours
497 int offset = KGlobal::locale()->localTimeOffset( dt ); 501 int offset = KGlobal::locale()->localTimeOffset( dt );
498 if ( useTz ) 502 if ( useTz )
499 dt = dt.addSecs ( offset*60); 503 dt = dt.addSecs ( offset*60);
500 return dt; 504 return dt;
501 505
502 } 506 }
503 507
504 QString dtToString( const QDateTime& dti, bool useTZ = false ) 508 QString dtToString( const QDateTime& dti, bool useTZ = false )
505 { 509 {
506 QString datestr; 510 QString datestr;
507 QString timestr; 511 QString timestr;
508 int offset = KGlobal::locale()->localTimeOffset( dti ); 512 int offset = KGlobal::locale()->localTimeOffset( dti );
509 QDateTime dt; 513 QDateTime dt;
510 if (useTZ) 514 if (useTZ)
511 dt = dti.addSecs ( -(offset*60)); 515 dt = dti.addSecs ( -(offset*60));
512 else 516 else
513 dt = dti; 517 dt = dti;
514 if(dt.date().isValid()){ 518 if(dt.date().isValid()){
515 const QDate& date = dt.date(); 519 const QDate& date = dt.date();
516 datestr.sprintf("%04d%02d%02d", 520 datestr.sprintf("%04d%02d%02d",
517 date.year(), date.month(), date.day()); 521 date.year(), date.month(), date.day());
518 } 522 }
519 if(dt.time().isValid()){ 523 if(dt.time().isValid()){
520 const QTime& time = dt.time(); 524 const QTime& time = dt.time();
521 timestr.sprintf("T%02d%02d%02d", 525 timestr.sprintf("T%02d%02d%02d",
522 time.hour(), time.minute(), time.second()); 526 time.hour(), time.minute(), time.second());
523 } 527 }
524 return datestr + timestr; 528 return datestr + timestr;
525 } 529 }
526 QDate datefromGSM ( GSM_DateTime*dtp ) { 530 QDate datefromGSM ( GSM_DateTime*dtp ) {
527 return QDate ( dtp->Year, dtp->Month, dtp->Day ); 531 return QDate ( dtp->Year, dtp->Month, dtp->Day );
528 } 532 }
529 QString getCategory( GSM_CalendarEntry*Note) 533 QString getCategory( GSM_CalendarEntry*Note)
530 { 534 {
531 QString CATEGORY; 535 QString CATEGORY;
532 switch (Note->Type) { 536 switch (Note->Type) {
533 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break; 537 case GSM_CAL_REMINDER : CATEGORY = QString("Reminder"); break;
534 case GSM_CAL_CALL : CATEGORY = QString("Call"); break; 538 case GSM_CAL_CALL : CATEGORY = QString("Call"); break;
535 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break; 539 case GSM_CAL_MEETING : CATEGORY = QString("Meeting"); break;
536 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break; 540 case GSM_CAL_BIRTHDAY : CATEGORY = QString("Birthday"); break;
537 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break; 541 case GSM_CAL_MEMO : CATEGORY = QString("Memo"); break;
538 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break; 542 case GSM_CAL_TRAVEL : CATEGORY = QString("Travel"); break;
539 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break; 543 case GSM_CAL_VACATION : CATEGORY = QString("Vacation"); break;
540 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break; 544 case GSM_CAL_ALARM : CATEGORY = QString("Alarm"); break;
541 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break; 545 case GSM_CAL_DAILY_ALARM : CATEGORY = QString("Daily alarm"); break;
542 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break; 546 case GSM_CAL_T_ATHL : CATEGORY = QString("Training/Athletism"); break;
543 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break; 547 case GSM_CAL_T_BALL : CATEGORY = QString("Training/Ball Games"); break;
544 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break; 548 case GSM_CAL_T_CYCL : CATEGORY = QString("Training/Cycling"); break;
545 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break; 549 case GSM_CAL_T_BUDO : CATEGORY = QString("Training/Budo"); break;
546 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break; 550 case GSM_CAL_T_DANC : CATEGORY = QString("Training/Dance"); break;
547 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break; 551 case GSM_CAL_T_EXTR : CATEGORY = QString("Training/Extreme Sports"); break;
548 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break; 552 case GSM_CAL_T_FOOT : CATEGORY = QString("Training/Football"); break;
549 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break; 553 case GSM_CAL_T_GOLF : CATEGORY = QString("Training/Golf"); break;
550 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break; 554 case GSM_CAL_T_GYM : CATEGORY = QString("Training/Gym"); break;
551 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break; 555 case GSM_CAL_T_HORS : CATEGORY = QString("Training/Horse Races"); break;
552 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break; 556 case GSM_CAL_T_HOCK : CATEGORY = QString("Training/Hockey"); break;
553 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break; 557 case GSM_CAL_T_RACE : CATEGORY = QString("Training/Races"); break;
554 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break; 558 case GSM_CAL_T_RUGB : CATEGORY = QString("Training/Rugby"); break;
555 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break; 559 case GSM_CAL_T_SAIL : CATEGORY = QString("Training/Sailing"); break;
556 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break; 560 case GSM_CAL_T_STRE : CATEGORY = QString("Training/Street Games"); break;
557 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break; 561 case GSM_CAL_T_SWIM : CATEGORY = QString("Training/Swimming"); break;
558 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break; 562 case GSM_CAL_T_TENN : CATEGORY = QString("Training/Tennis"); break;
559 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break; 563 case GSM_CAL_T_TRAV : CATEGORY = QString("Training/Travels"); break;
560 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break; 564 case GSM_CAL_T_WINT : CATEGORY = QString("Training/Winter Games"); break;
561 default : CATEGORY = QString(""); 565 default : CATEGORY = QString("");
562 } 566 }
563 567
564 return CATEGORY; 568 return CATEGORY;
565 } 569 }
566 570
567protected: 571protected:
568private: 572private:
569 Calendar *mCalendar; 573 Calendar *mCalendar;
570 QString mProfileName ; 574 QString mProfileName ;
571}; 575};
572 576
573 577
574PhoneFormat::PhoneFormat() 578PhoneFormat::PhoneFormat()
575{ 579{
576 ; 580 ;
577} 581}
578 582
579PhoneFormat::~PhoneFormat() 583PhoneFormat::~PhoneFormat()
580{ 584{
581} 585}
582ulong PhoneFormat::getCsum( const QStringList & attList) 586ulong PhoneFormat::getCsum( const QStringList & attList)
583{ 587{
584 int max = attList.count() -1; 588 int max = attList.count() -1;
585 ulong cSum = 0; 589 ulong cSum = 0;
586 int j,k,i; 590 int j,k,i;
587 int add; 591 int add;
588 for ( i = 1; i < max ; ++i ) { 592 for ( i = 1; i < max ; ++i ) {
589 QString s = attList[i]; 593 QString s = attList[i];
590 if ( ! s.isEmpty() ){ 594 if ( ! s.isEmpty() ){
591 j = s.length(); 595 j = s.length();
592 for ( k = 0; k < j; ++k ) { 596 for ( k = 0; k < j; ++k ) {
593 int mul = k +1; 597 int mul = k +1;
594 add = s[k].unicode (); 598 add = s[k].unicode ();
595 if ( k < 16 ) 599 if ( k < 16 )
596 mul = mul * mul; 600 mul = mul * mul;
597 add = add * mul *i*i*i; 601 add = add * mul *i*i*i;
598 cSum += add; 602 cSum += add;
599 } 603 }
600 } 604 }
601 } 605 }
602 return cSum; 606 return cSum;
603 607
604} 608}
605//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 609//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
606#include <stdlib.h> 610#include <stdlib.h>
607#define DEBUGMODE false 611#define DEBUGMODE false
608bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profileName, QString device,QString connection, QString model ) 612bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal ,QString profileName, QString device,QString connection, QString model )
609{ 613{
610 mProfileName = profileName; 614 mProfileName = profileName;
611 GSM_StateMachines; 615 GSM_StateMachines;
612 qDebug(" load "); 616 qDebug(" load ");
613 s.opened = false; 617 s.opened = false;
614 s.msg = NULL; 618 s.msg = NULL;
615 s.ConfigNum = 0; 619 s.ConfigNum = 0;
616#if 0 620#if 0
617 static char*cp; 621 static char*cp;
618 static INI_Section *cfg = NULL; 622 static INI_Section *cfg = NULL;
619 cfg=GSM_FindGammuRC(); 623 cfg=GSM_FindGammuRC();
620 int i; 624 int i;
621 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 625 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
622 if (cfg!=NULL) { 626 if (cfg!=NULL) {
623 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 627 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
624 if (cp) di.coding = cp; 628 if (cp) di.coding = cp;
625 629
626 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 630 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
627 if (s.Config[i].Localize) { 631 if (s.Config[i].Localize) {
628 s.msg=INI_ReadFile(s.Config[i].Localize, true); 632 s.msg=INI_ReadFile(s.Config[i].Localize, true);
629 } else { 633 } else {
630#if !defined(WIN32) && defined(LOCALE_PATH) 634#if !defined(WIN32) && defined(LOCALE_PATH)
631 locale = setlocale(LC_MESSAGES, NULL); 635 locale = setlocale(LC_MESSAGES, NULL);
632 if (locale != NULL) { 636 if (locale != NULL) {
633 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 637 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
634 LOCALE_PATH, 638 LOCALE_PATH,
635 tolower(locale[0]), 639 tolower(locale[0]),
636 tolower(locale[1])); 640 tolower(locale[1]));
637 s.msg = INI_ReadFile(locale_file, true); 641 s.msg = INI_ReadFile(locale_file, true);
638 } 642 }
639#endif 643#endif
640 } 644 }
641 } 645 }
642 646
643 /* Wanted user specific configuration? */ 647 /* Wanted user specific configuration? */
644 648
645 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 649 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
646 650
647 s.ConfigNum++; 651 s.ConfigNum++;
648 652
649 /* We want to use only one file descriptor for global and state machine debug output */ 653 /* We want to use only one file descriptor for global and state machine debug output */
650 s.Config[i].UseGlobalDebugFile = true; 654 s.Config[i].UseGlobalDebugFile = true;
651 655
652 656
653 657
654 /* We wanted to read just user specified configuration. */ 658 /* We wanted to read just user specified configuration. */
diff --git a/libkcal/sharpformat.cpp b/libkcal/sharpformat.cpp
index f8b066d..defdb09 100644
--- a/libkcal/sharpformat.cpp
+++ b/libkcal/sharpformat.cpp
@@ -1,383 +1,385 @@
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 "sharpformat.h" 44#include "sharpformat.h"
45#include "syncdefines.h" 45#include "syncdefines.h"
46 46
47using namespace KCal; 47using namespace KCal;
48 48
49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY 49//CARDID,CATEGORY,DSRP,PLCE,MEM1,TIM1,TIM2,ADAY,ARON,ARMN,ARSD,RTYP,RFRQ,RPOS,RDYS,REND,REDT,ALSD,ALED,MDAY
50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 50// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
51 51
52//ARSD silentalarm = 0 52//ARSD silentalarm = 0
53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly 53// 11 RTYP 225 no /0 dialy/ 1 weekly/ 3 month by date/ 2 month by day(pos)/ yearly
54// 12 RFRQ 54// 12 RFRQ
55// 13 RPOS pos = 4. monday in month 55// 13 RPOS pos = 4. monday in month
56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun 56// 14 RDYS days: 1 mon/ 2 tue .. 64 sun
57// 15 REND 0 = no end/ 1 = end 57// 15 REND 0 = no end/ 1 = end
58// 16 REDT rec end dt 58// 16 REDT rec end dt
59//ALSD 59//ALSD
60//ALED 60//ALED
61//MDAY 61//MDAY
62 62
63class SharpParser : public QObject 63class SharpParser : public QObject
64{ 64{
65 public: 65 public:
66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) { 66 SharpParser( Calendar *calendar ) : mCalendar( calendar ) {
67 oldCategories = 0; 67 oldCategories = 0;
68 } 68 }
69 69
70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName ) 70 bool startElement( Calendar *existingCalendar, const QStringList & attList, QString qName )
71 { 71 {
72 int i = 1; 72 int i = 1;
73 bool skip = true; 73 bool skip = true;
74 int max = attList.count() -2; 74 int max = attList.count() -2;
75 while ( i < max ) { 75 while ( i < max ) {
76 if ( !attList[i].isEmpty() ) { 76 if ( !attList[i].isEmpty() ) {
77 skip = false; 77 skip = false;
78 break; 78 break;
79 } 79 }
80 ++i ; 80 ++i ;
81 } 81 }
82 if ( skip ) 82 if ( skip )
83 return false; 83 return false;
84 ulong cSum = SharpFormat::getCsum(attList ); 84 ulong cSum = SharpFormat::getCsum(attList );
85 85
86 if ( qName == "Event" ) { 86 if ( qName == "Event" ) {
87 Event *event; 87 Event *event;
88 event = existingCalendar->event( "Sharp_DTM",attList[0] ); 88 event = existingCalendar->event( "Sharp_DTM",attList[0] );
89 if ( event ) 89 if ( event )
90 event = (Event*)event->clone(); 90 event = (Event*)event->clone();
91 else 91 else
92 event = new Event; 92 event = new Event;
93 event->setID("Sharp_DTM", attList[0] ); 93 event->setID("Sharp_DTM", attList[0] );
94 event->setCsum( "Sharp_DTM", QString::number( cSum )); 94 event->setCsum( "Sharp_DTM", QString::number( cSum ));
95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 95 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
96 96
97 event->setSummary( attList[2] ); 97 event->setSummary( attList[2] );
98 event->setLocation( attList[3] ); 98 event->setLocation( attList[3] );
99 event->setDescription( attList[4] ); 99 event->setDescription( attList[4] );
100 if ( attList[7] == "1" ) { 100 if ( attList[7] == "1" ) {
101 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) )); 101 event->setDtStart( QDateTime(fromString( attList[17]+"T000000", false ).date(),QTime(0,0,0 ) ));
102 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 ))); 102 event->setDtEnd( QDateTime(fromString( attList[18]+"T000000", false ).date(),QTime(0,0,0 )));
103 event->setFloats( true ); 103 event->setFloats( true );
104 } else { 104 } else {
105 event->setFloats( false ); 105 event->setFloats( false );
106 event->setDtStart( fromString( attList[5] ) ); 106 event->setDtStart( fromString( attList[5] ) );
107 event->setDtEnd( fromString( attList[6] )); 107 event->setDtEnd( fromString( attList[6] ));
108 } 108 }
109 109
110 QString rtype = attList[11]; 110 QString rtype = attList[11];
111 if ( rtype != "255" ) { 111 if ( rtype != "255" ) {
112 // qDebug("recurs "); 112 // qDebug("recurs ");
113 QDate startDate = event->dtStart().date(); 113 QDate startDate = event->dtStart().date();
114 114
115 QString freqStr = attList[12]; 115 QString freqStr = attList[12];
116 int freq = freqStr.toInt(); 116 int freq = freqStr.toInt();
117 117
118 QString hasEndDateStr = attList[15] ; 118 QString hasEndDateStr = attList[15] ;
119 bool hasEndDate = hasEndDateStr == "1"; 119 bool hasEndDate = hasEndDateStr == "1";
120 120
121 QString endDateStr = attList[16]; 121 QString endDateStr = attList[16];
122 QDate endDate = fromString( endDateStr ).date(); 122 QDate endDate = fromString( endDateStr ).date();
123 123
124 QString weekDaysStr = attList[14]; 124 QString weekDaysStr = attList[14];
125 uint weekDaysNum = weekDaysStr.toInt(); 125 uint weekDaysNum = weekDaysStr.toInt();
126 126
127 QBitArray weekDays( 7 ); 127 QBitArray weekDays( 7 );
128 int i; 128 int i;
129 int bb = 1; 129 int bb = 1;
130 for( i = 1; i <= 7; ++i ) { 130 for( i = 1; i <= 7; ++i ) {
131 weekDays.setBit( i - 1, ( bb & weekDaysNum )); 131 weekDays.setBit( i - 1, ( bb & weekDaysNum ));
132 bb = 2 << (i-1); 132 bb = 2 << (i-1);
133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) ); 133 //qDebug(" %d bit %d ",i-1,weekDays.at(i-1) );
134 } 134 }
135 // qDebug("next "); 135 // qDebug("next ");
136 QString posStr = attList[13]; 136 QString posStr = attList[13];
137 int pos = posStr.toInt(); 137 int pos = posStr.toInt();
138 Recurrence *r = event->recurrence(); 138 Recurrence *r = event->recurrence();
139 139
140 if ( rtype == "0" ) { 140 if ( rtype == "0" ) {
141 if ( hasEndDate ) r->setDaily( freq, endDate ); 141 if ( hasEndDate ) r->setDaily( freq, endDate );
142 else r->setDaily( freq, -1 ); 142 else r->setDaily( freq, -1 );
143 } else if ( rtype == "1" ) { 143 } else if ( rtype == "1" ) {
144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate ); 144 if ( hasEndDate ) r->setWeekly( freq, weekDays, endDate );
145 else r->setWeekly( freq, weekDays, -1 ); 145 else r->setWeekly( freq, weekDays, -1 );
146 } else if ( rtype == "3" ) { 146 } else if ( rtype == "3" ) {
147 if ( hasEndDate ) 147 if ( hasEndDate )
148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate ); 148 r->setMonthly( Recurrence::rMonthlyDay, freq, endDate );
149 else 149 else
150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 ); 150 r->setMonthly( Recurrence::rMonthlyDay, freq, -1 );
151 r->addMonthlyDay( startDate.day() ); 151 r->addMonthlyDay( startDate.day() );
152 } else if ( rtype == "2" ) { 152 } else if ( rtype == "2" ) {
153 if ( hasEndDate ) 153 if ( hasEndDate )
154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate ); 154 r->setMonthly( Recurrence::rMonthlyPos, freq, endDate );
155 else 155 else
156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 ); 156 r->setMonthly( Recurrence::rMonthlyPos, freq, -1 );
157 QBitArray days( 7 ); 157 QBitArray days( 7 );
158 days.fill( false ); 158 days.fill( false );
159 days.setBit( startDate.dayOfWeek() - 1 ); 159 days.setBit( startDate.dayOfWeek() - 1 );
160 r->addMonthlyPos( pos, days ); 160 r->addMonthlyPos( pos, days );
161 } else if ( rtype == "4" ) { 161 } else if ( rtype == "4" ) {
162 if ( hasEndDate ) 162 if ( hasEndDate )
163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate ); 163 r->setYearly( Recurrence::rYearlyMonth, freq, endDate );
164 else 164 else
165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 ); 165 r->setYearly( Recurrence::rYearlyMonth, freq, -1 );
166 r->addYearlyNum( startDate.month() ); 166 r->addYearlyNum( startDate.month() );
167 } 167 }
168 } else { 168 } else {
169 event->recurrence()->unsetRecurs(); 169 event->recurrence()->unsetRecurs();
170 } 170 }
171 171
172 QString categoryList = attList[1] ; 172 QString categoryList = attList[1] ;
173 event->setCategories( lookupCategories( categoryList ) ); 173 event->setCategories( lookupCategories( categoryList ) );
174 174
175 // strange 0 semms to mean: alarm enabled 175 // strange 0 semms to mean: alarm enabled
176 if ( attList[8] == "0" ) { 176 if ( attList[8] == "0" ) {
177 Alarm *alarm; 177 Alarm *alarm;
178 if ( event->alarms().count() > 0 ) 178 if ( event->alarms().count() > 0 )
179 alarm = event->alarms().first(); 179 alarm = event->alarms().first();
180 else { 180 else {
181 alarm = new Alarm( event ); 181 alarm = new Alarm( event );
182 event->addAlarm( alarm ); 182 event->addAlarm( alarm );
183 } 183 }
184 alarm->setType( Alarm::Audio ); 184 alarm->setType( Alarm::Audio );
185 alarm->setEnabled( true ); 185 alarm->setEnabled( true );
186 int alarmOffset = attList[9].toInt(); 186 int alarmOffset = attList[9].toInt();
187 alarm->setStartOffset( alarmOffset * -60 ); 187 alarm->setStartOffset( alarmOffset * -60 );
188 } else { 188 } else {
189 Alarm *alarm; 189 Alarm *alarm;
190 if ( event->alarms().count() > 0 ) { 190 if ( event->alarms().count() > 0 ) {
191 alarm = event->alarms().first(); 191 alarm = event->alarms().first();
192 alarm->setType( Alarm::Audio );
193 alarm->setStartOffset( -60*15 );
192 alarm->setEnabled( false ); 194 alarm->setEnabled( false );
193 } 195 }
194 } 196 }
195 197
196 mCalendar->addEvent( event); 198 mCalendar->addEvent( event);
197 } else if ( qName == "Todo" ) { 199 } else if ( qName == "Todo" ) {
198 Todo *todo; 200 Todo *todo;
199 201
200 todo = existingCalendar->todo( "Sharp_DTM", attList[0] ); 202 todo = existingCalendar->todo( "Sharp_DTM", attList[0] );
201 if (todo ) 203 if (todo )
202 todo = (Todo*)todo->clone(); 204 todo = (Todo*)todo->clone();
203 else 205 else
204 todo = new Todo; 206 todo = new Todo;
205 207
206//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1 208//CARDID,CATEGORY,ETDY,LTDY,FNDY,MARK,PRTY,TITL,MEM1
207// 0 1 2 3 4 5 6 7 8 209// 0 1 2 3 4 5 6 7 8
208//1,,,,,1,4,Loch zumachen,"" 210//1,,,,,1,4,Loch zumachen,""
209//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" " 211//3,Privat,20040317T000000,20040318T000000,20040319T000000,0,5,Call bbb,"notes123 bbb gggg ""bb "" "
210//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes 212//2,"Familie,Freunde,Holiday",20040318T000000,20040324T000000,20040317T000000,1,2,tod2,notes
211 213
212 todo->setID( "Sharp_DTM", attList[0]); 214 todo->setID( "Sharp_DTM", attList[0]);
213 todo->setCsum( "Sharp_DTM", QString::number( cSum )); 215 todo->setCsum( "Sharp_DTM", QString::number( cSum ));
214 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 216 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
215 217
216 todo->setSummary( attList[7] ); 218 todo->setSummary( attList[7] );
217 todo->setDescription( attList[8]); 219 todo->setDescription( attList[8]);
218 220
219 int priority = attList[6].toInt(); 221 int priority = attList[6].toInt();
220 if ( priority == 0 ) priority = 3; 222 if ( priority == 0 ) priority = 3;
221 todo->setPriority( priority ); 223 todo->setPriority( priority );
222 224
223 QString categoryList = attList[1]; 225 QString categoryList = attList[1];
224 todo->setCategories( lookupCategories( categoryList ) ); 226 todo->setCategories( lookupCategories( categoryList ) );
225 227
226 228
227 229
228 QString hasDateStr = attList[3]; // due 230 QString hasDateStr = attList[3]; // due
229 if ( !hasDateStr.isEmpty() ) { 231 if ( !hasDateStr.isEmpty() ) {
230 if ( hasDateStr.right(6) == "000000" ) { 232 if ( hasDateStr.right(6) == "000000" ) {
231 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) ); 233 todo->setDtDue( QDateTime(fromString( hasDateStr, false ).date(), QTime(0,0,0 )) );
232 todo->setFloats( true ); 234 todo->setFloats( true );
233 } 235 }
234 else { 236 else {
235 todo->setDtDue( fromString( hasDateStr ) ); 237 todo->setDtDue( fromString( hasDateStr ) );
236 todo->setFloats( false ); 238 todo->setFloats( false );
237 } 239 }
238 240
239 todo->setHasDueDate( true ); 241 todo->setHasDueDate( true );
240 } 242 }
241 hasDateStr = attList[2];//start 243 hasDateStr = attList[2];//start
242 if ( !hasDateStr.isEmpty() ) { 244 if ( !hasDateStr.isEmpty() ) {
243 245
244 todo->setDtStart( fromString( hasDateStr ) ); 246 todo->setDtStart( fromString( hasDateStr ) );
245 todo->setHasStartDate( true); 247 todo->setHasStartDate( true);
246 } else 248 } else
247 todo->setHasStartDate( false ); 249 todo->setHasStartDate( false );
248 hasDateStr = attList[4];//completed 250 hasDateStr = attList[4];//completed
249 if ( !hasDateStr.isEmpty() ) { 251 if ( !hasDateStr.isEmpty() ) {
250 todo->setCompleted(fromString( hasDateStr ) ); 252 todo->setCompleted(fromString( hasDateStr ) );
251 } 253 }
252 QString completedStr = attList[5]; 254 QString completedStr = attList[5];
253 if ( completedStr == "0" ) 255 if ( completedStr == "0" )
254 todo->setCompleted( true ); 256 todo->setCompleted( true );
255 else 257 else
256 todo->setCompleted( false ); 258 todo->setCompleted( false );
257 mCalendar->addTodo( todo ); 259 mCalendar->addTodo( todo );
258 260
259 } else if ( qName == "Category" ) { 261 } else if ( qName == "Category" ) {
260 /* 262 /*
261 QString id = attributes.value( "id" ); 263 QString id = attributes.value( "id" );
262 QString name = attributes.value( "name" ); 264 QString name = attributes.value( "name" );
263 setCategory( id, name ); 265 setCategory( id, name );
264 */ 266 */
265 } 267 }
266 //qDebug("end "); 268 //qDebug("end ");
267 return true; 269 return true;
268 } 270 }
269 271
270 272
271 void setCategoriesList ( QStringList * c ) 273 void setCategoriesList ( QStringList * c )
272 { 274 {
273 oldCategories = c; 275 oldCategories = c;
274 } 276 }
275 277
276 QDateTime fromString ( QString s, bool useTz = true ) { 278 QDateTime fromString ( QString s, bool useTz = true ) {
277 QDateTime dt; 279 QDateTime dt;
278 int y,m,t,h,min,sec; 280 int y,m,t,h,min,sec;
279 y = s.mid(0,4).toInt(); 281 y = s.mid(0,4).toInt();
280 m = s.mid(4,2).toInt(); 282 m = s.mid(4,2).toInt();
281 t = s.mid(6,2).toInt(); 283 t = s.mid(6,2).toInt();
282 h = s.mid(9,2).toInt(); 284 h = s.mid(9,2).toInt();
283 min = s.mid(11,2).toInt(); 285 min = s.mid(11,2).toInt();
284 sec = s.mid(13,2).toInt(); 286 sec = s.mid(13,2).toInt();
285 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec)); 287 dt = QDateTime(QDate(y,m,t), QTime(h,min,sec));
286 int offset = KGlobal::locale()->localTimeOffset( dt ); 288 int offset = KGlobal::locale()->localTimeOffset( dt );
287 if ( useTz ) 289 if ( useTz )
288 dt = dt.addSecs ( offset*60); 290 dt = dt.addSecs ( offset*60);
289 return dt; 291 return dt;
290 292
291 } 293 }
292 protected: 294 protected:
293 QDateTime toDateTime( const QString &value ) 295 QDateTime toDateTime( const QString &value )
294 { 296 {
295 QDateTime dt; 297 QDateTime dt;
296 dt.setTime_t( value.toUInt() ); 298 dt.setTime_t( value.toUInt() );
297 299
298 return dt; 300 return dt;
299 } 301 }
300 302
301 QStringList lookupCategories( const QString &categoryList ) 303 QStringList lookupCategories( const QString &categoryList )
302 { 304 {
303 QStringList categoryIds = QStringList::split( ";", categoryList ); 305 QStringList categoryIds = QStringList::split( ";", categoryList );
304 QStringList categories; 306 QStringList categories;
305 QStringList::ConstIterator it; 307 QStringList::ConstIterator it;
306 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) { 308 for( it = categoryIds.begin(); it != categoryIds.end(); ++it ) {
307 QString cate = category( *it ); 309 QString cate = category( *it );
308 if ( oldCategories ) { 310 if ( oldCategories ) {
309 if ( ! oldCategories->contains( cate ) ) 311 if ( ! oldCategories->contains( cate ) )
310 oldCategories->append( cate ); 312 oldCategories->append( cate );
311 } 313 }
312 categories.append(cate ); 314 categories.append(cate );
313 } 315 }
314 return categories; 316 return categories;
315 } 317 }
316 318
317 private: 319 private:
318 Calendar *mCalendar; 320 Calendar *mCalendar;
319 QStringList * oldCategories; 321 QStringList * oldCategories;
320 static QString category( const QString &id ) 322 static QString category( const QString &id )
321 { 323 {
322 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id ); 324 QMap<QString,QString>::ConstIterator it = mCategoriesMap.find( id );
323 if ( it == mCategoriesMap.end() ) return id; 325 if ( it == mCategoriesMap.end() ) return id;
324 else return *it; 326 else return *it;
325 } 327 }
326 328
327 static void setCategory( const QString &id, const QString &name ) 329 static void setCategory( const QString &id, const QString &name )
328 { 330 {
329 mCategoriesMap.insert( id, name ); 331 mCategoriesMap.insert( id, name );
330 } 332 }
331 333
332 static QMap<QString,QString> mCategoriesMap; 334 static QMap<QString,QString> mCategoriesMap;
333}; 335};
334 336
335QMap<QString,QString> SharpParser::mCategoriesMap; 337QMap<QString,QString> SharpParser::mCategoriesMap;
336 338
337SharpFormat::SharpFormat() 339SharpFormat::SharpFormat()
338{ 340{
339 mCategories = 0; 341 mCategories = 0;
340} 342}
341 343
342SharpFormat::~SharpFormat() 344SharpFormat::~SharpFormat()
343{ 345{
344} 346}
345ulong SharpFormat::getCsum( const QStringList & attList) 347ulong SharpFormat::getCsum( const QStringList & attList)
346{ 348{
347 int max = attList.count() -1; 349 int max = attList.count() -1;
348 ulong cSum = 0; 350 ulong cSum = 0;
349 int j,k,i; 351 int j,k,i;
350 int add; 352 int add;
351 for ( i = 1; i < max ; ++i ) { 353 for ( i = 1; i < max ; ++i ) {
352 QString s = attList[i]; 354 QString s = attList[i];
353 if ( ! s.isEmpty() ){ 355 if ( ! s.isEmpty() ){
354 j = s.length(); 356 j = s.length();
355 for ( k = 0; k < j; ++k ) { 357 for ( k = 0; k < j; ++k ) {
356 int mul = k +1; 358 int mul = k +1;
357 add = s[k].unicode (); 359 add = s[k].unicode ();
358 if ( k < 16 ) 360 if ( k < 16 )
359 mul = mul * mul; 361 mul = mul * mul;
360 add = add * mul *i*i*i; 362 add = add * mul *i*i*i;
361 cSum += add; 363 cSum += add;
362 } 364 }
363 } 365 }
364 } 366 }
365 return cSum; 367 return cSum;
366 368
367} 369}
368#include <stdlib.h> 370#include <stdlib.h>
369#define DEBUGMODE false 371#define DEBUGMODE false
370bool SharpFormat::load( Calendar *calendar, Calendar *existngCal ) 372bool SharpFormat::load( Calendar *calendar, Calendar *existngCal )
371{ 373{
372 374
373 375
374 bool debug = DEBUGMODE; 376 bool debug = DEBUGMODE;
375 //debug = true; 377 //debug = true;
376 QString text; 378 QString text;
377 QString codec = "utf8"; 379 QString codec = "utf8";
378 QLabel status ( i18n("Reading events ..."), 0 ); 380 QLabel status ( i18n("Reading events ..."), 0 );
379 381
380 int w = status.sizeHint().width()+20 ; 382 int w = status.sizeHint().width()+20 ;
381 if ( w < 200 ) w = 200; 383 if ( w < 200 ) w = 200;
382 int h = status.sizeHint().height()+20 ; 384 int h = status.sizeHint().height()+20 ;
383 int dw = QApplication::desktop()->width(); 385 int dw = QApplication::desktop()->width();