summaryrefslogtreecommitdiffabout
Unidiff
Diffstat (more/less context) (ignore whitespace changes)
-rw-r--r--libical/src/libical/icalmemory.c2
-rw-r--r--libkcal/icalformat.cpp4
2 files changed, 4 insertions, 2 deletions
diff --git a/libical/src/libical/icalmemory.c b/libical/src/libical/icalmemory.c
index 18d7ef9..3ed38ad 100644
--- a/libical/src/libical/icalmemory.c
+++ b/libical/src/libical/icalmemory.c
@@ -1,368 +1,368 @@
1/* -*- Mode: C -*- 1/* -*- Mode: C -*-
2 ====================================================================== 2 ======================================================================
3 FILE: icalmemory.c 3 FILE: icalmemory.c
4 CREATOR: eric 30 June 1999 4 CREATOR: eric 30 June 1999
5 5
6 $Id$ 6 $Id$
7 $Locker$ 7 $Locker$
8 8
9 The contents of this file are subject to the Mozilla Public License 9 The contents of this file are subject to the Mozilla Public License
10 Version 1.0 (the "License"); you may not use this file except in 10 Version 1.0 (the "License"); you may not use this file except in
11 compliance with the License. You may obtain a copy of the License at 11 compliance with the License. You may obtain a copy of the License at
12 http://www.mozilla.org/MPL/ 12 http://www.mozilla.org/MPL/
13 13
14 Software distributed under the License is distributed on an "AS IS" 14 Software distributed under the License is distributed on an "AS IS"
15 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See 15 basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
16 the License for the specific language governing rights and 16 the License for the specific language governing rights and
17 limitations under the License. 17 limitations under the License.
18 18
19 19
20 This program is free software; you can redistribute it and/or modify 20 This program is free software; you can redistribute it and/or modify
21 it under the terms of either: 21 it under the terms of either:
22 22
23 The LGPL as published by the Free Software Foundation, version 23 The LGPL as published by the Free Software Foundation, version
24 2.1, available at: http://www.fsf.org/copyleft/lesser.html 24 2.1, available at: http://www.fsf.org/copyleft/lesser.html
25 25
26 Or: 26 Or:
27 27
28 The Mozilla Public License Version 1.0. You may obtain a copy of 28 The Mozilla Public License Version 1.0. You may obtain a copy of
29 the License at http://www.mozilla.org/MPL/ 29 the License at http://www.mozilla.org/MPL/
30 30
31 The Original Code is icalmemory.h 31 The Original Code is icalmemory.h
32 32
33 ======================================================================*/ 33 ======================================================================*/
34 34
35/** 35/**
36 * @file icalmemory.c 36 * @file icalmemory.c
37 * @brief Common memory management routines. 37 * @brief Common memory management routines.
38 * 38 *
39 * libical often passes strings back to the caller. To make these 39 * libical often passes strings back to the caller. To make these
40 * interfaces simple, I did not want the caller to have to pass in a 40 * interfaces simple, I did not want the caller to have to pass in a
41 * memory buffer, but having libical pass out newly allocated memory 41 * memory buffer, but having libical pass out newly allocated memory
42 * makes it difficult to de-allocate the memory. 42 * makes it difficult to de-allocate the memory.
43 * 43 *
44 * The ring buffer in this scheme makes it possible for libical to pass 44 * The ring buffer in this scheme makes it possible for libical to pass
45 * out references to memory which the caller does not own, and be able 45 * out references to memory which the caller does not own, and be able
46 * to de-allocate the memory later. The ring allows libical to have 46 * to de-allocate the memory later. The ring allows libical to have
47 * several buffers active simultaneously, which is handy when creating 47 * several buffers active simultaneously, which is handy when creating
48 * string representations of components. 48 * string representations of components.
49 */ 49 */
50 50
51#define ICALMEMORY_C 51#define ICALMEMORY_C
52 52
53#ifdef HAVE_CONFIG_H 53#ifdef HAVE_CONFIG_H
54#include "config.h" 54#include "config.h"
55#endif 55#endif
56 56
57#ifdef DMALLOC 57#ifdef DMALLOC
58#include "dmalloc.h" 58#include "dmalloc.h"
59#endif 59#endif
60 60
61#include "icalmemory.h" 61#include "icalmemory.h"
62#include "icalerror.h" 62#include "icalerror.h"
63 63
64#include <stdio.h> /* for printf (debugging) */ 64#include <stdio.h> /* for printf (debugging) */
65#include <stdlib.h> /* for malloc, realloc */ 65#include <stdlib.h> /* for malloc, realloc */
66#include <string.h> /* for memset(), strdup */ 66#include <string.h> /* for memset(), strdup */
67 67
68#ifdef WIN32 68#ifdef WIN32
69#include <windows.h> 69#include <windows.h>
70#endif 70#endif
71 71
72#define BUFFER_RING_SIZE 50 72#define BUFFER_RING_SIZE 100
73#define MIN_BUFFER_SIZE 64 73#define MIN_BUFFER_SIZE 64
74 74
75 75
76/* HACK. Not threadsafe */ 76/* HACK. Not threadsafe */
77 77
78typedef struct { 78typedef struct {
79 int pos; 79 int pos;
80 void *ring[BUFFER_RING_SIZE]; 80 void *ring[BUFFER_RING_SIZE];
81} buffer_ring; 81} buffer_ring;
82 82
83void icalmemory_free_tmp_buffer (void* buf); 83void icalmemory_free_tmp_buffer (void* buf);
84void icalmemory_free_ring_byval(buffer_ring *br); 84void icalmemory_free_ring_byval(buffer_ring *br);
85 85
86static buffer_ring* global_buffer_ring = 0; 86static buffer_ring* global_buffer_ring = 0;
87 87
88#ifdef HAVE_PTHREAD 88#ifdef HAVE_PTHREAD
89#include <pthread.h> 89#include <pthread.h>
90 90
91static pthread_key_t ring_key; 91static pthread_key_t ring_key;
92static pthread_once_t ring_key_once = PTHREAD_ONCE_INIT; 92static pthread_once_t ring_key_once = PTHREAD_ONCE_INIT;
93 93
94static void ring_destroy(void * buf) { 94static void ring_destroy(void * buf) {
95 if (buf) icalmemory_free_ring_byval((buffer_ring *) buf); 95 if (buf) icalmemory_free_ring_byval((buffer_ring *) buf);
96 pthread_setspecific(ring_key, NULL); 96 pthread_setspecific(ring_key, NULL);
97} 97}
98 98
99static void ring_key_alloc(void) { 99static void ring_key_alloc(void) {
100 pthread_key_create(&ring_key, ring_destroy); 100 pthread_key_create(&ring_key, ring_destroy);
101} 101}
102#endif 102#endif
103 103
104 104
105static buffer_ring * buffer_ring_new(void) { 105static buffer_ring * buffer_ring_new(void) {
106 buffer_ring *br; 106 buffer_ring *br;
107 int i; 107 int i;
108 108
109 br = (buffer_ring *)malloc(sizeof(buffer_ring)); 109 br = (buffer_ring *)malloc(sizeof(buffer_ring));
110 110
111 for(i=0; i<BUFFER_RING_SIZE; i++){ 111 for(i=0; i<BUFFER_RING_SIZE; i++){
112 br->ring[i] = 0; 112 br->ring[i] = 0;
113 } 113 }
114 br->pos = 0; 114 br->pos = 0;
115 return(br); 115 return(br);
116} 116}
117 117
118 118
119#ifdef HAVE_PTHREAD 119#ifdef HAVE_PTHREAD
120static buffer_ring* get_buffer_ring_pthread(void) { 120static buffer_ring* get_buffer_ring_pthread(void) {
121 buffer_ring *br; 121 buffer_ring *br;
122 122
123 pthread_once(&ring_key_once, ring_key_alloc); 123 pthread_once(&ring_key_once, ring_key_alloc);
124 124
125 br = pthread_getspecific(ring_key); 125 br = pthread_getspecific(ring_key);
126 126
127 if (!br) { 127 if (!br) {
128 br = buffer_ring_new(); 128 br = buffer_ring_new();
129 pthread_setspecific(ring_key, br); 129 pthread_setspecific(ring_key, br);
130 } 130 }
131 return(br); 131 return(br);
132} 132}
133#endif 133#endif
134 134
135/* get buffer ring via a single global for a non-threaded program */ 135/* get buffer ring via a single global for a non-threaded program */
136static buffer_ring* get_buffer_ring_global(void) { 136static buffer_ring* get_buffer_ring_global(void) {
137 if (global_buffer_ring == 0) { 137 if (global_buffer_ring == 0) {
138 global_buffer_ring = buffer_ring_new(); 138 global_buffer_ring = buffer_ring_new();
139 } 139 }
140 return(global_buffer_ring); 140 return(global_buffer_ring);
141} 141}
142 142
143static buffer_ring *get_buffer_ring(void) { 143static buffer_ring *get_buffer_ring(void) {
144#ifdef HAVE_PTHREAD 144#ifdef HAVE_PTHREAD
145 return(get_buffer_ring_pthread()); 145 return(get_buffer_ring_pthread());
146#else 146#else
147 return get_buffer_ring_global(); 147 return get_buffer_ring_global();
148#endif 148#endif
149} 149}
150 150
151 151
152/** Add an existing buffer to the buffer ring */ 152/** Add an existing buffer to the buffer ring */
153void icalmemory_add_tmp_buffer(void* buf) 153void icalmemory_add_tmp_buffer(void* buf)
154{ 154{
155 buffer_ring *br = get_buffer_ring(); 155 buffer_ring *br = get_buffer_ring();
156 156
157 157
158 /* Wrap around the ring */ 158 /* Wrap around the ring */
159 if(++(br->pos) == BUFFER_RING_SIZE){ 159 if(++(br->pos) == BUFFER_RING_SIZE){
160 br->pos = 0; 160 br->pos = 0;
161 } 161 }
162 162
163 /* Free buffers as their slots are overwritten */ 163 /* Free buffers as their slots are overwritten */
164 if ( br->ring[br->pos] != 0){ 164 if ( br->ring[br->pos] != 0){
165 free( br->ring[br->pos]); 165 free( br->ring[br->pos]);
166 } 166 }
167 167
168 /* Assign the buffer to a slot */ 168 /* Assign the buffer to a slot */
169 br->ring[br->pos] = buf; 169 br->ring[br->pos] = buf;
170} 170}
171 171
172 172
173/** 173/**
174 * Create a new temporary buffer on the ring. Libical owns these and 174 * Create a new temporary buffer on the ring. Libical owns these and
175 * will deallocate them. 175 * will deallocate them.
176 */ 176 */
177 177
178void* 178void*
179icalmemory_tmp_buffer (size_t size) 179icalmemory_tmp_buffer (size_t size)
180{ 180{
181 char *buf; 181 char *buf;
182 182
183 if (size < MIN_BUFFER_SIZE){ 183 if (size < MIN_BUFFER_SIZE){
184 size = MIN_BUFFER_SIZE; 184 size = MIN_BUFFER_SIZE;
185 } 185 }
186 186
187 buf = (void*)malloc(size); 187 buf = (void*)malloc(size);
188 188
189 if( buf == 0){ 189 if( buf == 0){
190 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 190 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
191 return 0; 191 return 0;
192 } 192 }
193 193
194 memset(buf,0,size); 194 memset(buf,0,size);
195 195
196 icalmemory_add_tmp_buffer(buf); 196 icalmemory_add_tmp_buffer(buf);
197 197
198 return buf; 198 return buf;
199} 199}
200 200
201/** get rid of this buffer ring */ 201/** get rid of this buffer ring */
202void icalmemory_free_ring_byval(buffer_ring *br) { 202void icalmemory_free_ring_byval(buffer_ring *br) {
203 int i; 203 int i;
204 for(i=0; i<BUFFER_RING_SIZE; i++){ 204 for(i=0; i<BUFFER_RING_SIZE; i++){
205 if ( br->ring[i] != 0){ 205 if ( br->ring[i] != 0){
206 free( br->ring[i]); 206 free( br->ring[i]);
207 } 207 }
208 } 208 }
209 free(br); 209 free(br);
210} 210}
211 211
212void icalmemory_free_ring() 212void icalmemory_free_ring()
213{ 213{
214 buffer_ring *br; 214 buffer_ring *br;
215 br = get_buffer_ring(); 215 br = get_buffer_ring();
216 icalmemory_free_ring_byval(br); 216 icalmemory_free_ring_byval(br);
217 if ( global_buffer_ring == br ) 217 if ( global_buffer_ring == br )
218 global_buffer_ring = 0; 218 global_buffer_ring = 0;
219} 219}
220 220
221 221
222 222
223/** Like strdup, but the buffer is on the ring. */ 223/** Like strdup, but the buffer is on the ring. */
224char* 224char*
225icalmemory_tmp_copy(const char* str) 225icalmemory_tmp_copy(const char* str)
226{ 226{
227 char* b = icalmemory_tmp_buffer(strlen(str)+1); 227 char* b = icalmemory_tmp_buffer(strlen(str)+1);
228 228
229 strcpy(b,str); 229 strcpy(b,str);
230 230
231 return b; 231 return b;
232} 232}
233 233
234 234
235char* icalmemory_strdup(const char *s) 235char* icalmemory_strdup(const char *s)
236{ 236{
237 return strdup(s); 237 return strdup(s);
238} 238}
239 239
240void 240void
241icalmemory_free_tmp_buffer (void* buf) 241icalmemory_free_tmp_buffer (void* buf)
242{ 242{
243 if(buf == 0) 243 if(buf == 0)
244 { 244 {
245 return; 245 return;
246 } 246 }
247 247
248 free(buf); 248 free(buf);
249} 249}
250 250
251 251
252/* 252/*
253 * These buffer routines create memory the old fashioned way -- so the 253 * These buffer routines create memory the old fashioned way -- so the
254 * caller will have to deallocate the new memory 254 * caller will have to deallocate the new memory
255 */ 255 */
256 256
257void* icalmemory_new_buffer(size_t size) 257void* icalmemory_new_buffer(size_t size)
258{ 258{
259 void *b = malloc(size); 259 void *b = malloc(size);
260 260
261 if( b == 0){ 261 if( b == 0){
262 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 262 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
263 return 0; 263 return 0;
264 } 264 }
265 265
266 memset(b,0,size); 266 memset(b,0,size);
267 267
268 return b; 268 return b;
269} 269}
270 270
271void* icalmemory_resize_buffer(void* buf, size_t size) 271void* icalmemory_resize_buffer(void* buf, size_t size)
272{ 272{
273 void *b = realloc(buf, size); 273 void *b = realloc(buf, size);
274 274
275 if( b == 0){ 275 if( b == 0){
276 icalerror_set_errno(ICAL_NEWFAILED_ERROR); 276 icalerror_set_errno(ICAL_NEWFAILED_ERROR);
277 return 0; 277 return 0;
278 } 278 }
279 279
280 return b; 280 return b;
281} 281}
282 282
283void icalmemory_free_buffer(void* buf) 283void icalmemory_free_buffer(void* buf)
284{ 284{
285 free(buf); 285 free(buf);
286} 286}
287 287
288void 288void
289icalmemory_append_string(char** buf, char** pos, size_t* buf_size, 289icalmemory_append_string(char** buf, char** pos, size_t* buf_size,
290 const char* string) 290 const char* string)
291{ 291{
292 char *new_buf; 292 char *new_buf;
293 char *new_pos; 293 char *new_pos;
294 294
295 size_t data_length, final_length, string_length; 295 size_t data_length, final_length, string_length;
296 296
297#ifndef ICAL_NO_INTERNAL_DEBUG 297#ifndef ICAL_NO_INTERNAL_DEBUG
298 icalerror_check_arg_rv( (buf!=0),"buf"); 298 icalerror_check_arg_rv( (buf!=0),"buf");
299 icalerror_check_arg_rv( (*buf!=0),"*buf"); 299 icalerror_check_arg_rv( (*buf!=0),"*buf");
300 icalerror_check_arg_rv( (pos!=0),"pos"); 300 icalerror_check_arg_rv( (pos!=0),"pos");
301 icalerror_check_arg_rv( (*pos!=0),"*pos"); 301 icalerror_check_arg_rv( (*pos!=0),"*pos");
302 icalerror_check_arg_rv( (buf_size!=0),"buf_size"); 302 icalerror_check_arg_rv( (buf_size!=0),"buf_size");
303 icalerror_check_arg_rv( (*buf_size!=0),"*buf_size"); 303 icalerror_check_arg_rv( (*buf_size!=0),"*buf_size");
304 icalerror_check_arg_rv( (string!=0),"string"); 304 icalerror_check_arg_rv( (string!=0),"string");
305#endif 305#endif
306 306
307 string_length = strlen(string); 307 string_length = strlen(string);
308 data_length = (size_t)*pos - (size_t)*buf; 308 data_length = (size_t)*pos - (size_t)*buf;
309 final_length = data_length + string_length; 309 final_length = data_length + string_length;
310 310
311 if ( final_length >= (size_t) *buf_size) { 311 if ( final_length >= (size_t) *buf_size) {
312 312
313 313
314 *buf_size = (*buf_size) * 2 + final_length; 314 *buf_size = (*buf_size) * 2 + final_length;
315 315
316 new_buf = realloc(*buf,*buf_size); 316 new_buf = realloc(*buf,*buf_size);
317 317
318 new_pos = (void*)((size_t)new_buf + data_length); 318 new_pos = (void*)((size_t)new_buf + data_length);
319 319
320 *pos = new_pos; 320 *pos = new_pos;
321 *buf = new_buf; 321 *buf = new_buf;
322 } 322 }
323 323
324 strcpy(*pos, string); 324 strcpy(*pos, string);
325 325
326 *pos += string_length; 326 *pos += string_length;
327} 327}
328 328
329 329
330void 330void
331icalmemory_append_char(char** buf, char** pos, size_t* buf_size, 331icalmemory_append_char(char** buf, char** pos, size_t* buf_size,
332 char ch) 332 char ch)
333{ 333{
334 char *new_buf; 334 char *new_buf;
335 char *new_pos; 335 char *new_pos;
336 336
337 size_t data_length, final_length; 337 size_t data_length, final_length;
338 338
339#ifndef ICAL_NO_INTERNAL_DEBUG 339#ifndef ICAL_NO_INTERNAL_DEBUG
340 icalerror_check_arg_rv( (buf!=0),"buf"); 340 icalerror_check_arg_rv( (buf!=0),"buf");
341 icalerror_check_arg_rv( (*buf!=0),"*buf"); 341 icalerror_check_arg_rv( (*buf!=0),"*buf");
342 icalerror_check_arg_rv( (pos!=0),"pos"); 342 icalerror_check_arg_rv( (pos!=0),"pos");
343 icalerror_check_arg_rv( (*pos!=0),"*pos"); 343 icalerror_check_arg_rv( (*pos!=0),"*pos");
344 icalerror_check_arg_rv( (buf_size!=0),"buf_size"); 344 icalerror_check_arg_rv( (buf_size!=0),"buf_size");
345 icalerror_check_arg_rv( (*buf_size!=0),"*buf_size"); 345 icalerror_check_arg_rv( (*buf_size!=0),"*buf_size");
346#endif 346#endif
347 347
348 data_length = (size_t)*pos - (size_t)*buf; 348 data_length = (size_t)*pos - (size_t)*buf;
349 349
350 final_length = data_length + 2; 350 final_length = data_length + 2;
351 351
352 if ( final_length > (size_t) *buf_size ) { 352 if ( final_length > (size_t) *buf_size ) {
353 353
354 354
355 *buf_size = (*buf_size) * 2 + final_length +1; 355 *buf_size = (*buf_size) * 2 + final_length +1;
356 356
357 new_buf = realloc(*buf,*buf_size); 357 new_buf = realloc(*buf,*buf_size);
358 358
359 new_pos = (void*)((size_t)new_buf + data_length); 359 new_pos = (void*)((size_t)new_buf + data_length);
360 360
361 *pos = new_pos; 361 *pos = new_pos;
362 *buf = new_buf; 362 *buf = new_buf;
363 } 363 }
364 364
365 **pos = ch; 365 **pos = ch;
366 *pos += 1; 366 *pos += 1;
367 **pos = 0; 367 **pos = 0;
368} 368}
diff --git a/libkcal/icalformat.cpp b/libkcal/icalformat.cpp
index d9fe40b..5877406 100644
--- a/libkcal/icalformat.cpp
+++ b/libkcal/icalformat.cpp
@@ -1,460 +1,462 @@
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 <qdatetime.h> 21#include <qdatetime.h>
22#include <qstring.h> 22#include <qstring.h>
23#include <qptrlist.h> 23#include <qptrlist.h>
24#include <qregexp.h> 24#include <qregexp.h>
25#include <qclipboard.h> 25#include <qclipboard.h>
26#include <qfile.h> 26#include <qfile.h>
27#include <qtextstream.h> 27#include <qtextstream.h>
28#include <qtextcodec.h> 28#include <qtextcodec.h>
29#include <stdlib.h> 29#include <stdlib.h>
30 30
31#include <kdebug.h> 31#include <kdebug.h>
32#include <kglobal.h> 32#include <kglobal.h>
33#include <klocale.h> 33#include <klocale.h>
34 34
35extern "C" { 35extern "C" {
36 #include <ical.h> 36 #include <ical.h>
37 #include <icalss.h> 37 #include <icalss.h>
38 #include <icalparser.h> 38 #include <icalparser.h>
39 #include <icalrestriction.h> 39 #include <icalrestriction.h>
40} 40}
41 41
42#include "calendar.h" 42#include "calendar.h"
43#include "calendarlocal.h" 43#include "calendarlocal.h"
44#include "journal.h" 44#include "journal.h"
45 45
46#include "icalformat.h" 46#include "icalformat.h"
47#include "icalformatimpl.h" 47#include "icalformatimpl.h"
48 48
49#define _ICAL_VERSION "2.0" 49#define _ICAL_VERSION "2.0"
50 50
51using namespace KCal; 51using namespace KCal;
52 52
53ICalFormat::ICalFormat( ) 53ICalFormat::ICalFormat( )
54{ 54{
55 mImpl = new ICalFormatImpl( this ); 55 mImpl = new ICalFormatImpl( this );
56 tzOffsetMin = 0; 56 tzOffsetMin = 0;
57 //qDebug("new ICalFormat() "); 57 //qDebug("new ICalFormat() ");
58} 58}
59 59
60ICalFormat::~ICalFormat() 60ICalFormat::~ICalFormat()
61{ 61{
62 delete mImpl; 62 delete mImpl;
63 //qDebug("delete ICalFormat "); 63 //qDebug("delete ICalFormat ");
64} 64}
65 65
66bool ICalFormat::load( Calendar *calendar, const QString &fileName) 66bool ICalFormat::load( Calendar *calendar, const QString &fileName)
67{ 67{
68 68
69 clearException(); 69 clearException();
70 70
71 QFile file( fileName ); 71 QFile file( fileName );
72 if (!file.open( IO_ReadOnly ) ) { 72 if (!file.open( IO_ReadOnly ) ) {
73 setException(new ErrorFormat(ErrorFormat::LoadError)); 73 setException(new ErrorFormat(ErrorFormat::LoadError));
74 return false; 74 return false;
75 } 75 }
76 QTextStream ts( &file ); 76 QTextStream ts( &file );
77 QString text; 77 QString text;
78 78
79 ts.setEncoding( QTextStream::Latin1 ); 79 ts.setEncoding( QTextStream::Latin1 );
80 text = ts.read(); 80 text = ts.read();
81 file.close(); 81 file.close();
82 82
83 return fromString( calendar, text ); 83 return fromString( calendar, text );
84} 84}
85 85
86//#include <qdatetime.h> 86//#include <qdatetime.h>
87bool ICalFormat::save( Calendar *calendar, const QString &fileName ) 87bool ICalFormat::save( Calendar *calendar, const QString &fileName )
88{ 88{
89 //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl; 89 //kdDebug(5800) << "ICalFormat::save(): " << fileName << endl;
90 //qDebug("ICalFormat::save "); 90 //qDebug("ICalFormat::save ");
91 clearException(); 91 clearException();
92 QString text = toString( calendar ); 92 QString text = toString( calendar );
93 //return false; 93 //return false;
94 // qDebug("to string takes ms: %d ",is.elapsed() ); 94 // qDebug("to string takes ms: %d ",is.elapsed() );
95 if ( text.isNull() ) return false; 95 if ( text.isNull() ) return false;
96 96
97 // TODO: write backup file 97 // TODO: write backup file
98 //is.restart(); 98 //is.restart();
99 QFile file( fileName ); 99 QFile file( fileName );
100 if (!file.open( IO_WriteOnly ) ) { 100 if (!file.open( IO_WriteOnly ) ) {
101 setException(new ErrorFormat(ErrorFormat::SaveError, 101 setException(new ErrorFormat(ErrorFormat::SaveError,
102 i18n("Could not open file '%1'").arg(fileName))); 102 i18n("Could not open file '%1'").arg(fileName)));
103 return false; 103 return false;
104 } 104 }
105 QTextStream ts( &file ); 105 QTextStream ts( &file );
106 106
107 ts.setEncoding( QTextStream::Latin1 ); 107 ts.setEncoding( QTextStream::Latin1 );
108 ts << text; 108 ts << text;
109 file.close(); 109 file.close();
110 //qDebug("saving file takes ms: %d ", is.elapsed() ); 110 //qDebug("saving file takes ms: %d ", is.elapsed() );
111 return true; 111 return true;
112} 112}
113 113
114bool ICalFormat::fromString( Calendar *cal, const QString &text ) 114bool ICalFormat::fromString( Calendar *cal, const QString &text )
115{ 115{
116 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 116 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
117 // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1()); 117 // qDebug("ICalFormat::fromString tz: %s ", cal->timeZoneId().latin1());
118 // Get first VCALENDAR component. 118 // Get first VCALENDAR component.
119 // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components 119 // TODO: Handle more than one VCALENDAR or non-VCALENDAR top components
120 icalcomponent *calendar; 120 icalcomponent *calendar;
121 121
122 //calendar = icalcomponent_new_from_string( text.local8Bit().data()); 122 //calendar = icalcomponent_new_from_string( text.local8Bit().data());
123 // good calendar = icalcomponent_new_from_string( text.utf8().data()); 123 // good calendar = icalcomponent_new_from_string( text.utf8().data());
124 calendar = icalcomponent_new_from_string( (char*)text.latin1()); 124 calendar = icalcomponent_new_from_string( (char*)text.latin1());
125 if (!calendar) { 125 if (!calendar) {
126 setException(new ErrorFormat(ErrorFormat::ParseErrorIcal)); 126 setException(new ErrorFormat(ErrorFormat::ParseErrorIcal));
127 return false; 127 return false;
128 } 128 }
129 129
130 bool success = true; 130 bool success = true;
131 131
132 if (icalcomponent_isa(calendar) != ICAL_VCALENDAR_COMPONENT) { 132 if (icalcomponent_isa(calendar) != ICAL_VCALENDAR_COMPONENT) {
133 setException(new ErrorFormat(ErrorFormat::NoCalendar)); 133 setException(new ErrorFormat(ErrorFormat::NoCalendar));
134 success = false; 134 success = false;
135 } else { 135 } else {
136 // put all objects into their proper places 136 // put all objects into their proper places
137 if ( !mImpl->populate( cal, calendar ) ) { 137 if ( !mImpl->populate( cal, calendar ) ) {
138 if ( !exception() ) { 138 if ( !exception() ) {
139 setException(new ErrorFormat(ErrorFormat::ParseErrorKcal)); 139 setException(new ErrorFormat(ErrorFormat::ParseErrorKcal));
140 } 140 }
141 success = false; 141 success = false;
142 } else 142 } else
143 mLoadedProductId = mImpl->loadedProductId(); 143 mLoadedProductId = mImpl->loadedProductId();
144 } 144 }
145 145
146 icalcomponent_free( calendar ); 146 icalcomponent_free( calendar );
147 icalmemory_free_ring();
147 148
148 return success; 149 return success;
149} 150}
150 151
151Incidence *ICalFormat::fromString( const QString &text ) 152Incidence *ICalFormat::fromString( const QString &text )
152{ 153{
153 CalendarLocal cal( mTimeZoneId ); 154 CalendarLocal cal( mTimeZoneId );
154 fromString(&cal, text); 155 fromString(&cal, text);
155 156
156 Incidence *ical = 0; 157 Incidence *ical = 0;
157 QPtrList<Event> elist = cal.events(); 158 QPtrList<Event> elist = cal.events();
158 if ( elist.count() > 0 ) { 159 if ( elist.count() > 0 ) {
159 ical = elist.first(); 160 ical = elist.first();
160 } else { 161 } else {
161 QPtrList<Todo> tlist = cal.todos(); 162 QPtrList<Todo> tlist = cal.todos();
162 if ( tlist.count() > 0 ) { 163 if ( tlist.count() > 0 ) {
163 ical = tlist.first(); 164 ical = tlist.first();
164 } else { 165 } else {
165 QPtrList<Journal> jlist = cal.journals(); 166 QPtrList<Journal> jlist = cal.journals();
166 if ( jlist.count() > 0 ) { 167 if ( jlist.count() > 0 ) {
167 ical = jlist.first(); 168 ical = jlist.first();
168 } 169 }
169 } 170 }
170 } 171 }
171 return ical; 172 return ical;
172} 173}
173#include <qapp.h> 174#include <qapp.h>
174 175
175QString ICalFormat::toString( Calendar *cal ) 176QString ICalFormat::toString( Calendar *cal )
176{ 177{
177 178
178 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 179 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
179 180
180 icalcomponent *calendar = mImpl->createCalendarComponent(cal); 181 icalcomponent *calendar = mImpl->createCalendarComponent(cal);
181 182
182 icalcomponent *component; 183 icalcomponent *component;
183 184
184 // todos 185 // todos
185 QPtrList<Todo> todoList = cal->rawTodos(); 186 QPtrList<Todo> todoList = cal->rawTodos();
186 QPtrListIterator<Todo> qlt(todoList); 187 QPtrListIterator<Todo> qlt(todoList);
187 for (; qlt.current(); ++qlt) { 188 for (; qlt.current(); ++qlt) {
188 component = mImpl->writeTodo(qlt.current()); 189 component = mImpl->writeTodo(qlt.current());
189 icalcomponent_add_component(calendar,component); 190 icalcomponent_add_component(calendar,component);
190 //qDebug(" todos "); 191 //qDebug(" todos ");
191 qApp->processEvents(); 192 qApp->processEvents();
192 } 193 }
193 // events 194 // events
194 QPtrList<Event> events = cal->rawEvents(); 195 QPtrList<Event> events = cal->rawEvents();
195 Event *ev; 196 Event *ev;
196 for(ev=events.first();ev;ev=events.next()) { 197 for(ev=events.first();ev;ev=events.next()) {
197 component = mImpl->writeEvent(ev); 198 component = mImpl->writeEvent(ev);
198 icalcomponent_add_component(calendar,component); 199 icalcomponent_add_component(calendar,component);
199 //qDebug("events "); 200 //qDebug("events ");
200 qApp->processEvents(); 201 qApp->processEvents();
201 } 202 }
202 203
203 // journals 204 // journals
204 QPtrList<Journal> journals = cal->journals(); 205 QPtrList<Journal> journals = cal->journals();
205 Journal *j; 206 Journal *j;
206 for(j=journals.first();j;j=journals.next()) { 207 for(j=journals.first();j;j=journals.next()) {
207 component = mImpl->writeJournal(j); 208 component = mImpl->writeJournal(j);
208 icalcomponent_add_component(calendar,component); 209 icalcomponent_add_component(calendar,component);
209 //qDebug("journals "); 210 //qDebug("journals ");
210 qApp->processEvents(); 211 qApp->processEvents();
211 } 212 }
212 const char *text; 213 const char *text;
213 QString ret =""; 214 QString ret ="";
214 text = icalcomponent_as_ical_string( calendar ); 215 text = icalcomponent_as_ical_string( calendar );
215 qApp->processEvents(); 216 qApp->processEvents();
216 217
217 // text = "BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML libkcal 3.1//EN\nVERSION\n :2.0\nBEGIN:VEVENT\nDTSTAMP\n :20031231T213514Z\nORGANIZER\n :MAILTO:lutz@putz.de\nCREATED\n :20031231T213513Z\nUID\n :libkcal-1295166342.120\nSEQUENCE\n :0\nLAST-MODIFIED\n :20031231T213513Z\nSUMMARY\n :test1\nCLASS\n :PUBLIC\nPRIORITY\n :3\nDTSTART\n :20040101T090000Z\nDTEND\n :20040101T110000Z\nTRANSP\n :OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n"; 218 // text = "BEGIN:VCALENDAR\nPRODID\n :-//K Desktop Environment//NONSGML libkcal 3.1//EN\nVERSION\n :2.0\nBEGIN:VEVENT\nDTSTAMP\n :20031231T213514Z\nORGANIZER\n :MAILTO:lutz@putz.de\nCREATED\n :20031231T213513Z\nUID\n :libkcal-1295166342.120\nSEQUENCE\n :0\nLAST-MODIFIED\n :20031231T213513Z\nSUMMARY\n :test1\nCLASS\n :PUBLIC\nPRIORITY\n :3\nDTSTART\n :20040101T090000Z\nDTEND\n :20040101T110000Z\nTRANSP\n :OPAQUE\nEND:VEVENT\nEND:VCALENDAR\n";
218 219
219 220
220 if ( text ) { 221 if ( text ) {
221 ret = QString ( text ); 222 ret = QString ( text );
222 } 223 }
223 icalcomponent_free( calendar ); 224 icalcomponent_free( calendar );
224 225
225 if (!text) { 226 if (!text) {
226 setException(new ErrorFormat(ErrorFormat::SaveError, 227 setException(new ErrorFormat(ErrorFormat::SaveError,
227 i18n("libical error"))); 228 i18n("libical error")));
229 icalmemory_free_ring();
228 return QString::null; 230 return QString::null;
229 } 231 }
230 232 icalmemory_free_ring();
231 return ret; 233 return ret;
232} 234}
233 235
234QString ICalFormat::toICalString( Incidence *incidence ) 236QString ICalFormat::toICalString( Incidence *incidence )
235{ 237{
236 CalendarLocal cal( mTimeZoneId ); 238 CalendarLocal cal( mTimeZoneId );
237 cal.addIncidence( incidence->clone() ); 239 cal.addIncidence( incidence->clone() );
238 return toString( &cal ); 240 return toString( &cal );
239} 241}
240 242
241QString ICalFormat::toString( Incidence *incidence ) 243QString ICalFormat::toString( Incidence *incidence )
242{ 244{
243 icalcomponent *component; 245 icalcomponent *component;
244 246
245 component = mImpl->writeIncidence( incidence ); 247 component = mImpl->writeIncidence( incidence );
246 248
247 const char *text = icalcomponent_as_ical_string( component ); 249 const char *text = icalcomponent_as_ical_string( component );
248 250
249 icalcomponent_free( component ); 251 icalcomponent_free( component );
250 252
251 return QString::fromLocal8Bit( text ); 253 return QString::fromLocal8Bit( text );
252} 254}
253 255
254QString ICalFormat::toString( Recurrence *recurrence ) 256QString ICalFormat::toString( Recurrence *recurrence )
255{ 257{
256 icalproperty *property; 258 icalproperty *property;
257 property = mImpl->writeRecurrenceRule( recurrence ); 259 property = mImpl->writeRecurrenceRule( recurrence );
258 const char *text = icalproperty_as_ical_string( property ); 260 const char *text = icalproperty_as_ical_string( property );
259 icalproperty_free( property ); 261 icalproperty_free( property );
260 return QString::fromLocal8Bit( text ); 262 return QString::fromLocal8Bit( text );
261} 263}
262/* 264/*
263bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule ) 265bool ICalFormat::fromString( Recurrence * recurrence, const QString& rrule )
264{ 266{
265 bool success = true; 267 bool success = true;
266 icalerror_clear_errno(); 268 icalerror_clear_errno();
267 struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule ); 269 struct icalrecurrencetype recur = icalrecurrencetype_from_string( rrule );
268 if ( icalerrno != ICAL_NO_ERROR ) { 270 if ( icalerrno != ICAL_NO_ERROR ) {
269 kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl; 271 kdDebug() << "Recurrence parsing error: " << icalerror_strerror( icalerrno ) << endl;
270 success = false; 272 success = false;
271 } 273 }
272 274
273 if ( success ) { 275 if ( success ) {
274 mImpl->readRecurrence( recur, recurrence ); 276 mImpl->readRecurrence( recur, recurrence );
275 } 277 }
276 278
277 return success; 279 return success;
278} 280}
279*/ 281*/
280 282
281QString ICalFormat::createScheduleMessage(IncidenceBase *incidence, 283QString ICalFormat::createScheduleMessage(IncidenceBase *incidence,
282 Scheduler::Method method) 284 Scheduler::Method method)
283{ 285{
284 icalcomponent *message = mImpl->createScheduleComponent(incidence,method); 286 icalcomponent *message = mImpl->createScheduleComponent(incidence,method);
285 287
286 QString messageText = icalcomponent_as_ical_string(message); 288 QString messageText = icalcomponent_as_ical_string(message);
287 289
288 290
289 291
290 return messageText; 292 return messageText;
291} 293}
292 294
293ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal, 295ScheduleMessage *ICalFormat::parseScheduleMessage( Calendar *cal,
294 const QString &messageText ) 296 const QString &messageText )
295{ 297{
296 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() ); 298 setTimeZone( cal->timeZoneId(), !cal->isLocalTime() );
297 clearException(); 299 clearException();
298 300
299 if (messageText.isEmpty()) return 0; 301 if (messageText.isEmpty()) return 0;
300 302
301 icalcomponent *message; 303 icalcomponent *message;
302 message = icalparser_parse_string(messageText.local8Bit()); 304 message = icalparser_parse_string(messageText.local8Bit());
303 305
304 if (!message) return 0; 306 if (!message) return 0;
305 307
306 icalproperty *m = icalcomponent_get_first_property(message, 308 icalproperty *m = icalcomponent_get_first_property(message,
307 ICAL_METHOD_PROPERTY); 309 ICAL_METHOD_PROPERTY);
308 310
309 if (!m) return 0; 311 if (!m) return 0;
310 312
311 icalcomponent *c; 313 icalcomponent *c;
312 314
313 IncidenceBase *incidence = 0; 315 IncidenceBase *incidence = 0;
314 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT); 316 c = icalcomponent_get_first_component(message,ICAL_VEVENT_COMPONENT);
315 if (c) { 317 if (c) {
316 incidence = mImpl->readEvent(c); 318 incidence = mImpl->readEvent(c);
317 } 319 }
318 320
319 if (!incidence) { 321 if (!incidence) {
320 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT); 322 c = icalcomponent_get_first_component(message,ICAL_VTODO_COMPONENT);
321 if (c) { 323 if (c) {
322 incidence = mImpl->readTodo(c); 324 incidence = mImpl->readTodo(c);
323 } 325 }
324 } 326 }
325 327
326 if (!incidence) { 328 if (!incidence) {
327 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT); 329 c = icalcomponent_get_first_component(message,ICAL_VFREEBUSY_COMPONENT);
328 if (c) { 330 if (c) {
329 incidence = mImpl->readFreeBusy(c); 331 incidence = mImpl->readFreeBusy(c);
330 } 332 }
331 } 333 }
332 334
333 if (!incidence) { 335 if (!incidence) {
334 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl; 336 kdDebug() << "ICalFormat:parseScheduleMessage: object is not a freebusy, event or todo" << endl;
335 return 0; 337 return 0;
336 } 338 }
337 339
338 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl; 340 kdDebug(5800) << "ICalFormat::parseScheduleMessage() getting method..." << endl;
339 341
340 icalproperty_method icalmethod = icalproperty_get_method(m); 342 icalproperty_method icalmethod = icalproperty_get_method(m);
341 Scheduler::Method method; 343 Scheduler::Method method;
342 344
343 switch (icalmethod) { 345 switch (icalmethod) {
344 case ICAL_METHOD_PUBLISH: 346 case ICAL_METHOD_PUBLISH:
345 method = Scheduler::Publish; 347 method = Scheduler::Publish;
346 break; 348 break;
347 case ICAL_METHOD_REQUEST: 349 case ICAL_METHOD_REQUEST:
348 method = Scheduler::Request; 350 method = Scheduler::Request;
349 break; 351 break;
350 case ICAL_METHOD_REFRESH: 352 case ICAL_METHOD_REFRESH:
351 method = Scheduler::Refresh; 353 method = Scheduler::Refresh;
352 break; 354 break;
353 case ICAL_METHOD_CANCEL: 355 case ICAL_METHOD_CANCEL:
354 method = Scheduler::Cancel; 356 method = Scheduler::Cancel;
355 break; 357 break;
356 case ICAL_METHOD_ADD: 358 case ICAL_METHOD_ADD:
357 method = Scheduler::Add; 359 method = Scheduler::Add;
358 break; 360 break;
359 case ICAL_METHOD_REPLY: 361 case ICAL_METHOD_REPLY:
360 method = Scheduler::Reply; 362 method = Scheduler::Reply;
361 break; 363 break;
362 case ICAL_METHOD_COUNTER: 364 case ICAL_METHOD_COUNTER:
363 method = Scheduler::Counter; 365 method = Scheduler::Counter;
364 break; 366 break;
365 case ICAL_METHOD_DECLINECOUNTER: 367 case ICAL_METHOD_DECLINECOUNTER:
366 method = Scheduler::Declinecounter; 368 method = Scheduler::Declinecounter;
367 break; 369 break;
368 default: 370 default:
369 method = Scheduler::NoMethod; 371 method = Scheduler::NoMethod;
370 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl; 372 kdDebug(5800) << "ICalFormat::parseScheduleMessage(): Unknow method" << endl;
371 break; 373 break;
372 } 374 }
373 375
374 376
375 if (!icalrestriction_check(message)) { 377 if (!icalrestriction_check(message)) {
376 setException(new ErrorFormat(ErrorFormat::Restriction, 378 setException(new ErrorFormat(ErrorFormat::Restriction,
377 Scheduler::translatedMethodName(method) + ": " + 379 Scheduler::translatedMethodName(method) + ": " +
378 mImpl->extractErrorProperty(c))); 380 mImpl->extractErrorProperty(c)));
379 return 0; 381 return 0;
380 } 382 }
381 383
382 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal); 384 icalcomponent *calendarComponent = mImpl->createCalendarComponent(cal);
383 385
384 Incidence *existingIncidence = cal->event(incidence->uid()); 386 Incidence *existingIncidence = cal->event(incidence->uid());
385 if (existingIncidence) { 387 if (existingIncidence) {
386 // TODO: check, if cast is required, or if it can be done by virtual funcs. 388 // TODO: check, if cast is required, or if it can be done by virtual funcs.
387 if (existingIncidence->typeID() == todoID ) { 389 if (existingIncidence->typeID() == todoID ) {
388 Todo *todo = static_cast<Todo *>(existingIncidence); 390 Todo *todo = static_cast<Todo *>(existingIncidence);
389 icalcomponent_add_component(calendarComponent, 391 icalcomponent_add_component(calendarComponent,
390 mImpl->writeTodo(todo)); 392 mImpl->writeTodo(todo));
391 } 393 }
392 if (existingIncidence->typeID() == eventID ) { 394 if (existingIncidence->typeID() == eventID ) {
393 Event *event = static_cast<Event *>(existingIncidence); 395 Event *event = static_cast<Event *>(existingIncidence);
394 icalcomponent_add_component(calendarComponent, 396 icalcomponent_add_component(calendarComponent,
395 mImpl->writeEvent(event)); 397 mImpl->writeEvent(event));
396 } 398 }
397 } else { 399 } else {
398 calendarComponent = 0; 400 calendarComponent = 0;
399 } 401 }
400 qDebug("icalclassify commented out "); 402 qDebug("icalclassify commented out ");
401 ScheduleMessage::Status status; 403 ScheduleMessage::Status status;
402#if 0 404#if 0
403 405
404 icalclass result = icalclassify(message,calendarComponent,(char *)""); 406 icalclass result = icalclassify(message,calendarComponent,(char *)"");
405 407
406 408
407 409
408 switch (result) { 410 switch (result) {
409 case ICAL_PUBLISH_NEW_CLASS: 411 case ICAL_PUBLISH_NEW_CLASS:
410 status = ScheduleMessage::PublishNew; 412 status = ScheduleMessage::PublishNew;
411 break; 413 break;
412 case ICAL_OBSOLETE_CLASS: 414 case ICAL_OBSOLETE_CLASS:
413 status = ScheduleMessage::Obsolete; 415 status = ScheduleMessage::Obsolete;
414 break; 416 break;
415 case ICAL_REQUEST_NEW_CLASS: 417 case ICAL_REQUEST_NEW_CLASS:
416 status = ScheduleMessage::RequestNew; 418 status = ScheduleMessage::RequestNew;
417 break; 419 break;
418 case ICAL_REQUEST_UPDATE_CLASS: 420 case ICAL_REQUEST_UPDATE_CLASS:
419 status = ScheduleMessage::RequestUpdate; 421 status = ScheduleMessage::RequestUpdate;
420 break; 422 break;
421 case ICAL_UNKNOWN_CLASS: 423 case ICAL_UNKNOWN_CLASS:
422 default: 424 default:
423 status = ScheduleMessage::Unknown; 425 status = ScheduleMessage::Unknown;
424 break; 426 break;
425 } 427 }
426#endif 428#endif
427 status = ScheduleMessage::RequestUpdate; 429 status = ScheduleMessage::RequestUpdate;
428 return new ScheduleMessage(incidence,method,status); 430 return new ScheduleMessage(incidence,method,status);
429} 431}
430 432
431void ICalFormat::setTimeZone( const QString &id, bool utc ) 433void ICalFormat::setTimeZone( const QString &id, bool utc )
432{ 434{
433 435
434 436
435 mTimeZoneId = id; 437 mTimeZoneId = id;
436 mUtc = utc; 438 mUtc = utc;
437 439
438 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId); 440 tzOffsetMin = KGlobal::locale()->timezoneOffset(mTimeZoneId);
439 441
440 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin); 442 //qDebug("ICalFormat::setTimeZoneOffset %s %d ",mTimeZoneId.latin1(), tzOffsetMin);
441} 443}
442 444
443QString ICalFormat::timeZoneId() const 445QString ICalFormat::timeZoneId() const
444{ 446{
445 return mTimeZoneId; 447 return mTimeZoneId;
446} 448}
447 449
448bool ICalFormat::utc() const 450bool ICalFormat::utc() const
449{ 451{
450 return mUtc; 452 return mUtc;
451} 453}
452int ICalFormat::timeOffset() 454int ICalFormat::timeOffset()
453{ 455{
454 return tzOffsetMin; 456 return tzOffsetMin;
455} 457}
456const char *ICalFormat::tzString() 458const char *ICalFormat::tzString()
457{ 459{
458 const char* ret = (const char* ) mTzString; 460 const char* ret = (const char* ) mTzString;
459 return ret; 461 return ret;
460} 462}