summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libkcal/calendar.cpp15
-rw-r--r--libkcal/calendar.h1
-rw-r--r--libkcal/incidencebase.cpp3
-rw-r--r--libkcal/phoneformat.cpp227
-rw-r--r--libkcal/phoneformat.h4
-rw-r--r--libkcal/vcalformat.cpp7
-rw-r--r--libkcal/vcalformat.h4
7 files changed, 221 insertions, 40 deletions
diff --git a/libkcal/calendar.cpp b/libkcal/calendar.cpp
index 32aac7a..a3977d7 100644
--- a/libkcal/calendar.cpp
+++ b/libkcal/calendar.cpp
@@ -1,128 +1,129 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2000,2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <stdlib.h> 22#include <stdlib.h>
23#include <time.h> 23#include <time.h>
24 24
25#include <kdebug.h> 25#include <kdebug.h>
26#include <kglobal.h> 26#include <kglobal.h>
27#include <klocale.h> 27#include <klocale.h>
28 28
29#include "exceptions.h" 29#include "exceptions.h"
30#include "calfilter.h" 30#include "calfilter.h"
31 31
32#include "calendar.h" 32#include "calendar.h"
33#include "syncdefines.h"
33 34
34using namespace KCal; 35using namespace KCal;
35 36
36Calendar::Calendar() 37Calendar::Calendar()
37{ 38{
38 39
39 init(); 40 init();
40 setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") ); 41 setTimeZoneId( i18n (" 00:00 Europe/London(UTC)") );
41} 42}
42 43
43Calendar::Calendar( const QString &timeZoneId ) 44Calendar::Calendar( const QString &timeZoneId )
44{ 45{
45 46
46 init(); 47 init();
47 setTimeZoneId(timeZoneId); 48 setTimeZoneId(timeZoneId);
48} 49}
49 50
50void Calendar::init() 51void Calendar::init()
51{ 52{
52 mObserver = 0; 53 mObserver = 0;
53 mNewObserver = false; 54 mNewObserver = false;
54 55
55 mModified = false; 56 mModified = false;
56 57
57 // Setup default filter, which does nothing 58 // Setup default filter, which does nothing
58 mDefaultFilter = new CalFilter; 59 mDefaultFilter = new CalFilter;
59 mFilter = mDefaultFilter; 60 mFilter = mDefaultFilter;
60 mFilter->setEnabled(false); 61 mFilter->setEnabled(false);
61 62
62 // initialize random numbers. This is a hack, and not 63 // initialize random numbers. This is a hack, and not
63 // even that good of one at that. 64 // even that good of one at that.
64// srandom(time(0)); 65// srandom(time(0));
65 66
66 // user information... 67 // user information...
67 setOwner(i18n("Unknown Name")); 68 setOwner(i18n("Unknown Name"));
68 setEmail(i18n("unknown@nowhere")); 69 setEmail(i18n("unknown@nowhere"));
69 70
70#if 0 71#if 0
71 tmpStr = KOPrefs::instance()->mTimeZone; 72 tmpStr = KOPrefs::instance()->mTimeZone;
72// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl; 73// kdDebug(5800) << "Calendar::Calendar(): TimeZone: " << tmpStr << endl;
73 int dstSetting = KOPrefs::instance()->mDaylightSavings; 74 int dstSetting = KOPrefs::instance()->mDaylightSavings;
74 extern long int timezone; 75 extern long int timezone;
75 struct tm *now; 76 struct tm *now;
76 time_t curtime; 77 time_t curtime;
77 curtime = time(0); 78 curtime = time(0);
78 now = localtime(&curtime); 79 now = localtime(&curtime);
79 int hourOff = - ((timezone / 60) / 60); 80 int hourOff = - ((timezone / 60) / 60);
80 if (now->tm_isdst) 81 if (now->tm_isdst)
81 hourOff += 1; 82 hourOff += 1;
82 QString tzStr; 83 QString tzStr;
83 tzStr.sprintf("%.2d%.2d", 84 tzStr.sprintf("%.2d%.2d",
84 hourOff, 85 hourOff,
85 abs((timezone / 60) % 60)); 86 abs((timezone / 60) % 60));
86 87
87 // if no time zone was in the config file, write what we just discovered. 88 // if no time zone was in the config file, write what we just discovered.
88 if (tmpStr.isEmpty()) { 89 if (tmpStr.isEmpty()) {
89// KOPrefs::instance()->mTimeZone = tzStr; 90// KOPrefs::instance()->mTimeZone = tzStr;
90 } else { 91 } else {
91 tzStr = tmpStr; 92 tzStr = tmpStr;
92 } 93 }
93 94
94 // if daylight savings has changed since last load time, we need 95 // if daylight savings has changed since last load time, we need
95 // to rewrite these settings to the config file. 96 // to rewrite these settings to the config file.
96 if ((now->tm_isdst && !dstSetting) || 97 if ((now->tm_isdst && !dstSetting) ||
97 (!now->tm_isdst && dstSetting)) { 98 (!now->tm_isdst && dstSetting)) {
98 KOPrefs::instance()->mTimeZone = tzStr; 99 KOPrefs::instance()->mTimeZone = tzStr;
99 KOPrefs::instance()->mDaylightSavings = now->tm_isdst; 100 KOPrefs::instance()->mDaylightSavings = now->tm_isdst;
100 } 101 }
101 102
102 setTimeZone(tzStr); 103 setTimeZone(tzStr);
103#endif 104#endif
104 105
105// KOPrefs::instance()->writeConfig(); 106// KOPrefs::instance()->writeConfig();
106} 107}
107 108
108Calendar::~Calendar() 109Calendar::~Calendar()
109{ 110{
110 delete mDefaultFilter; 111 delete mDefaultFilter;
111} 112}
112 113
113const QString &Calendar::getOwner() const 114const QString &Calendar::getOwner() const
114{ 115{
115 return mOwner; 116 return mOwner;
116} 117}
117 118
118void Calendar::setOwner(const QString &os) 119void Calendar::setOwner(const QString &os)
119{ 120{
120 int i; 121 int i;
121 mOwner = os; 122 mOwner = os;
122 i = mOwner.find(','); 123 i = mOwner.find(',');
123 if (i != -1) 124 if (i != -1)
124 mOwner = mOwner.left(i); 125 mOwner = mOwner.left(i);
125 126
126 setModified( true ); 127 setModified( true );
127} 128}
128 129
@@ -154,193 +155,207 @@ QString Calendar::getTimeZoneStr() const
154 if (mLocalTime) 155 if (mLocalTime)
155 return ""; 156 return "";
156 QString tmpStr; 157 QString tmpStr;
157 int hours = abs(mTimeZone / 60); 158 int hours = abs(mTimeZone / 60);
158 int minutes = abs(mTimeZone % 60); 159 int minutes = abs(mTimeZone % 60);
159 bool neg = mTimeZone < 0; 160 bool neg = mTimeZone < 0;
160 161
161 tmpStr.sprintf("%c%.2d%.2d", 162 tmpStr.sprintf("%c%.2d%.2d",
162 (neg ? '-' : '+'), 163 (neg ? '-' : '+'),
163 hours, minutes); 164 hours, minutes);
164 return tmpStr; 165 return tmpStr;
165} 166}
166 167
167void Calendar::setTimeZone(int tz) 168void Calendar::setTimeZone(int tz)
168{ 169{
169 mTimeZone = tz; 170 mTimeZone = tz;
170 mLocalTime = false; 171 mLocalTime = false;
171 172
172 setModified( true ); 173 setModified( true );
173} 174}
174 175
175int Calendar::getTimeZone() const 176int Calendar::getTimeZone() const
176{ 177{
177 return mTimeZone; 178 return mTimeZone;
178} 179}
179 180
180void Calendar::setTimeZoneId(const QString &id) 181void Calendar::setTimeZoneId(const QString &id)
181{ 182{
182 mTimeZoneId = id; 183 mTimeZoneId = id;
183 mLocalTime = false; 184 mLocalTime = false;
184 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId); 185 mTimeZone = KGlobal::locale()->timezoneOffset(mTimeZoneId);
185 if ( mTimeZone > 1000) 186 if ( mTimeZone > 1000)
186 setLocalTime(); 187 setLocalTime();
187 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone); 188 //qDebug("Calendar::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), mTimeZone);
188 setModified( true ); 189 setModified( true );
189} 190}
190 191
191QString Calendar::timeZoneId() const 192QString Calendar::timeZoneId() const
192{ 193{
193 return mTimeZoneId; 194 return mTimeZoneId;
194} 195}
195 196
196void Calendar::setLocalTime() 197void Calendar::setLocalTime()
197{ 198{
198 //qDebug("Calendar::setLocalTime() "); 199 //qDebug("Calendar::setLocalTime() ");
199 mLocalTime = true; 200 mLocalTime = true;
200 mTimeZone = 0; 201 mTimeZone = 0;
201 mTimeZoneId = ""; 202 mTimeZoneId = "";
202 203
203 setModified( true ); 204 setModified( true );
204} 205}
205 206
206bool Calendar::isLocalTime() const 207bool Calendar::isLocalTime() const
207{ 208{
208 return mLocalTime; 209 return mLocalTime;
209} 210}
210 211
211const QString &Calendar::getEmail() 212const QString &Calendar::getEmail()
212{ 213{
213 return mOwnerEmail; 214 return mOwnerEmail;
214} 215}
215 216
216void Calendar::setEmail(const QString &e) 217void Calendar::setEmail(const QString &e)
217{ 218{
218 mOwnerEmail = e; 219 mOwnerEmail = e;
219 220
220 setModified( true ); 221 setModified( true );
221} 222}
222 223
223void Calendar::setFilter(CalFilter *filter) 224void Calendar::setFilter(CalFilter *filter)
224{ 225{
225 mFilter = filter; 226 mFilter = filter;
226} 227}
227 228
228CalFilter *Calendar::filter() 229CalFilter *Calendar::filter()
229{ 230{
230 return mFilter; 231 return mFilter;
231} 232}
232 233
233QPtrList<Incidence> Calendar::incidences() 234QPtrList<Incidence> Calendar::incidences()
234{ 235{
235 QPtrList<Incidence> incidences; 236 QPtrList<Incidence> incidences;
236 237
237 Incidence *i; 238 Incidence *i;
238 239
239 QPtrList<Event> e = events(); 240 QPtrList<Event> e = events();
240 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 241 for( i = e.first(); i; i = e.next() ) incidences.append( i );
241 242
242 QPtrList<Todo> t = todos(); 243 QPtrList<Todo> t = todos();
243 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 244 for( i = t.first(); i; i = t.next() ) incidences.append( i );
244 245
245 QPtrList<Journal> j = journals(); 246 QPtrList<Journal> j = journals();
246 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 247 for( i = j.first(); i; i = j.next() ) incidences.append( i );
247 248
248 return incidences; 249 return incidences;
249} 250}
251void Calendar::resetTempSyncStat()
252{
253 QPtrList<Incidence> incidences;
254
255 Incidence *i;
256
257 QPtrList<Event> e = rawEvents();
258 for( i = e.first(); i; i = e.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
250 259
260 QPtrList<Todo> t = rawTodos();
261 for( i = t.first(); i; i = t.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
262
263 QPtrList<Journal> j = journals();
264 for( i = j.first(); i; i = j.next() ) i->setTempSyncStat( SYNC_TEMPSTATE_INITIAL );
265}
251QPtrList<Incidence> Calendar::rawIncidences() 266QPtrList<Incidence> Calendar::rawIncidences()
252{ 267{
253 QPtrList<Incidence> incidences; 268 QPtrList<Incidence> incidences;
254 269
255 Incidence *i; 270 Incidence *i;
256 271
257 QPtrList<Event> e = rawEvents(); 272 QPtrList<Event> e = rawEvents();
258 for( i = e.first(); i; i = e.next() ) incidences.append( i ); 273 for( i = e.first(); i; i = e.next() ) incidences.append( i );
259 274
260 QPtrList<Todo> t = rawTodos(); 275 QPtrList<Todo> t = rawTodos();
261 for( i = t.first(); i; i = t.next() ) incidences.append( i ); 276 for( i = t.first(); i; i = t.next() ) incidences.append( i );
262 277
263 QPtrList<Journal> j = journals(); 278 QPtrList<Journal> j = journals();
264 for( i = j.first(); i; i = j.next() ) incidences.append( i ); 279 for( i = j.first(); i; i = j.next() ) incidences.append( i );
265 280
266 return incidences; 281 return incidences;
267} 282}
268 283
269QPtrList<Event> Calendar::events( const QDate &date, bool sorted ) 284QPtrList<Event> Calendar::events( const QDate &date, bool sorted )
270{ 285{
271 QPtrList<Event> el = rawEventsForDate(date,sorted); 286 QPtrList<Event> el = rawEventsForDate(date,sorted);
272 mFilter->apply(&el); 287 mFilter->apply(&el);
273 return el; 288 return el;
274} 289}
275 290
276QPtrList<Event> Calendar::events( const QDateTime &qdt ) 291QPtrList<Event> Calendar::events( const QDateTime &qdt )
277{ 292{
278 QPtrList<Event> el = rawEventsForDate(qdt); 293 QPtrList<Event> el = rawEventsForDate(qdt);
279 mFilter->apply(&el); 294 mFilter->apply(&el);
280 return el; 295 return el;
281} 296}
282 297
283QPtrList<Event> Calendar::events( const QDate &start, const QDate &end, 298QPtrList<Event> Calendar::events( const QDate &start, const QDate &end,
284 bool inclusive) 299 bool inclusive)
285{ 300{
286 QPtrList<Event> el = rawEvents(start,end,inclusive); 301 QPtrList<Event> el = rawEvents(start,end,inclusive);
287 mFilter->apply(&el); 302 mFilter->apply(&el);
288 return el; 303 return el;
289} 304}
290 305
291QPtrList<Event> Calendar::events() 306QPtrList<Event> Calendar::events()
292{ 307{
293 QPtrList<Event> el = rawEvents(); 308 QPtrList<Event> el = rawEvents();
294 mFilter->apply(&el); 309 mFilter->apply(&el);
295 return el; 310 return el;
296} 311}
297 312
298 313
299bool Calendar::addIncidence(Incidence *i) 314bool Calendar::addIncidence(Incidence *i)
300{ 315{
301 Incidence::AddVisitor<Calendar> v(this); 316 Incidence::AddVisitor<Calendar> v(this);
302 317
303 return i->accept(v); 318 return i->accept(v);
304} 319}
305void Calendar::deleteIncidence(Incidence *in) 320void Calendar::deleteIncidence(Incidence *in)
306{ 321{
307 if ( in->type() == "Event" ) 322 if ( in->type() == "Event" )
308 deleteEvent( (Event*) in ); 323 deleteEvent( (Event*) in );
309 else if ( in->type() =="Todo" ) 324 else if ( in->type() =="Todo" )
310 deleteTodo( (Todo*) in); 325 deleteTodo( (Todo*) in);
311 else if ( in->type() =="Journal" ) 326 else if ( in->type() =="Journal" )
312 deleteJournal( (Journal*) in ); 327 deleteJournal( (Journal*) in );
313} 328}
314 329
315Incidence* Calendar::incidence( const QString& uid ) 330Incidence* Calendar::incidence( const QString& uid )
316{ 331{
317 Incidence* i; 332 Incidence* i;
318 333
319 if( (i = todo( uid )) != 0 ) 334 if( (i = todo( uid )) != 0 )
320 return i; 335 return i;
321 if( (i = event( uid )) != 0 ) 336 if( (i = event( uid )) != 0 )
322 return i; 337 return i;
323 if( (i = journal( uid )) != 0 ) 338 if( (i = journal( uid )) != 0 )
324 return i; 339 return i;
325 340
326 return 0; 341 return 0;
327} 342}
328 343
329QPtrList<Todo> Calendar::todos() 344QPtrList<Todo> Calendar::todos()
330{ 345{
331 QPtrList<Todo> tl = rawTodos(); 346 QPtrList<Todo> tl = rawTodos();
332 mFilter->apply( &tl ); 347 mFilter->apply( &tl );
333 return tl; 348 return tl;
334} 349}
335 350
336// When this is called, the todo have already been added to the calendar. 351// When this is called, the todo have already been added to the calendar.
337// This method is only about linking related todos 352// This method is only about linking related todos
338void Calendar::setupRelations( Incidence *incidence ) 353void Calendar::setupRelations( Incidence *incidence )
339{ 354{
340 QString uid = incidence->uid(); 355 QString uid = incidence->uid();
341 //qDebug("Calendar::setupRelations "); 356 //qDebug("Calendar::setupRelations ");
342 // First, go over the list of orphans and see if this is their parent 357 // First, go over the list of orphans and see if this is their parent
343 while( Incidence* i = mOrphans[ uid ] ) { 358 while( Incidence* i = mOrphans[ uid ] ) {
344 mOrphans.remove( uid ); 359 mOrphans.remove( uid );
345 i->setRelatedTo( incidence ); 360 i->setRelatedTo( incidence );
346 incidence->addRelation( i ); 361 incidence->addRelation( i );
diff --git a/libkcal/calendar.h b/libkcal/calendar.h
index 4a3223c..06a911c 100644
--- a/libkcal/calendar.h
+++ b/libkcal/calendar.h
@@ -1,164 +1,165 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef CALENDAR_H 22#ifndef CALENDAR_H
23#define CALENDAR_H 23#define CALENDAR_H
24 24
25#include <qobject.h> 25#include <qobject.h>
26#include <qstring.h> 26#include <qstring.h>
27#include <qdatetime.h> 27#include <qdatetime.h>
28#include <qptrlist.h> 28#include <qptrlist.h>
29#include <qdict.h> 29#include <qdict.h>
30 30
31#include "customproperties.h" 31#include "customproperties.h"
32#include "event.h" 32#include "event.h"
33#include "todo.h" 33#include "todo.h"
34#include "journal.h" 34#include "journal.h"
35 35
36#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */ 36#define _TIME_ZONE "-0500" /* hardcoded, overridden in config file. */
37 37
38class KConfig; 38class KConfig;
39 39
40namespace KCal { 40namespace KCal {
41 41
42class CalFilter; 42class CalFilter;
43 43
44/** 44/**
45 This is the main "calendar" object class for KOrganizer. It holds 45 This is the main "calendar" object class for KOrganizer. It holds
46 information like all appointments/events, user information, etc. etc. 46 information like all appointments/events, user information, etc. etc.
47 one calendar is associated with each CalendarView (@see calendarview.h). 47 one calendar is associated with each CalendarView (@see calendarview.h).
48 This is an abstract base class defining the interface to a calendar. It is 48 This is an abstract base class defining the interface to a calendar. It is
49 implemented by subclasses like @see CalendarLocal, which use different 49 implemented by subclasses like @see CalendarLocal, which use different
50 methods to store and access the data. 50 methods to store and access the data.
51 51
52 Ownership of events etc. is handled by the following policy: As soon as an 52 Ownership of events etc. is handled by the following policy: As soon as an
53 event (or any other subclass of IncidenceBase) object is added to the 53 event (or any other subclass of IncidenceBase) object is added to the
54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes 54 Calendar by addEvent() it is owned by the Calendar object. The Calendar takes
55 care of deleting it. All Events returned by the query functions are returned 55 care of deleting it. All Events returned by the query functions are returned
56 as pointers, that means all changes to the returned events are immediately 56 as pointers, that means all changes to the returned events are immediately
57 visible in the Calendar. You shouldn't delete any Event object you get from 57 visible in the Calendar. You shouldn't delete any Event object you get from
58 Calendar. 58 Calendar.
59*/ 59*/
60class Calendar : public QObject, public CustomProperties, 60class Calendar : public QObject, public CustomProperties,
61 public IncidenceBase::Observer 61 public IncidenceBase::Observer
62{ 62{
63 Q_OBJECT 63 Q_OBJECT
64public: 64public:
65 Calendar(); 65 Calendar();
66 Calendar(const QString &timeZoneId); 66 Calendar(const QString &timeZoneId);
67 virtual ~Calendar(); 67 virtual ~Calendar();
68 void deleteIncidence(Incidence *in); 68 void deleteIncidence(Incidence *in);
69 void resetTempSyncStat();
69 /** 70 /**
70 Clears out the current calendar, freeing all used memory etc. 71 Clears out the current calendar, freeing all used memory etc.
71 */ 72 */
72 virtual void close() = 0; 73 virtual void close() = 0;
73 74
74 /** 75 /**
75 Sync changes in memory to persistant storage. 76 Sync changes in memory to persistant storage.
76 */ 77 */
77 virtual void save() = 0; 78 virtual void save() = 0;
78 virtual QPtrList<Event> getExternLastSyncEvents() = 0; 79 virtual QPtrList<Event> getExternLastSyncEvents() = 0;
79 virtual bool isSaving() { return false; } 80 virtual bool isSaving() { return false; }
80 81
81 /** 82 /**
82 Return the owner of the calendar's full name. 83 Return the owner of the calendar's full name.
83 */ 84 */
84 const QString &getOwner() const; 85 const QString &getOwner() const;
85 /** 86 /**
86 Set the owner of the calendar. Should be owner's full name. 87 Set the owner of the calendar. Should be owner's full name.
87 */ 88 */
88 void setOwner( const QString &os ); 89 void setOwner( const QString &os );
89 /** 90 /**
90 Return the email address of the calendar owner. 91 Return the email address of the calendar owner.
91 */ 92 */
92 const QString &getEmail(); 93 const QString &getEmail();
93 /** 94 /**
94 Set the email address of the calendar owner. 95 Set the email address of the calendar owner.
95 */ 96 */
96 void setEmail( const QString & ); 97 void setEmail( const QString & );
97 98
98 /** 99 /**
99 Set time zone from a timezone string (e.g. -2:00) 100 Set time zone from a timezone string (e.g. -2:00)
100 */ 101 */
101 void setTimeZone( const QString &tz ); 102 void setTimeZone( const QString &tz );
102 /** 103 /**
103 Set time zone from a minutes value (e.g. -60) 104 Set time zone from a minutes value (e.g. -60)
104 */ 105 */
105 void setTimeZone( int tz ); 106 void setTimeZone( int tz );
106 /** 107 /**
107 Return time zone as offest in minutes. 108 Return time zone as offest in minutes.
108 */ 109 */
109 int getTimeZone() const; 110 int getTimeZone() const;
110 /** 111 /**
111 Compute an ISO 8601 format string from the time zone. 112 Compute an ISO 8601 format string from the time zone.
112 */ 113 */
113 QString getTimeZoneStr() const; 114 QString getTimeZoneStr() const;
114 /** 115 /**
115 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal 116 Set time zone id (see /usr/share/zoneinfo/zone.tab for list of legal
116 values). 117 values).
117 */ 118 */
118 void setTimeZoneId( const QString & ); 119 void setTimeZoneId( const QString & );
119 /** 120 /**
120 Return time zone id. 121 Return time zone id.
121 */ 122 */
122 QString timeZoneId() const; 123 QString timeZoneId() const;
123 /** 124 /**
124 Use local time, not UTC or a time zone. 125 Use local time, not UTC or a time zone.
125 */ 126 */
126 void setLocalTime(); 127 void setLocalTime();
127 /** 128 /**
128 Return whether local time is being used. 129 Return whether local time is being used.
129 */ 130 */
130 bool isLocalTime() const; 131 bool isLocalTime() const;
131 132
132 /** 133 /**
133 Add an incidence to calendar. 134 Add an incidence to calendar.
134 135
135 @return true on success, false on error. 136 @return true on success, false on error.
136 */ 137 */
137 virtual bool addIncidence( Incidence * ); 138 virtual bool addIncidence( Incidence * );
138 /** 139 /**
139 Return filtered list of all incidences of this calendar. 140 Return filtered list of all incidences of this calendar.
140 */ 141 */
141 virtual QPtrList<Incidence> incidences(); 142 virtual QPtrList<Incidence> incidences();
142 143
143 /** 144 /**
144 Return unfiltered list of all incidences of this calendar. 145 Return unfiltered list of all incidences of this calendar.
145 */ 146 */
146 virtual QPtrList<Incidence> rawIncidences(); 147 virtual QPtrList<Incidence> rawIncidences();
147 148
148 /** 149 /**
149 Adds a Event to this calendar object. 150 Adds a Event to this calendar object.
150 @param anEvent a pointer to the event to add 151 @param anEvent a pointer to the event to add
151 152
152 @return true on success, false on error. 153 @return true on success, false on error.
153 */ 154 */
154 virtual bool addEventNoDup( Event *event ) = 0; 155 virtual bool addEventNoDup( Event *event ) = 0;
155 virtual bool addAnniversaryNoDup( Event *event ) = 0; 156 virtual bool addAnniversaryNoDup( Event *event ) = 0;
156 virtual bool addEvent( Event *anEvent ) = 0; 157 virtual bool addEvent( Event *anEvent ) = 0;
157 /** 158 /**
158 Delete event from calendar. 159 Delete event from calendar.
159 */ 160 */
160 virtual void deleteEvent( Event * ) = 0; 161 virtual void deleteEvent( Event * ) = 0;
161 /** 162 /**
162 Retrieves an event on the basis of the unique string ID. 163 Retrieves an event on the basis of the unique string ID.
163 */ 164 */
164 virtual Event *event( const QString &UniqueStr ) = 0; 165 virtual Event *event( const QString &UniqueStr ) = 0;
diff --git a/libkcal/incidencebase.cpp b/libkcal/incidencebase.cpp
index 15c4fa8..64a343c 100644
--- a/libkcal/incidencebase.cpp
+++ b/libkcal/incidencebase.cpp
@@ -1,139 +1,140 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 3 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
4 4
5 This library is free software; you can redistribute it and/or 5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Library General Public 6 modify it under the terms of the GNU Library General Public
7 License as published by the Free Software Foundation; either 7 License as published by the Free Software Foundation; either
8 version 2 of the License, or (at your option) any later version. 8 version 2 of the License, or (at your option) any later version.
9 9
10 This library is distributed in the hope that it will be useful, 10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of 11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Library General Public License for more details. 13 Library General Public License for more details.
14 14
15 You should have received a copy of the GNU Library General Public License 15 You should have received a copy of the GNU Library General Public License
16 along with this library; see the file COPYING.LIB. If not, write to 16 along with this library; see the file COPYING.LIB. If not, write to
17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 17 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
18 Boston, MA 02111-1307, USA. 18 Boston, MA 02111-1307, USA.
19*/ 19*/
20 20
21#include <kglobal.h> 21#include <kglobal.h>
22#include <klocale.h> 22#include <klocale.h>
23#include <kdebug.h> 23#include <kdebug.h>
24#include <kidmanager.h> 24#include <kidmanager.h>
25 25
26#include "calformat.h" 26#include "calformat.h"
27#include "syncdefines.h"
27 28
28#include "incidencebase.h" 29#include "incidencebase.h"
29 30
30using namespace KCal; 31using namespace KCal;
31 32
32IncidenceBase::IncidenceBase() : 33IncidenceBase::IncidenceBase() :
33 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false), 34 mReadOnly(false), mFloats(true), mDuration(0), mHasDuration(false),
34 mPilotId(0), mSyncStatus(SYNCMOD) 35 mPilotId(0), mSyncStatus(SYNCMOD)
35{ 36{
36 setUid(CalFormat::createUniqueId()); 37 setUid(CalFormat::createUniqueId());
37 mOrganizer = ""; 38 mOrganizer = "";
38 mFloats = false; 39 mFloats = false;
39 mDuration = 0; 40 mDuration = 0;
40 mHasDuration = false; 41 mHasDuration = false;
41 mPilotId = 0; 42 mPilotId = 0;
42 mExternalId = ":"; 43 mExternalId = ":";
43 mTempSyncStat = 0; 44 mTempSyncStat = SYNC_TEMPSTATE_INITIAL;
44 mSyncStatus = 0; 45 mSyncStatus = 0;
45 mAttendees.setAutoDelete( true ); 46 mAttendees.setAutoDelete( true );
46} 47}
47 48
48IncidenceBase::IncidenceBase(const IncidenceBase &i) : 49IncidenceBase::IncidenceBase(const IncidenceBase &i) :
49 CustomProperties( i ) 50 CustomProperties( i )
50{ 51{
51 mReadOnly = i.mReadOnly; 52 mReadOnly = i.mReadOnly;
52 mDtStart = i.mDtStart; 53 mDtStart = i.mDtStart;
53 mDuration = i.mDuration; 54 mDuration = i.mDuration;
54 mHasDuration = i.mHasDuration; 55 mHasDuration = i.mHasDuration;
55 mOrganizer = i.mOrganizer; 56 mOrganizer = i.mOrganizer;
56 mUid = i.mUid; 57 mUid = i.mUid;
57 QPtrList<Attendee> attendees = i.attendees(); 58 QPtrList<Attendee> attendees = i.attendees();
58 for( Attendee *a = attendees.first(); a; a = attendees.next() ) { 59 for( Attendee *a = attendees.first(); a; a = attendees.next() ) {
59 mAttendees.append( new Attendee( *a ) ); 60 mAttendees.append( new Attendee( *a ) );
60 } 61 }
61 mFloats = i.mFloats; 62 mFloats = i.mFloats;
62 mLastModified = i.mLastModified; 63 mLastModified = i.mLastModified;
63 mPilotId = i.mPilotId; 64 mPilotId = i.mPilotId;
64 mTempSyncStat = i.mTempSyncStat; 65 mTempSyncStat = i.mTempSyncStat;
65 mSyncStatus = i.mSyncStatus; 66 mSyncStatus = i.mSyncStatus;
66 mExternalId = i.mExternalId; 67 mExternalId = i.mExternalId;
67 // The copied object is a new one, so it isn't observed by the observer 68 // The copied object is a new one, so it isn't observed by the observer
68 // of the original object. 69 // of the original object.
69 mObservers.clear(); 70 mObservers.clear();
70 71
71 mAttendees.setAutoDelete( true ); 72 mAttendees.setAutoDelete( true );
72} 73}
73 74
74IncidenceBase::~IncidenceBase() 75IncidenceBase::~IncidenceBase()
75{ 76{
76} 77}
77 78
78 79
79bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 ) 80bool KCal::operator==( const IncidenceBase& i1, const IncidenceBase& i2 )
80{ 81{
81 // do not compare mSyncStatus and mExternalId 82 // do not compare mSyncStatus and mExternalId
82 if( i1.attendees().count() != i2.attendees().count() ) { 83 if( i1.attendees().count() != i2.attendees().count() ) {
83 return false; // no need to check further 84 return false; // no need to check further
84 } 85 }
85 if ( i1.attendees().count() > 0 ) { 86 if ( i1.attendees().count() > 0 ) {
86 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ; 87 Attendee * a1 = i1.attendees().first(), *a2 =i2.attendees().first() ;
87 while ( a1 ) { 88 while ( a1 ) {
88 if ( !( (*a1) == (*a2)) ) 89 if ( !( (*a1) == (*a2)) )
89 { 90 {
90 //qDebug("Attendee not equal "); 91 //qDebug("Attendee not equal ");
91 return false; 92 return false;
92 } 93 }
93 a1 = i1.attendees().next(); 94 a1 = i1.attendees().next();
94 a2 = i2.attendees().next(); 95 a2 = i2.attendees().next();
95 } 96 }
96 } 97 }
97 //if ( i1.dtStart() != i2.dtStart() ) 98 //if ( i1.dtStart() != i2.dtStart() )
98 // return false; 99 // return false;
99#if 0 100#if 0
100 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() ); 101 qDebug("1 %d ",i1.doesFloat() == i2.doesFloat() );
101 qDebug("1 %d ",i1.duration() == i2.duration() ); 102 qDebug("1 %d ",i1.duration() == i2.duration() );
102 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() ); 103 qDebug("3 %d ",i1.hasDuration() == i2.hasDuration() );
103 qDebug("1 %d ",i1.pilotId() == i2.pilotId() ); 104 qDebug("1 %d ",i1.pilotId() == i2.pilotId() );
104 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() ); 105 qDebug("1 %d %d %d",i1.syncStatus() == i2.syncStatus() , i1.syncStatus(),i2.syncStatus() );
105 qDebug("6 %d ",i1.organizer() == i2.organizer() ); 106 qDebug("6 %d ",i1.organizer() == i2.organizer() );
106 107
107#endif 108#endif
108 return ( i1.organizer() == i2.organizer() && 109 return ( i1.organizer() == i2.organizer() &&
109 // i1.uid() == i2.uid() && 110 // i1.uid() == i2.uid() &&
110 // Don't compare lastModified, otherwise the operator is not 111 // Don't compare lastModified, otherwise the operator is not
111 // of much use. We are not comparing for identity, after all. 112 // of much use. We are not comparing for identity, after all.
112 i1.doesFloat() == i2.doesFloat() && 113 i1.doesFloat() == i2.doesFloat() &&
113 i1.duration() == i2.duration() && 114 i1.duration() == i2.duration() &&
114 i1.hasDuration() == i2.hasDuration() && 115 i1.hasDuration() == i2.hasDuration() &&
115 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() ); 116 i1.pilotId() == i2.pilotId() );// && i1.syncStatus() == i2.syncStatus() );
116 // no need to compare mObserver 117 // no need to compare mObserver
117} 118}
118 119
119 120
120QDateTime IncidenceBase::getEvenTime( QDateTime dt ) 121QDateTime IncidenceBase::getEvenTime( QDateTime dt )
121{ 122{
122 QTime t = dt.time(); 123 QTime t = dt.time();
123 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) ); 124 dt.setTime( QTime (t.hour (), t.minute (), t.second () ) );
124 return dt; 125 return dt;
125} 126}
126 127
127 128
128void IncidenceBase::setUid(const QString &uid) 129void IncidenceBase::setUid(const QString &uid)
129{ 130{
130 mUid = uid; 131 mUid = uid;
131 updated(); 132 updated();
132} 133}
133 134
134QString IncidenceBase::uid() const 135QString IncidenceBase::uid() const
135{ 136{
136 return mUid; 137 return mUid;
137} 138}
138 139
139void IncidenceBase::setLastModified(const QDateTime &lm) 140void IncidenceBase::setLastModified(const QDateTime &lm)
diff --git a/libkcal/phoneformat.cpp b/libkcal/phoneformat.cpp
index e6d4879..6bbc0a3 100644
--- a/libkcal/phoneformat.cpp
+++ b/libkcal/phoneformat.cpp
@@ -1,328 +1,329 @@
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 = 5; 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 = 1; break;
72 default :priority = 3 ;break; 72 default :priority = 3 ;break;
73 } 73 }
74 todo->setPriority( priority ); 74 todo->setPriority( priority );
75 GSM_Phone_Functions*Phone; 75 GSM_Phone_Functions*Phone;
76 Phone=s->Phone.Functions; 76 Phone=s->Phone.Functions;
77 int j; 77 int j;
78 GSM_DateTime* dtp; 78 GSM_DateTime* dtp;
79 bool alarm = false; 79 bool alarm = false;
80 QDateTime alarmDt; 80 QDateTime alarmDt;
81 GSM_Category Category; 81 GSM_Category Category;
82 int error; 82 int error;
83 for (j=0;j<ToDo->EntriesNum;j++) { 83 for (j=0;j<ToDo->EntriesNum;j++) {
84 84
85 //qDebug(" for todo %d",ToDo->Location ); 85 //qDebug(" for todo %d",ToDo->Location );
86 switch (ToDo->Entries[j].EntryType) { 86 switch (ToDo->Entries[j].EntryType) {
87 case TODO_END_DATETIME: 87 case TODO_END_DATETIME:
88 dtp = &ToDo->Entries[j].Date ; 88 dtp = &ToDo->Entries[j].Date ;
89 todo->setDtDue (fromGSM ( dtp )); 89 todo->setDtDue (fromGSM ( dtp ));
90 break; 90 break;
91 case TODO_COMPLETED: 91 case TODO_COMPLETED:
92 if ( ToDo->Entries[j].Number == 1 ) { 92 if ( ToDo->Entries[j].Number == 1 ) {
93 todo->setCompleted( true ); 93 todo->setCompleted( true );
94 } 94 }
95 else { 95 else {
96 todo->setCompleted( false ); 96 todo->setCompleted( false );
97 } 97 }
98 break; 98 break;
99 case TODO_ALARM_DATETIME: 99 case TODO_ALARM_DATETIME:
100 dtp = &ToDo->Entries[j].Date ; 100 dtp = &ToDo->Entries[j].Date ;
101 alarm = true; 101 alarm = true;
102 alarmDt = fromGSM ( dtp ); 102 alarmDt = fromGSM ( dtp );
103 break; 103 break;
104 case TODO_SILENT_ALARM_DATETIME: 104 case TODO_SILENT_ALARM_DATETIME:
105 dtp = &ToDo->Entries[j].Date ; 105 dtp = &ToDo->Entries[j].Date ;
106 alarm = true; 106 alarm = true;
107 alarmDt = fromGSM ( dtp ); 107 alarmDt = fromGSM ( dtp );
108 break; 108 break;
109 case TODO_TEXT: 109 case TODO_TEXT:
110 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text )); 110 //qDebug(" text *%s* ", (const char*) DecodeUnicodeConsole(ToDo->Entries[j].Text ));
111 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text ))); 111 todo->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole(ToDo->Entries[j].Text )));
112 break; 112 break;
113 case TODO_PRIVATE: 113 case TODO_PRIVATE:
114 if ( ToDo->Entries[j].Number == 1 ) 114 if ( ToDo->Entries[j].Number == 1 )
115 todo->setSecrecy( Incidence::SecrecyPrivate ); 115 todo->setSecrecy( Incidence::SecrecyPrivate );
116 else 116 else
117 todo->setSecrecy( Incidence::SecrecyPublic ); 117 todo->setSecrecy( Incidence::SecrecyPublic );
118 break; 118 break;
119 case TODO_CATEGORY: 119 case TODO_CATEGORY:
120 Category.Location = ToDo->Entries[j].Number; 120 Category.Location = ToDo->Entries[j].Number;
121 Category.Type = Category_ToDo; 121 Category.Type = Category_ToDo;
122 error=Phone->GetCategory(s, &Category); 122 error=Phone->GetCategory(s, &Category);
123 if (error == ERR_NONE) { 123 if (error == ERR_NONE) {
124 QStringList cat = todo->categories(); 124 QStringList cat = todo->categories();
125 QString nCat = QString ( (const char*)Category.Name ); 125 QString nCat = QString ( (const char*)Category.Name );
126 if ( !nCat.isEmpty() ) 126 if ( !nCat.isEmpty() )
127 if ( !cat.contains( nCat )) { 127 if ( !cat.contains( nCat )) {
128 cat << nCat; 128 cat << nCat;
129 todo->setCategories( cat ); 129 todo->setCategories( cat );
130 } 130 }
131 } 131 }
132 break; 132 break;
133 case TODO_CONTACTID: 133 case TODO_CONTACTID:
134#if 0 134#if 0
135 // not supported 135 // not supported
136 entry.Location = ToDo->Entries[j].Number; 136 entry.Location = ToDo->Entries[j].Number;
137 entry.MemoryType = MEM_ME; 137 entry.MemoryType = MEM_ME;
138 error=Phone->GetMemory(s, &entry); 138 error=Phone->GetMemory(s, &entry);
139 if (error == ERR_NONE) { 139 if (error == ERR_NONE) {
140 name = GSM_PhonebookGetEntryName(&entry); 140 name = GSM_PhonebookGetEntryName(&entry);
141 if (name != NULL) { 141 if (name != NULL) {
142 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number); 142 printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), ToDo->Entries[j].Number);
143 } else { 143 } else {
144 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number); 144 printmsg("Contact ID : %d\n",ToDo->Entries[j].Number);
145 } 145 }
146 } else { 146 } else {
147 printmsg("Contact : %d\n",ToDo->Entries[j].Number); 147 printmsg("Contact : %d\n",ToDo->Entries[j].Number);
148 } 148 }
149#endif 149#endif
150 break; 150 break;
151 case TODO_PHONE: 151 case TODO_PHONE:
152#if 0 152#if 0
153 // not supported 153 // not supported
154 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text)); 154 printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(ToDo->Entries[j].Text));
155#endif 155#endif
156 break; 156 break;
157 } 157 }
158 } 158 }
159 QString alarmString = "na"; 159 QString alarmString = "na";
160 if ( alarm ) { 160 if ( alarm ) {
161 Alarm *alarm; 161 Alarm *alarm;
162 if ( todo->alarms().count() > 0 ) 162 if ( todo->alarms().count() > 0 )
163 alarm = todo->alarms().first(); 163 alarm = todo->alarms().first();
164 else { 164 else {
165 alarm = new Alarm( todo ); 165 alarm = new Alarm( todo );
166 todo->addAlarm( alarm ); 166 todo->addAlarm( alarm );
167 } 167 }
168 alarm->setType( Alarm::Audio ); 168 alarm->setType( Alarm::Audio );
169 alarm->setEnabled( true ); 169 alarm->setEnabled( true );
170 int alarmOffset = alarmDt.secsTo( todo->dtStart() ); 170 int alarmOffset = alarmDt.secsTo( todo->dtStart() );
171 alarm->setStartOffset( -alarmOffset ); 171 alarm->setStartOffset( -alarmOffset );
172 alarmString = QString::number( alarmOffset ); 172 alarmString = QString::number( alarmOffset );
173 } else { 173 } else {
174 Alarm *alarm; 174 Alarm *alarm;
175 if ( todo->alarms().count() > 0 ) { 175 if ( todo->alarms().count() > 0 ) {
176 alarm = todo->alarms().first(); 176 alarm = todo->alarms().first();
177 alarm->setType( Alarm::Audio ); 177 alarm->setType( Alarm::Audio );
178 alarm->setStartOffset( -60*15 ); 178 alarm->setStartOffset( -60*15 );
179 alarm->setEnabled( false ); 179 alarm->setEnabled( false );
180 } 180 }
181 } 181 }
182 // csum ***************************************** 182 // csum *****************************************
183 uint cSum; 183 uint cSum;
184 cSum = PhoneFormat::getCsumTodo( todo ); 184 cSum = PhoneFormat::getCsumTodo( todo );
185 todo->setCsum( mProfileName, QString::number( cSum )); 185 todo->setCsum( mProfileName, QString::number( cSum ));
186 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL ); 186 todo->setTempSyncStat( SYNC_TEMPSTATE_NEW_EXTERNAL );
187 mCalendar->addTodo( todo); 187 mCalendar->addTodo( todo);
188 188
189 return true; 189 return true;
190 } 190 }
191 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note) 191 bool readEvent( Calendar *existingCalendar, GSM_CalendarEntry*Note)
192 { 192 {
193 193
194 int id = Note->Location; 194 int id = Note->Location;
195 Event *event; 195 Event *event;
196 event = existingCalendar->event( mProfileName ,QString::number( id ) ); 196 event = existingCalendar->event( mProfileName ,QString::number( id ) );
197 if ( event ) 197 if ( event )
198 event = (Event*)event->clone(); 198 event = (Event*)event->clone();
199 else 199 else
200 event = new Event; 200 event = new Event;
201 event->setID( mProfileName,QString::number( id ) ); 201 event->setID( mProfileName,QString::number( id ) );
202 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL ); 202 event->setTempSyncStat(SYNC_TEMPSTATE_NEW_EXTERNAL );
203 203
204 204
205 int i = 0; 205 int i = 0;
206 bool repeating = false; 206 bool repeating = false;
207 int repeat_dayofweek = -1; 207 int repeat_dayofweek = -1;
208 int repeat_day = -1; 208 int repeat_day = -1;
209 int repeat_weekofmonth = -1; 209 int repeat_weekofmonth = -1;
210 int repeat_month = -1; 210 int repeat_month = -1;
211 int repeat_frequency = -1; 211 int repeat_frequency = -1;
212 int rec_type = -1; 212 int rec_type = -1;
213 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0}; 213 GSM_DateTime repeat_startdate = {0,0,0,0,0,0,0};
214 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0}; 214 GSM_DateTime repeat_stopdate = {0,0,0,0,0,0,0};
215 GSM_DateTime* dtp; 215 GSM_DateTime* dtp;
216 bool alarm = false; 216 bool alarm = false;
217 QDateTime alarmDt; 217 QDateTime alarmDt;
218 repeat_startdate.Day= 0; 218 repeat_startdate.Day= 0;
219 repeat_stopdate.Day = 0; 219 repeat_stopdate.Day = 0;
220 for (i=0;i<Note->EntriesNum;i++) { 220 for (i=0;i<Note->EntriesNum;i++) {
221 221
222 //qDebug(" for ev"); 222 //qDebug(" for ev");
223 switch (Note->Entries[i].EntryType) { 223 switch (Note->Entries[i].EntryType) {
224 case CAL_START_DATETIME: 224 case CAL_START_DATETIME:
225 dtp = &Note->Entries[i].Date ; 225 dtp = &Note->Entries[i].Date ;
226 if ( dtp->Hour > 24 ) { 226 if ( dtp->Hour > 24 ) {
227 event->setFloats( true ); 227 event->setFloats( true );
228 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 228 event->setDtStart( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
229 } else { 229 } else {
230 event->setDtStart (fromGSM ( dtp )); 230 event->setDtStart (fromGSM ( dtp ));
231 231
232 } 232 }
233 //Note->Entries[i].Date.Hour = 5;
233 break; 234 break;
234 case CAL_END_DATETIME: 235 case CAL_END_DATETIME:
235 dtp = &Note->Entries[i].Date ; 236 dtp = &Note->Entries[i].Date ;
236 if ( dtp->Hour > 24 ) { 237 if ( dtp->Hour > 24 ) {
237 event->setFloats( true ); 238 event->setFloats( true );
238 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 ))); 239 event->setDtEnd( QDateTime (datefromGSM ( dtp ), QTime(0,0,0 )));
239 } else { 240 } else {
240 event->setDtEnd (fromGSM ( dtp )); 241 event->setDtEnd (fromGSM ( dtp ));
241 } 242 }
242 break; 243 break;
243 case CAL_ALARM_DATETIME: 244 case CAL_ALARM_DATETIME:
244 dtp = &Note->Entries[i].Date ; 245 dtp = &Note->Entries[i].Date ;
245 alarm = true; 246 alarm = true;
246 alarmDt = fromGSM ( dtp ); 247 alarmDt = fromGSM ( dtp );
247 break; 248 break;
248 case CAL_SILENT_ALARM_DATETIME: 249 case CAL_SILENT_ALARM_DATETIME:
249 dtp = &Note->Entries[i].Date ; 250 dtp = &Note->Entries[i].Date ;
250 alarm = true; 251 alarm = true;
251 alarmDt = fromGSM ( dtp ); 252 alarmDt = fromGSM ( dtp );
252 break; 253 break;
253 case CAL_RECURRANCE: 254 case CAL_RECURRANCE:
254 rec_type = Note->Entries[i].Number; 255 rec_type = Note->Entries[i].Number;
255 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" ); 256 //printmsg("Repeat : %d day%s\n",Note->Entries[i].Number/24,((Note->Entries[i].Number/24)>1) ? "s":"" );
256 break; 257 break;
257 case CAL_TEXT: 258 case CAL_TEXT:
258 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) ); 259 //qDebug(" ev text %s", DecodeUnicodeConsole(Note->Entries[i].Text) );
259 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text ))); 260 event->setSummary( QString::fromUtf8 ( (const char*)DecodeUnicodeConsole( Note->Entries[i].Text )));
260 break; 261 break;
261 case CAL_LOCATION: 262 case CAL_LOCATION:
262 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) )); 263 event->setLocation(QString::fromUtf8 ((const char*) DecodeUnicodeConsole(Note->Entries[i].Text) ));
263 break; 264 break;
264 case CAL_PHONE: 265 case CAL_PHONE:
265 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text)); 266 //printmsg("Phone : \"%s\"\n",DecodeUnicodeConsole(Note->Entries[i].Text));
266 break; 267 break;
267 case CAL_PRIVATE: 268 case CAL_PRIVATE:
268 if ( Note->Entries[i].Number == 1 ) 269 if ( Note->Entries[i].Number == 1 )
269 event->setSecrecy( Incidence::SecrecyPrivate ); 270 event->setSecrecy( Incidence::SecrecyPrivate );
270 else 271 else
271 event->setSecrecy( Incidence::SecrecyPublic ); 272 event->setSecrecy( Incidence::SecrecyPublic );
272 273
273 break; 274 break;
274 case CAL_CONTACTID: 275 case CAL_CONTACTID:
275#if 0 276#if 0
276 entry.Location = Note->Entries[i].Number; 277 entry.Location = Note->Entries[i].Number;
277 entry.MemoryType = MEM_ME; 278 entry.MemoryType = MEM_ME;
278 error=Phone->GetMemory(&s, &entry); 279 error=Phone->GetMemory(&s, &entry);
279 if (error == ERR_NONE) { 280 if (error == ERR_NONE) {
280 name = GSM_PhonebookGetEntryName(&entry); 281 name = GSM_PhonebookGetEntryName(&entry);
281 if (name != NULL) { 282 if (name != NULL) {
282 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number); 283 //printmsg("Contact ID : \"%s\" (%d)\n", DecodeUnicodeConsole(name), Note->Entries[i].Number);
283 } else { 284 } else {
284 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 285 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
285 } 286 }
286 } else { 287 } else {
287 //printmsg("Contact ID : %d\n",Note->Entries[i].Number); 288 //printmsg("Contact ID : %d\n",Note->Entries[i].Number);
288 } 289 }
289#endif 290#endif
290 break; 291 break;
291 case CAL_REPEAT_DAYOFWEEK: 292 case CAL_REPEAT_DAYOFWEEK:
292 repeat_dayofweek = Note->Entries[i].Number; 293 repeat_dayofweek = Note->Entries[i].Number;
293 repeating = true; 294 repeating = true;
294 break; 295 break;
295 case CAL_REPEAT_DAY: 296 case CAL_REPEAT_DAY:
296 repeat_day = Note->Entries[i].Number; 297 repeat_day = Note->Entries[i].Number;
297 repeating = true; 298 repeating = true;
298 break; 299 break;
299 case CAL_REPEAT_WEEKOFMONTH: 300 case CAL_REPEAT_WEEKOFMONTH:
300 repeat_weekofmonth = Note->Entries[i].Number; 301 repeat_weekofmonth = Note->Entries[i].Number;
301 repeating = true; 302 repeating = true;
302 break; 303 break;
303 case CAL_REPEAT_MONTH: 304 case CAL_REPEAT_MONTH:
304 repeat_month = Note->Entries[i].Number; 305 repeat_month = Note->Entries[i].Number;
305 repeating = true; 306 repeating = true;
306 break; 307 break;
307 case CAL_REPEAT_FREQUENCY: 308 case CAL_REPEAT_FREQUENCY:
308 repeat_frequency = Note->Entries[i].Number; 309 repeat_frequency = Note->Entries[i].Number;
309 repeating = true; 310 repeating = true;
310 break; 311 break;
311 case CAL_REPEAT_STARTDATE: 312 case CAL_REPEAT_STARTDATE:
312 repeat_startdate = Note->Entries[i].Date; 313 repeat_startdate = Note->Entries[i].Date;
313 repeating = true; 314 repeating = true;
314 break; 315 break;
315 case CAL_REPEAT_STOPDATE: 316 case CAL_REPEAT_STOPDATE:
316 repeat_stopdate = Note->Entries[i].Date; 317 repeat_stopdate = Note->Entries[i].Date;
317 repeating = true; 318 repeating = true;
318 break; 319 break;
319 } 320 }
320 } 321 }
321#if 0 322#if 0
322 event->setDescription( attList[4] ); 323 event->setDescription( attList[4] );
323 bool repeating = false; 324 bool repeating = false;
324 int repeat_dayofweek = -1; 325 int repeat_dayofweek = -1;
325 int repeat_day = -1; 326 int repeat_day = -1;
326 int repeat_weekofmonth = -1; 327 int repeat_weekofmonth = -1;
327 int repeat_month = -1; 328 int repeat_month = -1;
328 int repeat_frequency = -1; 329 int repeat_frequency = -1;
@@ -677,433 +678,593 @@ ulong PhoneFormat::getCsumEvent( Event* event )
677 //pending weekdays 678 //pending weekdays
678 writeEndDate = true; 679 writeEndDate = true;
679 680
680 break; 681 break;
681 case Recurrence::rMonthlyPos:// 2 682 case Recurrence::rMonthlyPos:// 2
682 list.append( "2" ); 683 list.append( "2" );
683 list.append( QString::number( rec->frequency()) );//12 684 list.append( QString::number( rec->frequency()) );//12
684 685
685 writeEndDate = true; 686 writeEndDate = true;
686 { 687 {
687 int count = 1; 688 int count = 1;
688 QPtrList<Recurrence::rMonthPos> rmp; 689 QPtrList<Recurrence::rMonthPos> rmp;
689 rmp = rec->monthPositions(); 690 rmp = rec->monthPositions();
690 if ( rmp.first()->negative ) 691 if ( rmp.first()->negative )
691 count = 5 - rmp.first()->rPos - 1; 692 count = 5 - rmp.first()->rPos - 1;
692 else 693 else
693 count = rmp.first()->rPos - 1; 694 count = rmp.first()->rPos - 1;
694 list.append( QString::number( count ) ); 695 list.append( QString::number( count ) );
695 696
696 } 697 }
697 698
698 list.append( "0" ); 699 list.append( "0" );
699 break; 700 break;
700 case Recurrence::rMonthlyDay:// 3 701 case Recurrence::rMonthlyDay:// 3
701 list.append( "3" ); 702 list.append( "3" );
702 list.append( QString::number( rec->frequency()) );//12 703 list.append( QString::number( rec->frequency()) );//12
703 list.append( "0" ); 704 list.append( "0" );
704 list.append( "0" ); 705 list.append( "0" );
705 writeEndDate = true; 706 writeEndDate = true;
706 break; 707 break;
707 case Recurrence::rYearlyMonth://4 708 case Recurrence::rYearlyMonth://4
708 list.append( "4" ); 709 list.append( "4" );
709 list.append( QString::number( rec->frequency()) );//12 710 list.append( QString::number( rec->frequency()) );//12
710 list.append( "0" ); 711 list.append( "0" );
711 list.append( "0" ); 712 list.append( "0" );
712 writeEndDate = true; 713 writeEndDate = true;
713 break; 714 break;
714 715
715 default: 716 default:
716 list.append( "255" ); 717 list.append( "255" );
717 list.append( QString() ); 718 list.append( QString() );
718 list.append( "0" ); 719 list.append( "0" );
719 list.append( QString() ); 720 list.append( QString() );
720 list.append( "0" ); 721 list.append( "0" );
721 list.append( "20991231T000000" ); 722 list.append( "20991231T000000" );
722 break; 723 break;
723 } 724 }
724 if ( writeEndDate ) { 725 if ( writeEndDate ) {
725 726
726 if ( rec->endDate().isValid() ) { // 15 + 16 727 if ( rec->endDate().isValid() ) { // 15 + 16
727 list.append( "1" ); 728 list.append( "1" );
728 list.append( PhoneParser::dtToString( rec->endDate()) ); 729 list.append( PhoneParser::dtToString( rec->endDate()) );
729 } else { 730 } else {
730 list.append( "0" ); 731 list.append( "0" );
731 list.append( "20991231T000000" ); 732 list.append( "20991231T000000" );
732 } 733 }
733 734
734 } 735 }
735 attList << list.join(""); 736 attList << list.join("");
736 attList << event->categoriesStr(); 737 attList << event->categoriesStr();
737 attList << event->secrecyStr(); 738 attList << event->secrecyStr();
738 return PhoneFormat::getCsum(attList ); 739 return PhoneFormat::getCsum(attList );
739} 740}
740ulong PhoneFormat::getCsum( const QStringList & attList) 741ulong PhoneFormat::getCsum( const QStringList & attList)
741{ 742{
742 int max = attList.count() -1; 743 int max = attList.count() -1;
743 ulong cSum = 0; 744 ulong cSum = 0;
744 int j,k,i; 745 int j,k,i;
745 int add; 746 int add;
746 for ( i = 1; i < max ; ++i ) { 747 for ( i = 1; i < max ; ++i ) {
747 QString s = attList[i]; 748 QString s = attList[i];
748 if ( ! s.isEmpty() ){ 749 if ( ! s.isEmpty() ){
749 j = s.length(); 750 j = s.length();
750 for ( k = 0; k < j; ++k ) { 751 for ( k = 0; k < j; ++k ) {
751 int mul = k +1; 752 int mul = k +1;
752 add = s[k].unicode (); 753 add = s[k].unicode ();
753 if ( k < 16 ) 754 if ( k < 16 )
754 mul = mul * mul; 755 mul = mul * mul;
755 add = add * mul *i*i*i; 756 add = add * mul *i*i*i;
756 cSum += add; 757 cSum += add;
757 } 758 }
758 } 759 }
759 } 760 }
760 return cSum; 761 return cSum;
761 762
762} 763}
763//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum); 764//extern "C" GSM_Error GSM_InitConnection(GSM_StateMachine *s, int ReplyNum);
764#include <stdlib.h> 765#include <stdlib.h>
765#define DEBUGMODE false 766#define DEBUGMODE false
766bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal) 767bool PhoneFormat::load( Calendar *calendar, Calendar *existingCal)
767{ 768{
768 GSM_StateMachines; 769 GSM_StateMachines;
769 qDebug(" load "); 770 qDebug(" load ");
770 s.opened = false; 771 s.opened = false;
771 s.msg = NULL; 772 s.msg = NULL;
772 s.ConfigNum = 0; 773 s.ConfigNum = 0;
773 QLabel status ( i18n("Reading data. Opening device ..."), 0 ); 774 QLabel status ( i18n("Opening device ..."), 0 );
774 int w = status.sizeHint().width()+20 ; 775 int w = status.sizeHint().width()+20 ;
775 if ( w < 200 ) w = 200; 776 if ( w < 200 ) w = 230;
776 int h = status.sizeHint().height()+20 ; 777 int h = status.sizeHint().height()+20 ;
777 int dw = QApplication::desktop()->width(); 778 int dw = QApplication::desktop()->width();
778 int dh = QApplication::desktop()->height(); 779 int dh = QApplication::desktop()->height();
779 status.setCaption(i18n("Reading Phone Data") ); 780 status.setCaption(i18n("Reading phone...") );
780 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 781 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
781 status.show(); 782 status.show();
782 status.raise(); 783 status.raise();
783 qApp->processEvents(); 784 qApp->processEvents();
784#if 0 785#if 0
785 static char*cp; 786 static char*cp;
786 static INI_Section *cfg = NULL; 787 static INI_Section *cfg = NULL;
787 cfg=GSM_FindGammuRC(); 788 cfg=GSM_FindGammuRC();
788 int i; 789 int i;
789 for (i = 0; i <= MAX_CONFIG_NUM; i++) { 790 for (i = 0; i <= MAX_CONFIG_NUM; i++) {
790 if (cfg!=NULL) { 791 if (cfg!=NULL) {
791 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false); 792 cp = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*)"gammucoding", false);
792 if (cp) di.coding = cp; 793 if (cp) di.coding = cp;
793 794
794 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false); 795 s.Config[i].Localize = (char *)INI_GetValue(cfg, (unsigned char*) "gammu", (unsigned char*) "gammuloc", false);
795 if (s.Config[i].Localize) { 796 if (s.Config[i].Localize) {
796 s.msg=INI_ReadFile(s.Config[i].Localize, true); 797 s.msg=INI_ReadFile(s.Config[i].Localize, true);
797 } else { 798 } else {
798#if !defined(WIN32) && defined(LOCALE_PATH) 799#if !defined(WIN32) && defined(LOCALE_PATH)
799 locale = setlocale(LC_MESSAGES, NULL); 800 locale = setlocale(LC_MESSAGES, NULL);
800 if (locale != NULL) { 801 if (locale != NULL) {
801 snprintf(locale_file, 200, "%s/gammu_%c%c.txt", 802 snprintf(locale_file, 200, "%s/gammu_%c%c.txt",
802 LOCALE_PATH, 803 LOCALE_PATH,
803 tolower(locale[0]), 804 tolower(locale[0]),
804 tolower(locale[1])); 805 tolower(locale[1]));
805 s.msg = INI_ReadFile(locale_file, true); 806 s.msg = INI_ReadFile(locale_file, true);
806 } 807 }
807#endif 808#endif
808 } 809 }
809 } 810 }
810 811
811 /* Wanted user specific configuration? */ 812 /* Wanted user specific configuration? */
812 813
813 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break; 814 if (!GSM_ReadConfig(cfg, &s.Config[i], i) && i != 0) break;
814 815
815 s.ConfigNum++; 816 s.ConfigNum++;
816 817
817 /* We want to use only one file descriptor for global and state machine debug output */ 818 /* We want to use only one file descriptor for global and state machine debug output */
818 s.Config[i].UseGlobalDebugFile = true; 819 s.Config[i].UseGlobalDebugFile = true;
819 820
820 821
821 822
822 /* We wanted to read just user specified configuration. */ 823 /* We wanted to read just user specified configuration. */
823 {break;} 824 {break;}
824 } 825 }
825 826
826#endif 827#endif
827 int error=initDevice(&s); 828 int error=initDevice(&s);
828 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 829 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
829 if ( error != ERR_NONE ) 830 if ( error != ERR_NONE )
830 return false; 831 return false;
831 GSM_Phone_Functions*Phone; 832 GSM_Phone_Functions*Phone;
832 GSM_CalendarEntrynote; 833 GSM_CalendarEntrynote;
833 bool start = true; 834 bool start = true;
834 Phone=s.Phone.Functions; 835 Phone=s.Phone.Functions;
835 bool gshutdown = false; 836 bool gshutdown = false;
836 PhoneParser handler( calendar, mProfileName ); 837 PhoneParser handler( calendar, mProfileName );
837 int ccc = 0; 838 int ccc = 0;
838 QString message = i18n("Processing event # "); 839 QString message = i18n(" Reading event # ");
839 int procCount = 0; 840 int procCount = 0;
840 qDebug("Debug: only 10 calender items are downloaded "); 841 qDebug("Debug: only 10 calender items are downloaded ");
841 while (!gshutdown && ccc++ < 10) { 842 while (!gshutdown && ccc++ < 10) {
842 status.setText ( message + QString::number ( ++procCount ) ); 843 status.setText ( message + QString::number ( ++procCount ) );
843 qApp->processEvents(); 844 qApp->processEvents();
844 qDebug("readEvent %d ", ccc); 845 qDebug("readEvent %d ", ccc);
845 error=Phone->GetNextCalendar(&s,&note,start); 846 error=Phone->GetNextCalendar(&s,&note,start);
846 if (error == ERR_EMPTY) break; 847 if (error == ERR_EMPTY) break;
847 start = false; 848 start = false;
848 handler.readEvent( existingCal, &note ); 849 handler.readEvent( existingCal, &note );
850 qDebug("Org loc %d ",note.Location);
851 //note.Location = 0;
852 error=Phone->SetCalendar(&s,&note);
853 qDebug("new loc %d ",note.Location);
849 } 854 }
850 855
851 start = true; 856 start = true;
852 GSM_ToDoEntry ToDo; 857 GSM_ToDoEntry ToDo;
853 ccc = 0; 858 ccc = 0;
854 message = i18n("Processing todo # "); 859 message = i18n(" Reading todo # ");
855 procCount = 0; 860 procCount = 0;
856 while (!gshutdown) { 861 while (!gshutdown && ccc++ < 10) {
857 status.setText ( message + QString::number ( ++procCount ) ); 862 status.setText ( message + QString::number ( ++procCount ) );
858 qApp->processEvents(); 863 qApp->processEvents();
859 error = Phone->GetNextToDo(&s, &ToDo, start); 864 error = Phone->GetNextToDo(&s, &ToDo, start);
860 if (error == ERR_EMPTY) break; 865 if (error == ERR_EMPTY) break;
861 start = false; 866 start = false;
862 qDebug("ReadTodo %d ", ++ccc); 867 qDebug("ReadTodo %d ", ccc);
863 handler.readTodo( existingCal, &ToDo, &s); 868 handler.readTodo( existingCal, &ToDo, &s);
864 869
865 } 870 }
866 871
867 error=GSM_TerminateConnection(&s); 872 error=GSM_TerminateConnection(&s);
868 873
869 return true; 874 return true;
870} 875}
871void PhoneFormat::event2GSM( Event* ev, GSM_CalendarEntry*Note ) 876#include <qcstring.h>
877void PhoneFormat::event2GSM( Calendar *cal,Event* ev, GSM_CalendarEntry*Note )
872{ 878{
873 QString eText = vfconverter.eventToString( ev ); 879 QString eText = vfconverter.eventToString( ev, cal );
874 int pos = 0; 880 int pos = 0;
875 GSM_ToDoEntry dummy; 881 GSM_ToDoEntry dummy;
876 GSM_DecodeVCALENDAR_VTODO( (unsigned char*)eText.latin1(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo ); 882 qDebug( "Convert event");
883 QByteArray ba;
884 QDataStream s ( ba, IO_WriteOnly );
885 s << eText.utf8();
886 GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, Note , &dummy, Nokia_VCalendar, Nokia_VToDo );
887 qDebug( "Convert event done");
888 Note->Location = 0;
889 QString loc = ev->getID(mProfileName);
890 if ( !loc.isEmpty() ){
891 Note->Location = loc.toInt();
892 }
893
877} 894}
878void PhoneFormat::todo2GSM( Todo* todo, GSM_ToDoEntry *gsmTodo ) 895void PhoneFormat::todo2GSM( Calendar *cal, Todo* todo, GSM_ToDoEntry *gsmTodo )
879{ 896{
880 QString tText = vfconverter.todoToString( todo ); 897 qDebug( "Convert todo1");
898 QString tText = vfconverter.todoToString( todo, cal );
881 int pos = 0; 899 int pos = 0;
882 GSM_CalendarEntry dummy; 900 GSM_CalendarEntry dummy;
883 GSM_DecodeVCALENDAR_VTODO( (unsigned char*)tText.latin1(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo ); 901 QByteArray ba;
902 QDataStream s ( ba, IO_WriteOnly );
903 s << tText.utf8();
904 GSM_DecodeVCALENDAR_VTODO( (unsigned char*) ba.data(), &pos, &dummy, gsmTodo, Nokia_VCalendar, Nokia_VToDo );
905 qDebug( "Convert todo done ");
906 gsmTodo->Location = 0;
907 QString loc = todo->getID(mProfileName);
908 if ( !loc.isEmpty() ){
909 gsmTodo->Location = loc.toInt();
910 }
911
884} 912}
885void PhoneFormat::afterSave( Incidence* inc) 913void PhoneFormat::afterSave( Incidence* inc)
886{ 914{
887 uint csum; 915 uint csum;
888 if ( inc->type() == "Event") 916 if ( inc->type() == "Event")
889 csum = PhoneFormat::getCsumEvent( (Event*) inc ); 917 csum = PhoneFormat::getCsumEvent( (Event*) inc );
890 else 918 else
891 csum = PhoneFormat::getCsumTodo( (Todo*) inc ); 919 csum = PhoneFormat::getCsumTodo( (Todo*) inc );
892 inc->setCsum( mProfileName, QString::number( csum )); 920 inc->setCsum( mProfileName, QString::number( csum ));
893 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID ); 921 inc->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
894 922
895} 923}
896bool PhoneFormat::save( Calendar *calendar) 924bool PhoneFormat::save( Calendar *calendar)
897{ 925{
926 return true;
898 GSM_StateMachines; 927 GSM_StateMachines;
899 qDebug(" save "); 928 qDebug(" save ");
900 s.opened = false; 929 s.opened = false;
901 s.msg = NULL; 930 s.msg = NULL;
902 s.ConfigNum = 0; 931 s.ConfigNum = 0;
903 QLabel status ( i18n("Writing data. Opening device ..."), 0 ); 932 QLabel status ( i18n(" Opening device ..."), 0 );
904 int w = status.sizeHint().width()+20 ; 933 int w = status.sizeHint().width()+20 ;
905 if ( w < 200 ) w = 200; 934 if ( w < 200 ) w = 230;
906 int h = status.sizeHint().height()+20 ; 935 int h = status.sizeHint().height()+20 ;
907 int dw = QApplication::desktop()->width(); 936 int dw = QApplication::desktop()->width();
908 int dh = QApplication::desktop()->height(); 937 int dh = QApplication::desktop()->height();
909 status.setCaption(i18n("Writing Phone Data") ); 938 status.setCaption(i18n("Writing to phone...") );
910 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h ); 939 status.setGeometry( (dw-w)/2, (dh - h )/2 ,w,h );
911 status.show(); 940 status.show();
912 status.raise(); 941 status.raise();
913 qApp->processEvents(); 942 qApp->processEvents();
914 943
915 int error=initDevice(&s); 944 int error=initDevice(&s);
916 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE); 945 qDebug("GSM Init %d (no error is %d)", error, ERR_NONE);
917 if ( error != ERR_NONE ) 946 if ( error != ERR_NONE )
918 return false; 947 return false;
919 GSM_Phone_Functions*Phone; 948 GSM_Phone_Functions*Phone;
920 GSM_CalendarEntryNote; 949 GSM_CalendarEntryNote;
921 bool start = true; 950 bool start = true;
922 Phone=s.Phone.Functions; 951 Phone=s.Phone.Functions;
923 bool gshutdown = false; 952 bool gshutdown = false;
924 QPtrList<Event> er = calendar->rawEvents(); 953 QPtrList<Event> er = calendar->rawEvents();
925 Event* ev = er.first(); 954 Event* ev = er.first();
926 QString message = i18n("Processing event # "); 955 QString message = i18n(" Processing event # ");
927 int procCount = 0; 956 int procCount = 0;
928 while ( ev ) { 957 bool planB = true;// false;
929 //qDebug("i %d ", ++i); 958 while ( ev && ! planB) {
930 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one 959 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { // event was changed during sync or is a new one
931 960
932 status.setText ( message + QString::number ( ++procCount ) ); 961 status.setText ( message + QString::number ( ++procCount ) );
933 qApp->processEvents(); 962 qApp->processEvents();
934 event2GSM( ev, &Note ); 963 qDebug("event1 %d ", procCount);
964 event2GSM( calendar, ev, &Note );
935 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 965 if ( ev->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
936 error = Phone->DeleteCalendar(&s, &Note); 966 error = Phone->DeleteCalendar(&s, &Note);
967 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
968 planB = true;
969 qDebug(" e delete planB %d ", error);
970 break;
971 }
937 } 972 }
938 else if ( ev->getID(mProfileName).isEmpty() ) { // add new 973 else if ( ev->getID(mProfileName).isEmpty() ) { // add new
939 // we have to do this later after deleting 974 // we have to do this later after deleting
940 975
941 } 976 }
942 else { // change existing 977 else { // change existing
943 error = Phone->SetCalendar(&s, &Note); 978 error = Phone->SetCalendar(&s, &Note);
979 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
980 planB = true;
981 qDebug(" e change planB %d ", error);
982 break;
983 }
984 qDebug("Change Calendar. Location %d status: %d",Note.Location, error );
944 } 985 }
945 } 986 }
946 ev = er.next(); 987 ev = er.next();
947 } 988 }
948 ev = er.first(); 989 ev = er.first();
949 // pending get empty slots 990 // pending get empty slots
950 while ( ev ) { 991 int loc = 0;
992 while ( ev && ! planB) {
951 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 993 if ( ev->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && ev->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
994 qDebug("event2 %d ", procCount);
952 if ( ev->getID(mProfileName).isEmpty() ) { 995 if ( ev->getID(mProfileName).isEmpty() ) {
953 status.setText ( message + QString::number ( ++procCount ) ); 996 status.setText ( message + QString::number ( ++procCount ) );
954 qApp->processEvents(); 997 qApp->processEvents();
955 //int newID ;//= pending 998 //int newID ;//= pending
956 //ev->setID(mProfileName, QString::number( newID )); 999 //ev->setID(mProfileName, QString::number( newID ));
957 event2GSM( ev, &Note ); 1000 event2GSM( calendar, ev, &Note );
958 Note.Location = 0; 1001 ++loc;
1002 Note.Location = loc;
959 error = Phone->AddCalendar(&s, &Note); 1003 error = Phone->AddCalendar(&s, &Note);
1004 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1005 planB = true;
1006 qDebug(" e add planB %d ", error);
1007 break;
1008 }
960 ev->setID( mProfileName, QString::number( Note.Location ) ); 1009 ev->setID( mProfileName, QString::number( Note.Location ) );
961 qDebug("New Calendar. Location %d ",Note.Location ); 1010 qDebug("New Calendar. Location %d stat %d %d",Note.Location ,error, ERR_UNKNOWN);
962 afterSave( ev ); 1011 afterSave( ev );
963 } else { 1012 } else {
964 afterSave( ev ); // setting temp sync stat for changed items 1013 afterSave( ev ); // setting temp sync stat for changed items
965 } 1014 }
966 } 1015 }
967 ev = er.next(); 1016 ev = er.next();
968 } 1017 }
1018
1019
1020 if ( planB ) {
1021 qDebug("delete all calendar...");
1022 status.setText ( i18n("Deleting all calendar..."));
1023 qApp->processEvents();
1024 error=Phone->DeleteAllCalendar(&s);
1025 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1026 message = i18n(" Deleting event # ");
1027 procCount = 0;
1028 while (1) {
1029 status.setText ( message + QString::number ( ++procCount ) );
1030 qApp->processEvents();
1031 qDebug("deleting event ... %d", procCount);
1032 error = Phone->GetNextCalendar(&s,&Note,true);
1033 if (error != ERR_NONE) break;
1034 error = Phone->DeleteCalendar(&s,&Note);
1035 }
1036 qDebug("deleting calendar ... finished");
1037 } else {
1038 status.setText ( i18n("All calendar deleted!"));
1039 qDebug("all cal deleted");
1040 }
1041 bool planC = false;
1042 ev = er.first();
1043 procCount = 0;
1044 message = i18n(" Writing event # ");
1045 while ( ev && ! planC) {
1046 status.setText ( message + QString::number ( ++procCount ) );
1047 qApp->processEvents();
1048 event2GSM( calendar, ev, &Note );
1049 Note.Location = procCount;
1050 error=Phone->AddCalendar(&s,&Note);
1051 if (error != ERR_NONE ) {
1052 // we have currently no planC :-(
1053 // planC = true;
1054 //qDebug("add planC %d ", error);
1055 //break;
1056 // we remove the ID such that this todo is not deleted after next sync
1057 ev->removeID(mProfileName);
1058 ev->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1059 qDebug("error :cal adding loc %d planB stat %d ", Note.Location ,error);
1060 } else {
1061 qDebug("cal adding loc %d planB stat %d ", Note.Location ,error);
1062 ev->setID(mProfileName, QString::number( Note.Location ));
1063 afterSave( ev );
1064 }
1065 ev = er.next();
1066 }
1067 if ( planC ) {
1068 qDebug("writing cal went wrong...");
1069
1070 // we have currently no planC :-(
1071 }
1072 }
969 GSM_ToDoEntry ToDoEntry; 1073 GSM_ToDoEntry ToDoEntry;
970 QPtrList<Todo> tl = calendar->rawTodos(); 1074 QPtrList<Todo> tl = calendar->rawTodos();
971 Todo* to = tl.first(); 1075 Todo* to = tl.first();
972 1076
973 message = i18n("Processing todo # "); 1077 message = i18n(" Processing todo # ");
974 procCount = 0; 1078 procCount = 0;
975 while ( to ) { 1079 planB = false;
1080 while ( to && ! planB ) {
976 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) { 1081 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL ) {
1082 qDebug("todo3 %d ", procCount);
977 status.setText ( message + QString::number ( ++procCount ) ); 1083 status.setText ( message + QString::number ( ++procCount ) );
978 qApp->processEvents(); 1084 qApp->processEvents();
979 todo2GSM( to, &ToDoEntry ); 1085 qDebug("todo5 %d ", procCount);
1086 todo2GSM( calendar, to, &ToDoEntry );
980 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete 1087 if ( to->tempSyncStat() == SYNC_TEMPSTATE_DELETE ) { // delete
981 error=Phone->DeleteToDo(&s,&ToDoEntry); 1088 error=Phone->DeleteToDo(&s,&ToDoEntry);
1089 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1090 planB = true;
1091 qDebug("delete planB %d ", error);
1092 }
982 } 1093 }
983 else if ( to->getID("Sharp_DTM").isEmpty() ) { // add new 1094 else if ( to->getID(mProfileName).isEmpty() ) { // add new
984 ; 1095 ;
985 } 1096 }
986 else { // change existing 1097 else { // change existing
987 error=Phone->SetToDo(&s,&ToDoEntry); 1098 error=Phone->SetToDo(&s,&ToDoEntry);
1099 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1100 planB = true;
1101 qDebug("set planB %d ", error);
1102 }
1103 qDebug("Old Todo. Location %d %d",ToDoEntry.Location , error );
988 } 1104 }
989 } 1105 }
990 to = tl.next(); 1106 to = tl.next();
991 } 1107 }
992 1108
993 // pending get empty slots 1109 // pending get empty slots
994 to = tl.first(); 1110 to = tl.first();
995 while ( to ) { 1111 while ( to && ! planB ) {
1112 qDebug("todo2 %d ", procCount);
996 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) { 1113 if ( to->tempSyncStat() != SYNC_TEMPSTATE_NEW_EXTERNAL && to->tempSyncStat() != SYNC_TEMPSTATE_DELETE) {
1114 qDebug("todo4 %d ", procCount);
997 if ( to->getID(mProfileName).isEmpty() ) { 1115 if ( to->getID(mProfileName).isEmpty() ) {
998 status.setText ( message + QString::number ( ++procCount ) ); 1116 status.setText ( message + QString::number ( ++procCount ) );
999 qApp->processEvents(); 1117 qApp->processEvents();
1000 //int newID ;//= pending 1118 //int newID ;//= pending
1001 //to->setID(mProfileName, QString::number( newID )); 1119 //to->setID(mProfileName, QString::number( newID ));
1002 todo2GSM( to, &ToDoEntry ); 1120 todo2GSM( calendar,to, &ToDoEntry );
1003 ToDoEntry.Location = 0; 1121 ToDoEntry.Location = 0;
1004 error=Phone->AddToDo(&s,&ToDoEntry); 1122 error=Phone->AddToDo(&s,&ToDoEntry);
1123 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1124 planB = true;
1125 qDebug("new planB %d ", error);
1126 }
1005 to->setID(mProfileName, QString::number( ToDoEntry.Location )); 1127 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1006 afterSave( to ); 1128 afterSave( to );
1007 qDebug("New Todo. Location %d ",ToDoEntry.Location ); 1129 qDebug("New Todo. Location %d %d",ToDoEntry.Location, error );
1008 } else { 1130 } else {
1009 afterSave( to ); 1131 afterSave( to );
1010 } 1132 }
1011 } 1133 }
1012 to = tl.next(); 1134 to = tl.next();
1013 } 1135 }
1136 if ( planB ) {
1137 qDebug("delete all ...");
1138 error=Phone->DeleteAllToDo(&s);
1139 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1140 while (1) {
1141 qDebug("deleting todo ...");
1142 error = Phone->GetNextToDo(&s,&ToDoEntry,true);
1143 if (error != ERR_NONE) break;
1144 error = Phone->DeleteToDo(&s,&ToDoEntry);
1145 }
1146 qDebug("deleting todo ... finished");
1147 } else {
1148 qDebug("all todo deleted");
1149 }
1150 bool planC = false;
1151 to = tl.first();
1152 while ( to && ! planC ) {
1153 todo2GSM( calendar,to, &ToDoEntry );
1154 ToDoEntry.Location = 0;
1155 error=Phone->AddToDo(&s,&ToDoEntry);
1156 if (error == ERR_NOTSUPPORTED || error == ERR_NOTIMPLEMENTED) {
1157 // we have currently no planC :-(
1158 // planC = true;
1159 //qDebug("add planC %d ", error);
1160 //break;
1161 // we remove the ID such that this todo is not deleted after next sync
1162 to->removeID(mProfileName);
1163 to->setTempSyncStat( SYNC_TEMPSTATE_NEW_ID );
1164 } else {
1165 qDebug("adding %d planB %d ", ToDoEntry.Location ,error);
1166 to->setID(mProfileName, QString::number( ToDoEntry.Location ));
1167 afterSave( to );
1168 }
1169 to = tl.next();
1170 }
1171 if ( planC ) {
1172 // we have currently no planC :-(
1173 }
1174 }
1014 return true; 1175 return true;
1015} 1176}
1016QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ ) 1177QString PhoneFormat::dtToGSM( const QDateTime& dti, bool useTZ )
1017{ 1178{
1018 QString datestr; 1179 QString datestr;
1019 QString timestr; 1180 QString timestr;
1020 int offset = KGlobal::locale()->localTimeOffset( dti ); 1181 int offset = KGlobal::locale()->localTimeOffset( dti );
1021 QDateTime dt; 1182 QDateTime dt;
1022 if (useTZ) 1183 if (useTZ)
1023 dt = dti.addSecs ( -(offset*60)); 1184 dt = dti.addSecs ( -(offset*60));
1024 else 1185 else
1025 dt = dti; 1186 dt = dti;
1026 if(dt.date().isValid()){ 1187 if(dt.date().isValid()){
1027 const QDate& date = dt.date(); 1188 const QDate& date = dt.date();
1028 datestr.sprintf("%04d%02d%02d", 1189 datestr.sprintf("%04d%02d%02d",
1029 date.year(), date.month(), date.day()); 1190 date.year(), date.month(), date.day());
1030 } 1191 }
1031 if(dt.time().isValid()){ 1192 if(dt.time().isValid()){
1032 const QTime& time = dt.time(); 1193 const QTime& time = dt.time();
1033 timestr.sprintf("T%02d%02d%02d", 1194 timestr.sprintf("T%02d%02d%02d",
1034 time.hour(), time.minute(), time.second()); 1195 time.hour(), time.minute(), time.second());
1035 } 1196 }
1036 return datestr + timestr; 1197 return datestr + timestr;
1037} 1198}
1038QString PhoneFormat::getEventString( Event* event ) 1199QString PhoneFormat::getEventString( Event* event )
1039{ 1200{
1040#if 0 1201#if 0
1041 QStringList list; 1202 QStringList list;
1042 list.append( QString::number(event->zaurusId() ) ); 1203 list.append( QString::number(event->zaurusId() ) );
1043 list.append( event->categories().join(",") ); 1204 list.append( event->categories().join(",") );
1044 if ( !event->summary().isEmpty() ) 1205 if ( !event->summary().isEmpty() )
1045 list.append( event->summary() ); 1206 list.append( event->summary() );
1046 else 1207 else
1047 list.append("" ); 1208 list.append("" );
1048 if ( !event->location().isEmpty() ) 1209 if ( !event->location().isEmpty() )
1049 list.append( event->location() ); 1210 list.append( event->location() );
1050 else 1211 else
1051 list.append("" ); 1212 list.append("" );
1052 if ( !event->description().isEmpty() ) 1213 if ( !event->description().isEmpty() )
1053 list.append( event->description() ); 1214 list.append( event->description() );
1054 else 1215 else
1055 list.append( "" ); 1216 list.append( "" );
1056 if ( event->doesFloat () ) { 1217 if ( event->doesFloat () ) {
1057 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false )); 1218 list.append( dtToString( QDateTime(event->dtStart().date(), QTime(0,0,0)), false ));
1058 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6 1219 list.append( dtToString( QDateTime(event->dtEnd().date(),QTime(23,59,59)), false )); //6
1059 list.append( "1" ); 1220 list.append( "1" );
1060 1221
1061 } 1222 }
1062 else { 1223 else {
1063 list.append( dtToString( event->dtStart()) ); 1224 list.append( dtToString( event->dtStart()) );
1064 list.append( dtToString( event->dtEnd()) ); //6 1225 list.append( dtToString( event->dtEnd()) ); //6
1065 list.append( "0" ); 1226 list.append( "0" );
1066 } 1227 }
1067 bool noAlarm = true; 1228 bool noAlarm = true;
1068 if ( event->alarms().count() > 0 ) { 1229 if ( event->alarms().count() > 0 ) {
1069 Alarm * al = event->alarms().first(); 1230 Alarm * al = event->alarms().first();
1070 if ( al->enabled() ) { 1231 if ( al->enabled() ) {
1071 noAlarm = false; 1232 noAlarm = false;
1072 list.append( "0" ); // yes, 0 == alarm 1233 list.append( "0" ); // yes, 0 == alarm
1073 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) ); 1234 list.append( QString::number( al->startOffset().asSeconds()/(-60) ) );
1074 if ( al->type() == Alarm::Audio ) 1235 if ( al->type() == Alarm::Audio )
1075 list.append( "1" ); // type audio 1236 list.append( "1" ); // type audio
1076 else 1237 else
1077 list.append( "0" ); // type silent 1238 list.append( "0" ); // type silent
1078 } 1239 }
1079 } 1240 }
1080 if ( noAlarm ) { 1241 if ( noAlarm ) {
1081 list.append( "1" ); // yes, 1 == no alarm 1242 list.append( "1" ); // yes, 1 == no alarm
1082 list.append( "0" ); // no alarm offset 1243 list.append( "0" ); // no alarm offset
1083 list.append( "1" ); // type 1244 list.append( "1" ); // type
1084 } 1245 }
1085 // next is: 11 1246 // next is: 11
1086 // next is: 11-16 are recurrence 1247 // next is: 11-16 are recurrence
1087 Recurrence* rec = event->recurrence(); 1248 Recurrence* rec = event->recurrence();
1088 1249
1089 bool writeEndDate = false; 1250 bool writeEndDate = false;
1090 switch ( rec->doesRecur() ) 1251 switch ( rec->doesRecur() )
1091 { 1252 {
1092 case Recurrence::rDaily: // 0 1253 case Recurrence::rDaily: // 0
1093 list.append( "0" ); 1254 list.append( "0" );
1094 list.append( QString::number( rec->frequency() ));//12 1255 list.append( QString::number( rec->frequency() ));//12
1095 list.append( "0" ); 1256 list.append( "0" );
1096 list.append( "0" ); 1257 list.append( "0" );
1097 writeEndDate = true; 1258 writeEndDate = true;
1098 break; 1259 break;
1099 case Recurrence::rWeekly:// 1 1260 case Recurrence::rWeekly:// 1
1100 list.append( "1" ); 1261 list.append( "1" );
1101 list.append( QString::number( rec->frequency()) );//12 1262 list.append( QString::number( rec->frequency()) );//12
1102 list.append( "0" ); 1263 list.append( "0" );
1103 { 1264 {
1104 int days = 0; 1265 int days = 0;
1105 QBitArray weekDays = rec->days(); 1266 QBitArray weekDays = rec->days();
1106 int i; 1267 int i;
1107 for( i = 1; i <= 7; ++i ) { 1268 for( i = 1; i <= 7; ++i ) {
1108 if ( weekDays[i-1] ) { 1269 if ( weekDays[i-1] ) {
1109 days += 1 << (i-1); 1270 days += 1 << (i-1);
diff --git a/libkcal/phoneformat.h b/libkcal/phoneformat.h
index 33b2091..2c2e51c 100644
--- a/libkcal/phoneformat.h
+++ b/libkcal/phoneformat.h
@@ -1,67 +1,67 @@
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 "vcalformat.h" 28#include "vcalformat.h"
29#include "calformat.h" 29#include "calformat.h"
30extern "C" { 30extern "C" {
31#include "../gammu/emb/common/gammu.h" 31#include "../gammu/emb/common/gammu.h"
32} 32}
33namespace KCal { 33namespace KCal {
34 34
35/** 35/**
36 This class implements the calendar format used by Phone. 36 This class implements the calendar format used by Phone.
37*/ 37*/
38 class Event; 38 class Event;
39 class Todo; 39 class Todo;
40class PhoneFormat : public QObject { 40class PhoneFormat : public QObject {
41 public: 41 public:
42 /** Create new iCalendar format. */ 42 /** Create new iCalendar format. */
43 PhoneFormat(QString profileName, QString device,QString connection, QString model); 43 PhoneFormat(QString profileName, QString device,QString connection, QString model);
44 virtual ~PhoneFormat(); 44 virtual ~PhoneFormat();
45 45
46 bool load( Calendar * ,Calendar * ); 46 bool load( Calendar * ,Calendar * );
47 bool save( Calendar * ); 47 bool save( Calendar * );
48 bool fromString( Calendar *, const QString & ); 48 bool fromString( Calendar *, const QString & );
49 QString toString( Calendar * ); 49 QString toString( Calendar * );
50 static ulong getCsum( const QStringList & ); 50 static ulong getCsum( const QStringList & );
51 static ulong getCsumTodo( Todo* to ); 51 static ulong getCsumTodo( Todo* to );
52 static ulong getCsumEvent( Event* ev ); 52 static ulong getCsumEvent( Event* ev );
53 private: 53 private:
54 VCalFormat vfconverter; 54 VCalFormat vfconverter;
55 void event2GSM( Event* ev, GSM_CalendarEntry*Note ); 55 void event2GSM( Calendar *, Event* ev, GSM_CalendarEntry*Note );
56 void todo2GSM( Todo* ev, GSM_ToDoEntry *ToDo ); 56 void todo2GSM( Calendar *, Todo* ev, GSM_ToDoEntry *ToDo );
57 int initDevice(GSM_StateMachine *s); 57 int initDevice(GSM_StateMachine *s);
58 QString getEventString( Event* ); 58 QString getEventString( Event* );
59 QString getTodoString( Todo* ); 59 QString getTodoString( Todo* );
60 QString dtToGSM( const QDateTime& dt, bool useTZ = true ); 60 QString dtToGSM( const QDateTime& dt, bool useTZ = true );
61 QString mProfileName, mDevice, mConnection, mModel; 61 QString mProfileName, mDevice, mConnection, mModel;
62 void afterSave( Incidence* ); 62 void afterSave( Incidence* );
63}; 63};
64 64
65} 65}
66 66
67#endif 67#endif
diff --git a/libkcal/vcalformat.cpp b/libkcal/vcalformat.cpp
index 1167e58..076cd3f 100644
--- a/libkcal/vcalformat.cpp
+++ b/libkcal/vcalformat.cpp
@@ -1,275 +1,278 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brwon 3 Copyright (c) 1998 Preston Brwon
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#include <qapplication.h> 22#include <qapplication.h>
23#include <qdatetime.h> 23#include <qdatetime.h>
24#include <qstring.h> 24#include <qstring.h>
25#include <qptrlist.h> 25#include <qptrlist.h>
26#include <qregexp.h> 26#include <qregexp.h>
27#include <qclipboard.h> 27#include <qclipboard.h>
28#include <qdialog.h> 28#include <qdialog.h>
29#include <qfile.h> 29#include <qfile.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kmessagebox.h> 32#include <kmessagebox.h>
33#include <kiconloader.h> 33#include <kiconloader.h>
34#include <klocale.h> 34#include <klocale.h>
35 35
36#include "vcc.h" 36#include "vcc.h"
37#include "vobject.h" 37#include "vobject.h"
38 38
39#include "vcaldrag.h" 39#include "vcaldrag.h"
40#include "calendar.h" 40#include "calendar.h"
41 41
42#include "vcalformat.h" 42#include "vcalformat.h"
43 43
44using namespace KCal; 44using namespace KCal;
45 45
46VCalFormat::VCalFormat() 46VCalFormat::VCalFormat()
47{ 47{
48 mCalendar = 0;
48} 49}
49 50
50VCalFormat::~VCalFormat() 51VCalFormat::~VCalFormat()
51{ 52{
52} 53}
53 54
54bool VCalFormat::load(Calendar *calendar, const QString &fileName) 55bool VCalFormat::load(Calendar *calendar, const QString &fileName)
55{ 56{
56 mCalendar = calendar; 57 mCalendar = calendar;
57 58
58 clearException(); 59 clearException();
59 60
60 kdDebug(5800) << "VCalFormat::load() " << fileName << endl; 61 kdDebug(5800) << "VCalFormat::load() " << fileName << endl;
61 62
62 VObject *vcal = 0; 63 VObject *vcal = 0;
63 64
64 // this is not necessarily only 1 vcal. Could be many vcals, or include 65 // this is not necessarily only 1 vcal. Could be many vcals, or include
65 // a vcard... 66 // a vcard...
66 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data())); 67 vcal = Parse_MIME_FromFileName(const_cast<char *>(QFile::encodeName(fileName).data()));
67 68
68 if (!vcal) { 69 if (!vcal) {
69 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown)); 70 setException(new ErrorFormat(ErrorFormat::CalVersionUnknown));
70 return FALSE; 71 return FALSE;
71 } 72 }
72 73
73 // any other top-level calendar stuff should be added/initialized here 74 // any other top-level calendar stuff should be added/initialized here
74 75
75 // put all vobjects into their proper places 76 // put all vobjects into their proper places
76 populate(vcal); 77 populate(vcal);
77 78
78 // clean up from vcal API stuff 79 // clean up from vcal API stuff
79 cleanVObjects(vcal); 80 cleanVObjects(vcal);
80 cleanStrTbl(); 81 cleanStrTbl();
81 82
82 return true; 83 return true;
83} 84}
84 85
85 86
86bool VCalFormat::save(Calendar *calendar, const QString &fileName) 87bool VCalFormat::save(Calendar *calendar, const QString &fileName)
87{ 88{
88 mCalendar = calendar; 89 mCalendar = calendar;
89 90
90 QString tmpStr; 91 QString tmpStr;
91 VObject *vcal, *vo; 92 VObject *vcal, *vo;
92 93
93 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl; 94 kdDebug(5800) << "VCalFormat::save(): " << fileName << endl;
94 95
95 vcal = newVObject(VCCalProp); 96 vcal = newVObject(VCCalProp);
96 97
97 // addPropValue(vcal,VCLocationProp, "0.0"); 98 // addPropValue(vcal,VCLocationProp, "0.0");
98 addPropValue(vcal,VCProdIdProp, productId()); 99 addPropValue(vcal,VCProdIdProp, productId());
99 tmpStr = mCalendar->getTimeZoneStr(); 100 tmpStr = mCalendar->getTimeZoneStr();
100 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() ); 101 //qDebug("mCalendar->getTimeZoneStr() %s",tmpStr.latin1() );
101 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit()); 102 addPropValue(vcal,VCTimeZoneProp, tmpStr.local8Bit());
102 addPropValue(vcal,VCVersionProp, _VCAL_VERSION); 103 addPropValue(vcal,VCVersionProp, _VCAL_VERSION);
103 104
104 // TODO STUFF 105 // TODO STUFF
105 QPtrList<Todo> todoList = mCalendar->rawTodos(); 106 QPtrList<Todo> todoList = mCalendar->rawTodos();
106 QPtrListIterator<Todo> qlt(todoList); 107 QPtrListIterator<Todo> qlt(todoList);
107 for (; qlt.current(); ++qlt) { 108 for (; qlt.current(); ++qlt) {
108 vo = eventToVTodo(qlt.current()); 109 vo = eventToVTodo(qlt.current());
109 addVObjectProp(vcal, vo); 110 addVObjectProp(vcal, vo);
110 } 111 }
111 112
112 // EVENT STUFF 113 // EVENT STUFF
113 QPtrList<Event> events = mCalendar->rawEvents(); 114 QPtrList<Event> events = mCalendar->rawEvents();
114 Event *ev; 115 Event *ev;
115 for(ev=events.first();ev;ev=events.next()) { 116 for(ev=events.first();ev;ev=events.next()) {
116 vo = eventToVEvent(ev); 117 vo = eventToVEvent(ev);
117 addVObjectProp(vcal, vo); 118 addVObjectProp(vcal, vo);
118 } 119 }
119 120
120 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal); 121 writeVObjectToFile(QFile::encodeName(fileName).data() ,vcal);
121 cleanVObjects(vcal); 122 cleanVObjects(vcal);
122 cleanStrTbl(); 123 cleanStrTbl();
123 124
124 if (QFile::exists(fileName)) { 125 if (QFile::exists(fileName)) {
125 kdDebug(5800) << "No error" << endl; 126 kdDebug(5800) << "No error" << endl;
126 return true; 127 return true;
127 } else { 128 } else {
128 kdDebug(5800) << "Error" << endl; 129 kdDebug(5800) << "Error" << endl;
129 return false; // error 130 return false; // error
130 } 131 }
131} 132}
132 133
133bool VCalFormat::fromString( Calendar *calendar, const QString &text ) 134bool VCalFormat::fromString( Calendar *calendar, const QString &text )
134{ 135{
135 // TODO: Factor out VCalFormat::fromString() 136 // TODO: Factor out VCalFormat::fromString()
136 137
137 QCString data = text.utf8(); 138 QCString data = text.utf8();
138 139
139 if ( !data.size() ) return false; 140 if ( !data.size() ) return false;
140 141
141 VObject *vcal = Parse_MIME( data.data(), data.size()); 142 VObject *vcal = Parse_MIME( data.data(), data.size());
142 if ( !vcal ) return false; 143 if ( !vcal ) return false;
143 144
144 VObjectIterator i; 145 VObjectIterator i;
145 VObject *curvo; 146 VObject *curvo;
146 initPropIterator( &i, vcal ); 147 initPropIterator( &i, vcal );
147 148
148 // we only take the first object. TODO: parse all incidences. 149 // we only take the first object. TODO: parse all incidences.
149 do { 150 do {
150 curvo = nextVObject( &i ); 151 curvo = nextVObject( &i );
151 } while ( strcmp( vObjectName( curvo ), VCEventProp ) && 152 } while ( strcmp( vObjectName( curvo ), VCEventProp ) &&
152 strcmp( vObjectName( curvo ), VCTodoProp ) ); 153 strcmp( vObjectName( curvo ), VCTodoProp ) );
153 154
154 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) { 155 if ( strcmp( vObjectName( curvo ), VCEventProp ) == 0 ) {
155 Event *event = VEventToEvent( curvo ); 156 Event *event = VEventToEvent( curvo );
156 calendar->addEvent( event ); 157 calendar->addEvent( event );
157 } else { 158 } else {
158 kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl; 159 kdDebug(5800) << "VCalFormat::fromString(): Unknown object type." << endl;
159 deleteVObject( vcal ); 160 deleteVObject( vcal );
160 return false; 161 return false;
161 } 162 }
162 163
163 deleteVObject( vcal ); 164 deleteVObject( vcal );
164 165
165 return true; 166 return true;
166} 167}
167 168
168QString VCalFormat::eventToString( Event * event) 169QString VCalFormat::eventToString( Event * event, Calendar *calendar)
169{ 170{
170 if ( !event ) return QString::null; 171 if ( !event ) return QString::null;
172 mCalendar = calendar;
171 VObject *vevent = eventToVEvent( event ); 173 VObject *vevent = eventToVEvent( event );
172 char *buf = writeMemVObject( 0, 0, vevent ); 174 char *buf = writeMemVObject( 0, 0, vevent );
173 QString result( buf ); 175 QString result( buf );
174 cleanVObject( vevent ); 176 cleanVObject( vevent );
175 return result; 177 return result;
176} 178}
177QString VCalFormat::todoToString( Todo * todo ) 179QString VCalFormat::todoToString( Todo * todo, Calendar *calendar )
178{ 180{
179 if ( !todo ) return QString::null; 181 if ( !todo ) return QString::null;
182 mCalendar = calendar;
180 VObject *vevent = eventToVTodo( todo ); 183 VObject *vevent = eventToVTodo( todo );
181 char *buf = writeMemVObject( 0, 0, vevent ); 184 char *buf = writeMemVObject( 0, 0, vevent );
182 QString result( buf ); 185 QString result( buf );
183 cleanVObject( vevent ); 186 cleanVObject( vevent );
184 return result; 187 return result;
185} 188}
186 189
187QString VCalFormat::toString( Calendar *calendar ) 190QString VCalFormat::toString( Calendar *calendar )
188{ 191{
189 // TODO: Factor out VCalFormat::asString() 192 // TODO: Factor out VCalFormat::asString()
190 193
191 VObject *vcal = newVObject(VCCalProp); 194 VObject *vcal = newVObject(VCCalProp);
192 195
193 addPropValue( vcal, VCProdIdProp, CalFormat::productId() ); 196 addPropValue( vcal, VCProdIdProp, CalFormat::productId() );
194 QString tmpStr = mCalendar->getTimeZoneStr(); 197 QString tmpStr = mCalendar->getTimeZoneStr();
195 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() ); 198 addPropValue( vcal, VCTimeZoneProp, tmpStr.local8Bit() );
196 addPropValue( vcal, VCVersionProp, _VCAL_VERSION ); 199 addPropValue( vcal, VCVersionProp, _VCAL_VERSION );
197 200
198 // TODO: Use all data. 201 // TODO: Use all data.
199 QPtrList<Event> events = calendar->events(); 202 QPtrList<Event> events = calendar->events();
200 Event *event = events.first(); 203 Event *event = events.first();
201 if ( !event ) return QString::null; 204 if ( !event ) return QString::null;
202 205
203 VObject *vevent = eventToVEvent( event ); 206 VObject *vevent = eventToVEvent( event );
204 207
205 addVObjectProp( vcal, vevent ); 208 addVObjectProp( vcal, vevent );
206 209
207 char *buf = writeMemVObject( 0, 0, vcal ); 210 char *buf = writeMemVObject( 0, 0, vcal );
208 211
209 QString result( buf ); 212 QString result( buf );
210 213
211 cleanVObject( vcal ); 214 cleanVObject( vcal );
212 215
213 return result; 216 return result;
214} 217}
215 218
216VObject *VCalFormat::eventToVTodo(const Todo *anEvent) 219VObject *VCalFormat::eventToVTodo(const Todo *anEvent)
217{ 220{
218 VObject *vtodo; 221 VObject *vtodo;
219 QString tmpStr; 222 QString tmpStr;
220 QStringList tmpStrList; 223 QStringList tmpStrList;
221 224
222 vtodo = newVObject(VCTodoProp); 225 vtodo = newVObject(VCTodoProp);
223 226
224 // due date 227 // due date
225 if (anEvent->hasDueDate()) { 228 if (anEvent->hasDueDate()) {
226 tmpStr = qDateTimeToISO(anEvent->dtDue(), 229 tmpStr = qDateTimeToISO(anEvent->dtDue(),
227 !anEvent->doesFloat()); 230 !anEvent->doesFloat());
228 addPropValue(vtodo, VCDueProp, tmpStr.local8Bit()); 231 addPropValue(vtodo, VCDueProp, tmpStr.local8Bit());
229 } 232 }
230 233
231 // start date 234 // start date
232 if (anEvent->hasStartDate()) { 235 if (anEvent->hasStartDate()) {
233 tmpStr = qDateTimeToISO(anEvent->dtStart(), 236 tmpStr = qDateTimeToISO(anEvent->dtStart(),
234 !anEvent->doesFloat()); 237 !anEvent->doesFloat());
235 addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit()); 238 addPropValue(vtodo, VCDTstartProp, tmpStr.local8Bit());
236 } 239 }
237 240
238 // creation date 241 // creation date
239 tmpStr = qDateTimeToISO(anEvent->created()); 242 tmpStr = qDateTimeToISO(anEvent->created());
240 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit()); 243 addPropValue(vtodo, VCDCreatedProp, tmpStr.local8Bit());
241 244
242 // unique id 245 // unique id
243 addPropValue(vtodo, VCUniqueStringProp, 246 addPropValue(vtodo, VCUniqueStringProp,
244 anEvent->uid().local8Bit()); 247 anEvent->uid().local8Bit());
245 248
246 // revision 249 // revision
247 tmpStr.sprintf("%i", anEvent->revision()); 250 tmpStr.sprintf("%i", anEvent->revision());
248 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit()); 251 addPropValue(vtodo, VCSequenceProp, tmpStr.local8Bit());
249 252
250 // last modification date 253 // last modification date
251 tmpStr = qDateTimeToISO(anEvent->lastModified()); 254 tmpStr = qDateTimeToISO(anEvent->lastModified());
252 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit()); 255 addPropValue(vtodo, VCLastModifiedProp, tmpStr.local8Bit());
253 256
254 // organizer stuff 257 // organizer stuff
255 tmpStr = "MAILTO:" + anEvent->organizer(); 258 tmpStr = "MAILTO:" + anEvent->organizer();
256 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit()); 259 addPropValue(vtodo, ICOrganizerProp, tmpStr.local8Bit());
257 260
258 // attendees 261 // attendees
259 if (anEvent->attendeeCount() != 0) { 262 if (anEvent->attendeeCount() != 0) {
260 QPtrList<Attendee> al = anEvent->attendees(); 263 QPtrList<Attendee> al = anEvent->attendees();
261 QPtrListIterator<Attendee> ai(al); 264 QPtrListIterator<Attendee> ai(al);
262 Attendee *curAttendee; 265 Attendee *curAttendee;
263 266
264 for (; ai.current(); ++ai) { 267 for (; ai.current(); ++ai) {
265 curAttendee = ai.current(); 268 curAttendee = ai.current();
266 if (!curAttendee->email().isEmpty() && 269 if (!curAttendee->email().isEmpty() &&
267 !curAttendee->name().isEmpty()) 270 !curAttendee->name().isEmpty())
268 tmpStr = "MAILTO:" + curAttendee->name() + " <" + 271 tmpStr = "MAILTO:" + curAttendee->name() + " <" +
269 curAttendee->email() + ">"; 272 curAttendee->email() + ">";
270 else if (curAttendee->name().isEmpty()) 273 else if (curAttendee->name().isEmpty())
271 tmpStr = "MAILTO: " + curAttendee->email(); 274 tmpStr = "MAILTO: " + curAttendee->email();
272 else if (curAttendee->email().isEmpty()) 275 else if (curAttendee->email().isEmpty())
273 tmpStr = "MAILTO: " + curAttendee->name(); 276 tmpStr = "MAILTO: " + curAttendee->name();
274 else if (curAttendee->name().isEmpty() && 277 else if (curAttendee->name().isEmpty() &&
275 curAttendee->email().isEmpty()) 278 curAttendee->email().isEmpty())
diff --git a/libkcal/vcalformat.h b/libkcal/vcalformat.h
index 8490125..7b9ca26 100644
--- a/libkcal/vcalformat.h
+++ b/libkcal/vcalformat.h
@@ -1,110 +1,110 @@
1/* 1/*
2 This file is part of libkcal. 2 This file is part of libkcal.
3 Copyright (c) 1998 Preston Brown 3 Copyright (c) 1998 Preston Brown
4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org> 4 Copyright (c) 2001 Cornelius Schumacher <schumacher@kde.org>
5 5
6 This library is free software; you can redistribute it and/or 6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public 7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either 8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version. 9 version 2 of the License, or (at your option) any later version.
10 10
11 This library is distributed in the hope that it will be useful, 11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of 12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details. 14 Library General Public License for more details.
15 15
16 You should have received a copy of the GNU Library General Public License 16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to 17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 18 the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
19 Boston, MA 02111-1307, USA. 19 Boston, MA 02111-1307, USA.
20*/ 20*/
21 21
22#ifndef _VCALFORMAT_H 22#ifndef _VCALFORMAT_H
23#define _VCALFORMAT_H 23#define _VCALFORMAT_H
24 24
25#include "calformat.h" 25#include "calformat.h"
26 26
27#define _VCAL_VERSION "1.0" 27#define _VCAL_VERSION "1.0"
28 28
29class VObject; 29class VObject;
30 30
31namespace KCal { 31namespace KCal {
32 32
33/** 33/**
34 This class implements the vCalendar format. It provides methods for 34 This class implements the vCalendar format. It provides methods for
35 loading/saving/converting vCalendar format data into the internal KOrganizer 35 loading/saving/converting vCalendar format data into the internal KOrganizer
36 representation as Calendar and Events. 36 representation as Calendar and Events.
37 37
38 @short vCalendar format implementation 38 @short vCalendar format implementation
39*/ 39*/
40class VCalFormat : public CalFormat { 40class VCalFormat : public CalFormat {
41 public: 41 public:
42 VCalFormat(); 42 VCalFormat();
43 virtual ~VCalFormat(); 43 virtual ~VCalFormat();
44 44
45 /** loads a calendar on disk in vCalendar format into the current calendar. 45 /** loads a calendar on disk in vCalendar format into the current calendar.
46 * any information already present is lost. Returns TRUE if successful, 46 * any information already present is lost. Returns TRUE if successful,
47 * else returns FALSE. 47 * else returns FALSE.
48 * @param fileName the name of the calendar on disk. 48 * @param fileName the name of the calendar on disk.
49 */ 49 */
50 bool load(Calendar *,const QString &fileName); 50 bool load(Calendar *,const QString &fileName);
51 /** writes out the calendar to disk in vCalendar format. Returns true if 51 /** writes out the calendar to disk in vCalendar format. Returns true if
52 * successful and false on error. 52 * successful and false on error.
53 * @param fileName the name of the file 53 * @param fileName the name of the file
54 */ 54 */
55 bool save(Calendar *,const QString &fileName); 55 bool save(Calendar *,const QString &fileName);
56 56
57 /** 57 /**
58 Parse string and populate calendar with that information. 58 Parse string and populate calendar with that information.
59 */ 59 */
60 bool fromString( Calendar *, const QString & ); 60 bool fromString( Calendar *, const QString & );
61 /** 61 /**
62 Return calendar information as string. 62 Return calendar information as string.
63 */ 63 */
64 QString toString( Calendar * ); 64 QString toString( Calendar * );
65 QString eventToString( Event * ); 65 QString eventToString( Event *, Calendar *calendar );
66 QString todoToString( Todo * ); 66 QString todoToString( Todo * ,Calendar *calendar );
67 67
68 protected: 68 protected:
69 /** translates a VObject of the TODO type into a Event */ 69 /** translates a VObject of the TODO type into a Event */
70 Todo *VTodoToEvent(VObject *vtodo); 70 Todo *VTodoToEvent(VObject *vtodo);
71 /** translates a VObject into a Event and returns a pointer to it. */ 71 /** translates a VObject into a Event and returns a pointer to it. */
72 Event *VEventToEvent(VObject *vevent); 72 Event *VEventToEvent(VObject *vevent);
73 /** translate a Event into a VTodo-type VObject and return pointer */ 73 /** translate a Event into a VTodo-type VObject and return pointer */
74 VObject *eventToVTodo(const Todo *anEvent); 74 VObject *eventToVTodo(const Todo *anEvent);
75 /** translate a Event into a VObject and returns a pointer to it. */ 75 /** translate a Event into a VObject and returns a pointer to it. */
76 VObject* eventToVEvent(const Event *anEvent); 76 VObject* eventToVEvent(const Event *anEvent);
77 77
78 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */ 78 /** takes a QDate and returns a string in the format YYYYMMDDTHHMMSS */
79 QString qDateToISO(const QDate &); 79 QString qDateToISO(const QDate &);
80 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */ 80 /** takes a QDateTime and returns a string in format YYYYMMDDTHHMMSS */
81 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE); 81 QString qDateTimeToISO(const QDateTime &, bool zulu=TRUE);
82 /** takes a string in the format YYYYMMDDTHHMMSS and returns a 82 /** takes a string in the format YYYYMMDDTHHMMSS and returns a
83 * valid QDateTime. */ 83 * valid QDateTime. */
84 QDateTime ISOToQDateTime(const QString & dtStr); 84 QDateTime ISOToQDateTime(const QString & dtStr);
85 /** takes a string in the format YYYYMMDD and returns a 85 /** takes a string in the format YYYYMMDD and returns a
86 * valid QDate. */ 86 * valid QDate. */
87 QDate ISOToQDate(const QString & dtStr); 87 QDate ISOToQDate(const QString & dtStr);
88 /** takes a vCalendar tree of VObjects, and puts all of them that have 88 /** takes a vCalendar tree of VObjects, and puts all of them that have
89 * the "event" property into the dictionary, todos in the todo-list, etc. */ 89 * the "event" property into the dictionary, todos in the todo-list, etc. */
90 void populate(VObject *vcal); 90 void populate(VObject *vcal);
91 91
92 /** takes a number 0 - 6 and returns the two letter string of that day, 92 /** takes a number 0 - 6 and returns the two letter string of that day,
93 * i.e. MO, TU, WE, etc. */ 93 * i.e. MO, TU, WE, etc. */
94 const char *dayFromNum(int day); 94 const char *dayFromNum(int day);
95 /** the reverse of the above function. */ 95 /** the reverse of the above function. */
96 int numFromDay(const QString &day); 96 int numFromDay(const QString &day);
97 97
98 Attendee::PartStat readStatus(const char *s) const; 98 Attendee::PartStat readStatus(const char *s) const;
99 QCString writeStatus(Attendee::PartStat status) const; 99 QCString writeStatus(Attendee::PartStat status) const;
100 100
101 private: 101 private:
102 Calendar *mCalendar; 102 Calendar *mCalendar;
103 103
104 QPtrList<Event> mEventsRelate; // events with relations 104 QPtrList<Event> mEventsRelate; // events with relations
105 QPtrList<Todo> mTodosRelate; // todos with relations 105 QPtrList<Todo> mTodosRelate; // todos with relations
106}; 106};
107 107
108} 108}
109 109
110#endif 110#endif