|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Exports Agenda entry to vCalendar or iCalendar data |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 //debug |
|
20 #include "calendarengines_debug.h" |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "CalenExporter.h" |
|
24 |
|
25 #include "AgnExternalInterface.h" |
|
26 #include <agnexportobserver.h> |
|
27 |
|
28 #include <caldataexchange.h> |
|
29 #include <calsession.h> |
|
30 #include <caldataformat.h> |
|
31 #include <calentry.h> // CCalEntry |
|
32 #include <f32file.h> // RFs |
|
33 #include <s32file.h> // RFileWriteStream, RFileReadStream |
|
34 |
|
35 |
|
36 #include <e32base.h> |
|
37 #include <f32file.h> // for TParse |
|
38 #include <s32mem.h> |
|
39 |
|
40 #include <coemain.h> |
|
41 #include <featmgr.h> |
|
42 |
|
43 // LOCAL CONSTANTS AND MACROS |
|
44 |
|
45 _LIT8( KICalMimeType, "text/calendar" ); |
|
46 |
|
47 enum TAgnExportMethod |
|
48 { |
|
49 EExportAll = 0xFFFFFFFF, |
|
50 EVEventPublish = KAgnExportDtStart | |
|
51 KAgnExportDtStamp | |
|
52 KAgnExportOrganizer | |
|
53 KAgnExportSummary | |
|
54 KAgnExportUID | |
|
55 KAgnExportRecurrenceId | |
|
56 KAgnExportSequence | |
|
57 KAgnExportCategory | |
|
58 KAgnExportClass | |
|
59 KAgnExportCreated | |
|
60 KAgnExportDescription | |
|
61 KAgnExportDtEnd | |
|
62 KAgnExportExDate | |
|
63 KAgnExportLastModified | |
|
64 KAgnExportLocation | |
|
65 KAgnExportPriority | |
|
66 KAgnExportRDate | |
|
67 KAgnExportRRule | |
|
68 KAgnExportStatus | |
|
69 KAgnExportXProp | |
|
70 KAgnExportTzRules | |
|
71 KAgnExportAlarm, |
|
72 |
|
73 EVEventRequest = KAgnExportAttendee | |
|
74 KAgnExportDtStamp | |
|
75 KAgnExportDtStart | |
|
76 KAgnExportOrganizer | |
|
77 KAgnExportSequence | |
|
78 KAgnExportSummary | |
|
79 KAgnExportUID | |
|
80 KAgnExportCategory | |
|
81 KAgnExportClass | |
|
82 KAgnExportCreated | |
|
83 KAgnExportDescription | |
|
84 KAgnExportDtEnd | |
|
85 KAgnExportExDate | |
|
86 KAgnExportLastModified | |
|
87 KAgnExportLocation | |
|
88 KAgnExportPriority | |
|
89 KAgnExportRDate | |
|
90 KAgnExportRecurrenceId | |
|
91 KAgnExportRRule | |
|
92 KAgnExportStatus | |
|
93 KAgnExportXProp | |
|
94 KAgnExportTzRules | |
|
95 KAgnExportAlarm, |
|
96 |
|
97 EVEventReply = KAgnExportAttendee | |
|
98 KAgnExportDtStamp | |
|
99 KAgnExportOrganizer | |
|
100 KAgnExportUID | |
|
101 KAgnExportSequence | |
|
102 KAgnExportCategory | |
|
103 KAgnExportClass | |
|
104 KAgnExportCreated | |
|
105 KAgnExportDescription | |
|
106 KAgnExportDtEnd | |
|
107 KAgnExportExDate | |
|
108 KAgnExportLastModified | |
|
109 KAgnExportLocation | |
|
110 KAgnExportPriority | |
|
111 KAgnExportRDate | |
|
112 KAgnExportRRule | |
|
113 KAgnExportStatus | |
|
114 KAgnExportSummary | |
|
115 KAgnExportXProp | |
|
116 KAgnExportTzRules, |
|
117 |
|
118 EVEventAdd = KAgnExportDtStart | |
|
119 KAgnExportDtStamp | |
|
120 KAgnExportOrganizer | |
|
121 KAgnExportSequence | |
|
122 KAgnExportSummary | |
|
123 KAgnExportUID | |
|
124 KAgnExportAttendee | |
|
125 KAgnExportCategory | |
|
126 KAgnExportClass | |
|
127 KAgnExportCreated | |
|
128 KAgnExportDescription | |
|
129 KAgnExportDtEnd | |
|
130 KAgnExportExDate | |
|
131 KAgnExportLastModified | |
|
132 KAgnExportLocation | |
|
133 KAgnExportPriority | |
|
134 KAgnExportRDate | |
|
135 KAgnExportRRule | |
|
136 KAgnExportStatus | |
|
137 KAgnExportXProp | |
|
138 KAgnExportTzRules | |
|
139 KAgnExportAlarm, |
|
140 |
|
141 EVEventCancel = KAgnExportAttendee | |
|
142 KAgnExportDtStamp | |
|
143 KAgnExportOrganizer | |
|
144 KAgnExportSequence | |
|
145 KAgnExportUID | |
|
146 KAgnExportCategory | |
|
147 KAgnExportClass | |
|
148 KAgnExportCreated | |
|
149 KAgnExportDescription | |
|
150 KAgnExportDtStart | |
|
151 KAgnExportDtEnd | |
|
152 KAgnExportExDate | |
|
153 KAgnExportLastModified | |
|
154 KAgnExportLocation | |
|
155 KAgnExportPriority | |
|
156 KAgnExportRDate | |
|
157 KAgnExportRecurrenceId | |
|
158 KAgnExportRRule | |
|
159 KAgnExportStatus | |
|
160 KAgnExportSummary | |
|
161 KAgnExportXProp | |
|
162 KAgnExportTzRules, |
|
163 |
|
164 EVEventRefresh = KAgnExportAttendee | |
|
165 KAgnExportDtStamp | |
|
166 KAgnExportOrganizer | |
|
167 KAgnExportUID | |
|
168 KAgnExportRecurrenceId | |
|
169 KAgnExportXProp, |
|
170 |
|
171 EVEventCounter = KAgnExportDtStart | |
|
172 KAgnExportDtStamp | |
|
173 KAgnExportOrganizer | |
|
174 KAgnExportSequence | |
|
175 KAgnExportSummary | |
|
176 KAgnExportUID | |
|
177 KAgnExportAttendee | |
|
178 KAgnExportCategory | |
|
179 KAgnExportClass | |
|
180 KAgnExportCreated | |
|
181 KAgnExportDescription | |
|
182 KAgnExportDtEnd | |
|
183 KAgnExportExDate | |
|
184 KAgnExportLastModified | |
|
185 KAgnExportLocation | |
|
186 KAgnExportPriority | |
|
187 KAgnExportRDate | |
|
188 KAgnExportRecurrenceId | |
|
189 KAgnExportRRule | |
|
190 KAgnExportStatus | |
|
191 KAgnExportXProp | |
|
192 KAgnExportTzRules | |
|
193 KAgnExportAlarm, |
|
194 |
|
195 EVEventDeclineCounter = KAgnExportOrganizer | |
|
196 KAgnExportDtStamp | |
|
197 KAgnExportUID | |
|
198 KAgnExportRecurrenceId | |
|
199 KAgnExportSequence | |
|
200 KAgnExportXProp, |
|
201 |
|
202 EVTodoPublish = KAgnExportDtStart | |
|
203 KAgnExportDtStamp | |
|
204 KAgnExportOrganizer | |
|
205 KAgnExportPriority | |
|
206 KAgnExportSequence | |
|
207 KAgnExportSummary | |
|
208 KAgnExportUID | |
|
209 KAgnExportCategory | |
|
210 KAgnExportClass | |
|
211 KAgnExportCreated | |
|
212 KAgnExportDescription | |
|
213 KAgnExportDtEnd | |
|
214 KAgnExportExDate | |
|
215 KAgnExportLastModified | |
|
216 KAgnExportLocation | |
|
217 KAgnExportCompleted | |
|
218 KAgnExportRDate | |
|
219 KAgnExportRecurrenceId | |
|
220 KAgnExportRRule | |
|
221 KAgnExportStatus | |
|
222 KAgnExportXProp | |
|
223 KAgnExportTzRules | |
|
224 KAgnExportAlarm, |
|
225 |
|
226 EVTodoRequest = KAgnExportAttendee | |
|
227 KAgnExportDtStamp | |
|
228 KAgnExportDtStart | |
|
229 KAgnExportOrganizer | |
|
230 KAgnExportPriority | |
|
231 KAgnExportSequence | |
|
232 KAgnExportSummary | |
|
233 KAgnExportUID | |
|
234 KAgnExportCategory | |
|
235 KAgnExportClass | |
|
236 KAgnExportCreated | |
|
237 KAgnExportDescription | |
|
238 KAgnExportDtEnd | |
|
239 KAgnExportExDate | |
|
240 KAgnExportLastModified | |
|
241 KAgnExportLocation | |
|
242 KAgnExportCompleted | |
|
243 KAgnExportRDate | |
|
244 KAgnExportRecurrenceId | |
|
245 KAgnExportRRule | |
|
246 KAgnExportStatus | |
|
247 KAgnExportXProp | |
|
248 KAgnExportTzRules | |
|
249 KAgnExportAlarm, |
|
250 |
|
251 EVTodoReply = KAgnExportAttendee | |
|
252 KAgnExportDtStamp | |
|
253 KAgnExportOrganizer | |
|
254 KAgnExportUID | |
|
255 KAgnExportCategory | |
|
256 KAgnExportClass | |
|
257 KAgnExportCreated | |
|
258 KAgnExportDescription | |
|
259 KAgnExportDtStart | |
|
260 KAgnExportDtEnd | |
|
261 KAgnExportExDate | |
|
262 KAgnExportLastModified | |
|
263 KAgnExportLocation | |
|
264 KAgnExportCompleted | |
|
265 KAgnExportPriority | |
|
266 KAgnExportRDate | |
|
267 KAgnExportRRule | |
|
268 KAgnExportRecurrenceId | |
|
269 KAgnExportSequence | |
|
270 KAgnExportStatus | |
|
271 KAgnExportSummary | |
|
272 KAgnExportXProp | |
|
273 KAgnExportTzRules, |
|
274 |
|
275 EVTodoAdd = KAgnExportOrganizer | |
|
276 KAgnExportDtStamp | |
|
277 KAgnExportPriority | |
|
278 KAgnExportSequence | |
|
279 KAgnExportSummary | |
|
280 KAgnExportUID | |
|
281 KAgnExportAttendee | |
|
282 KAgnExportCategory | |
|
283 KAgnExportClass | |
|
284 KAgnExportCreated | |
|
285 KAgnExportDescription | |
|
286 KAgnExportDtStart | |
|
287 KAgnExportDtEnd | |
|
288 KAgnExportExDate | |
|
289 KAgnExportLastModified | |
|
290 KAgnExportLocation | |
|
291 KAgnExportCompleted | |
|
292 KAgnExportRDate | |
|
293 KAgnExportRRule | |
|
294 KAgnExportStatus | |
|
295 KAgnExportXProp | |
|
296 KAgnExportTzRules | |
|
297 KAgnExportAlarm, |
|
298 |
|
299 EVTodoCancel = KAgnExportAttendee | |
|
300 KAgnExportUID | |
|
301 KAgnExportOrganizer | |
|
302 KAgnExportSequence | |
|
303 KAgnExportDtStamp | |
|
304 KAgnExportCategory | |
|
305 KAgnExportClass | |
|
306 KAgnExportCreated | |
|
307 KAgnExportDescription | |
|
308 KAgnExportDtStart | |
|
309 KAgnExportDtEnd | |
|
310 KAgnExportExDate | |
|
311 KAgnExportLastModified | |
|
312 KAgnExportLocation | |
|
313 KAgnExportCompleted | |
|
314 KAgnExportRDate | |
|
315 KAgnExportRecurrenceId | |
|
316 KAgnExportRRule | |
|
317 KAgnExportPriority | |
|
318 KAgnExportStatus | |
|
319 KAgnExportXProp | |
|
320 KAgnExportTzRules, |
|
321 |
|
322 EVTodoRefresh = KAgnExportAttendee | |
|
323 KAgnExportDtStamp | |
|
324 KAgnExportUID | |
|
325 KAgnExportRecurrenceId | |
|
326 KAgnExportXProp, |
|
327 |
|
328 EVTodoCounter = KAgnExportAttendee | |
|
329 KAgnExportDtStamp | |
|
330 KAgnExportOrganizer | |
|
331 KAgnExportPriority | |
|
332 KAgnExportSummary | |
|
333 KAgnExportUID | |
|
334 KAgnExportCategory | |
|
335 KAgnExportClass | |
|
336 KAgnExportCreated | |
|
337 KAgnExportDescription | |
|
338 KAgnExportDtStart | |
|
339 KAgnExportDtEnd | |
|
340 KAgnExportExDate | |
|
341 KAgnExportLastModified | |
|
342 KAgnExportLocation | |
|
343 KAgnExportCompleted | |
|
344 KAgnExportRDate | |
|
345 KAgnExportRecurrenceId | |
|
346 KAgnExportRRule | |
|
347 KAgnExportSequence | |
|
348 KAgnExportStatus | |
|
349 KAgnExportXProp | |
|
350 KAgnExportTzRules | |
|
351 KAgnExportAlarm, |
|
352 |
|
353 EVTodoDeclineCounter = KAgnExportAttendee | |
|
354 KAgnExportDtStamp | |
|
355 KAgnExportOrganizer | |
|
356 KAgnExportSequence | |
|
357 KAgnExportUID | |
|
358 KAgnExportCategory | |
|
359 KAgnExportClass | |
|
360 KAgnExportCreated | |
|
361 KAgnExportDescription | |
|
362 KAgnExportDtStart | |
|
363 KAgnExportDtEnd | |
|
364 KAgnExportExDate | |
|
365 KAgnExportLastModified | |
|
366 KAgnExportLocation | |
|
367 KAgnExportCompleted | |
|
368 KAgnExportPriority | |
|
369 KAgnExportRDate | |
|
370 KAgnExportRecurrenceId | |
|
371 KAgnExportRRule | |
|
372 KAgnExportStatus | |
|
373 KAgnExportXProp | |
|
374 KAgnExportTzRules |
|
375 }; |
|
376 |
|
377 |
|
378 |
|
379 // ============================ MEMBER FUNCTIONS =============================== |
|
380 |
|
381 EXPORT_C CCalenExporter* CCalenExporter::NewL( CCalSession& aSession ) |
|
382 { |
|
383 TRACE_ENTRY_POINT; |
|
384 |
|
385 CCalenExporter* self = new (ELeave) CCalenExporter( aSession ); |
|
386 CleanupStack::PushL(self); |
|
387 self->ConstructL(); |
|
388 CleanupStack::Pop(); // self |
|
389 |
|
390 TRACE_EXIT_POINT; |
|
391 return self; |
|
392 } |
|
393 |
|
394 void CCalenExporter::ConstructL() |
|
395 { |
|
396 TRACE_ENTRY_POINT; |
|
397 TRACE_EXIT_POINT; |
|
398 } |
|
399 |
|
400 EXPORT_C CCalenExporter::~CCalenExporter() |
|
401 { |
|
402 TRACE_ENTRY_POINT; |
|
403 |
|
404 delete iICalInterface; |
|
405 |
|
406 TRACE_EXIT_POINT; |
|
407 } |
|
408 |
|
409 // ---------------------------------------------------------------------------- |
|
410 // CCalenExporter::CCalenExporter |
|
411 // C++ default constructor can NOT contain any code, that |
|
412 // might leave. |
|
413 // ---------------------------------------------------------------------------- |
|
414 // |
|
415 CCalenExporter::CCalenExporter( CCalSession& aSession ) : |
|
416 iSession( aSession ) |
|
417 { |
|
418 TRACE_ENTRY_POINT; |
|
419 |
|
420 //Debug counter, used for incrementing the file number |
|
421 #ifdef TRACE_TO_FILE_EXPORT |
|
422 iFileNumber = 0; |
|
423 iExported = EFalse; |
|
424 #endif |
|
425 |
|
426 TRACE_EXIT_POINT; |
|
427 } |
|
428 |
|
429 // ---------------------------------------------------------------------------- |
|
430 // CCalenExporter::ExportVCalL |
|
431 // Export one CCalEntry to write stream. |
|
432 // ---------------------------------------------------------------------------- |
|
433 // |
|
434 EXPORT_C void CCalenExporter::ExportVCalL( const CCalEntry& aEntry, RWriteStream& aWriteStream ) |
|
435 { |
|
436 TRACE_ENTRY_POINT; |
|
437 |
|
438 CCalDataExchange* exporter = CCalDataExchange::NewL( iSession ); |
|
439 CleanupStack::PushL( exporter ); |
|
440 |
|
441 RPointerArray< CCalEntry > array; |
|
442 CleanupClosePushL(array); |
|
443 array.Append( &aEntry ); |
|
444 exporter->ExportL( KUidVCalendar, aWriteStream, array ); |
|
445 CleanupStack::PopAndDestroy( 2 ); |
|
446 |
|
447 //Debug - Write the iCal to file |
|
448 #ifdef TRACE_TO_FILE_EXPORT |
|
449 DebugPrintFunction( aEntry, EVCal ); |
|
450 #endif |
|
451 |
|
452 TRACE_EXIT_POINT; |
|
453 } |
|
454 |
|
455 // ---------------------------------------------------------------------------- |
|
456 // CCalenExporter::ExportICalL |
|
457 // Export one CCalEntry to write stream. |
|
458 // ---------------------------------------------------------------------------- |
|
459 // |
|
460 EXPORT_C void CCalenExporter::ExportICalL( const CCalEntry& aEntry, RWriteStream& aWriteStream ) |
|
461 { |
|
462 TRACE_ENTRY_POINT; |
|
463 |
|
464 TInt flags = GetExportFlagsL( aEntry ); |
|
465 if( !iICalInterface ) |
|
466 { |
|
467 iICalInterface = CAgnExternalInterface::NewL( KICalMimeType ); |
|
468 } |
|
469 iICalInterface->ExportL( aEntry, aWriteStream, flags, *this); |
|
470 |
|
471 //Debug - Write the iCal to file |
|
472 #ifdef TRACE_TO_FILE_EXPORT |
|
473 DebugPrintFunction( aEntry, EICal ); |
|
474 #endif |
|
475 |
|
476 TRACE_EXIT_POINT; |
|
477 } |
|
478 |
|
479 // ---------------------------------------------------------------------------- |
|
480 // CCalenExporter::ExportVCalL |
|
481 // Export multiple CCalEntries to write stream. |
|
482 // ---------------------------------------------------------------------------- |
|
483 // |
|
484 EXPORT_C void CCalenExporter::ExportVCalL( |
|
485 const RPointerArray<CCalEntry>& aArray, |
|
486 RWriteStream& aWriteStream ) |
|
487 { |
|
488 TRACE_ENTRY_POINT; |
|
489 |
|
490 if( aArray.Count() > 1 ) |
|
491 { |
|
492 User::Leave( KErrNotSupported ); |
|
493 } |
|
494 |
|
495 ExportVCalL( *aArray[0], aWriteStream ); |
|
496 |
|
497 |
|
498 //Debug - Write the vCal to file |
|
499 #ifdef TRACE_TO_FILE_EXPORT |
|
500 DebugPrintFunction( *aArray[0], EVCal ); |
|
501 #endif |
|
502 |
|
503 TRACE_EXIT_POINT; |
|
504 } |
|
505 |
|
506 // ---------------------------------------------------------------------------- |
|
507 // CCalenExporter::ExportICalL |
|
508 // Export multiple CCalEntries to write stream. |
|
509 // ---------------------------------------------------------------------------- |
|
510 // |
|
511 EXPORT_C void CCalenExporter::ExportICalL( |
|
512 const RPointerArray<CCalEntry>& aArray, |
|
513 RWriteStream& aWriteStream ) |
|
514 { |
|
515 TRACE_ENTRY_POINT; |
|
516 |
|
517 if( aArray.Count() > 1 ) |
|
518 { |
|
519 User::Leave( KErrNotSupported ); |
|
520 } |
|
521 |
|
522 ExportICalL( *aArray[0], aWriteStream ); |
|
523 |
|
524 //Debug - Write the iCal to file |
|
525 #ifdef TRACE_TO_FILE_EXPORT |
|
526 DebugPrintFunction( *aArray[0], EICal ); |
|
527 #endif |
|
528 |
|
529 TRACE_EXIT_POINT; |
|
530 } |
|
531 |
|
532 TInt CCalenExporter::GetExportFlagsL(const CCalEntry& aEntry) |
|
533 { |
|
534 TRACE_ENTRY_POINT; |
|
535 |
|
536 switch (aEntry.EntryTypeL()) |
|
537 { |
|
538 case CCalEntry::EEvent: |
|
539 { |
|
540 switch (aEntry.MethodL()) |
|
541 { |
|
542 case CCalEntry::EMethodNone: |
|
543 TRACE_EXIT_POINT; |
|
544 return EExportAll; |
|
545 case CCalEntry::EMethodPublish: |
|
546 TRACE_EXIT_POINT; |
|
547 return EVEventPublish; |
|
548 case CCalEntry::EMethodRequest: |
|
549 TRACE_EXIT_POINT; |
|
550 return EVEventRequest; |
|
551 case CCalEntry::EMethodReply: |
|
552 TRACE_EXIT_POINT; |
|
553 return EVEventReply; |
|
554 case CCalEntry::EMethodAdd: |
|
555 TRACE_EXIT_POINT; |
|
556 return EVEventAdd; |
|
557 case CCalEntry::EMethodCancel: |
|
558 TRACE_EXIT_POINT; |
|
559 return EVEventCancel; |
|
560 case CCalEntry::EMethodRefresh: |
|
561 TRACE_EXIT_POINT; |
|
562 return EVEventRefresh; |
|
563 case CCalEntry::EMethodCounter: |
|
564 TRACE_EXIT_POINT; |
|
565 return EVEventCounter; |
|
566 case CCalEntry::EMethodDeclineCounter: |
|
567 TRACE_EXIT_POINT; |
|
568 return EVEventDeclineCounter; |
|
569 } |
|
570 } |
|
571 break; |
|
572 case CCalEntry::ETodo: |
|
573 { |
|
574 switch (aEntry.MethodL()) |
|
575 { |
|
576 case CCalEntry::EMethodNone: |
|
577 TRACE_EXIT_POINT; |
|
578 return EExportAll; |
|
579 case CCalEntry::EMethodPublish: |
|
580 TRACE_EXIT_POINT; |
|
581 return EVTodoPublish; |
|
582 case CCalEntry::EMethodRequest: |
|
583 TRACE_EXIT_POINT; |
|
584 return EVTodoRequest; |
|
585 case CCalEntry::EMethodReply: |
|
586 TRACE_EXIT_POINT; |
|
587 return EVTodoReply; |
|
588 case CCalEntry::EMethodAdd: |
|
589 TRACE_EXIT_POINT; |
|
590 return EVTodoAdd; |
|
591 case CCalEntry::EMethodCancel: |
|
592 TRACE_EXIT_POINT; |
|
593 return EVTodoCancel; |
|
594 case CCalEntry::EMethodRefresh: |
|
595 TRACE_EXIT_POINT; |
|
596 return EVTodoRefresh; |
|
597 case CCalEntry::EMethodCounter: |
|
598 TRACE_EXIT_POINT; |
|
599 return EVTodoCounter; |
|
600 case CCalEntry::EMethodDeclineCounter: |
|
601 TRACE_EXIT_POINT; |
|
602 return EVTodoDeclineCounter; |
|
603 } |
|
604 } |
|
605 } |
|
606 |
|
607 TRACE_EXIT_POINT; |
|
608 return EExportAll; |
|
609 } |
|
610 |
|
611 MAgnExportObserver::TExpResponse CCalenExporter::AgnExportErrorL( |
|
612 TExpError /*aType*/, |
|
613 const TDesC8& /*aUid*/, |
|
614 const TDesC& /*aContext*/) |
|
615 { |
|
616 TRACE_ENTRY_POINT; |
|
617 TRACE_EXIT_POINT; |
|
618 return EExpResponseContinue; |
|
619 } |
|
620 |
|
621 |
|
622 #ifdef TRACE_TO_FILE_EXPORT |
|
623 //Wrapper function to write the CCalEntry to file |
|
624 void CCalenExporter::DebugPrintFunction( const CCalEntry& aEntry, const TDebugExportType& aType ) |
|
625 { |
|
626 //Very ugly code, if you know how to use the buffer of RWriteStream update this function!! |
|
627 //This function will be called from ExportV/ICal, therefore a boolean to check if it |
|
628 //has been imported already so debug function wont be called again and cause a loop. |
|
629 if( !iExported ) |
|
630 { |
|
631 TRAPD( error, WriteStreamToFileL( aEntry, aType ) ); |
|
632 iExported = ETrue; |
|
633 } |
|
634 else |
|
635 { |
|
636 iExported = EFalse; |
|
637 } |
|
638 } |
|
639 |
|
640 //Writes the CCalEntry to file |
|
641 void CCalenExporter::WriteStreamToFileL( const CCalEntry& aEntry, const TDebugExportType& aType ) |
|
642 { |
|
643 TBuf<50> fileName; |
|
644 _LIT(KDefaultFileName, "C://calenExp_%d.txt"); |
|
645 fileName.Format( KDefaultFileName, iFileNumber ); |
|
646 |
|
647 RFs aFs; |
|
648 User::LeaveIfError(aFs.Connect()); |
|
649 CleanupClosePushL(aFs); |
|
650 aFs.MkDirAll(KDefaultFileName); |
|
651 |
|
652 RFileWriteStream rs; |
|
653 User::LeaveIfError(rs.Replace(aFs, fileName, EFileWrite)); |
|
654 CleanupClosePushL(rs); |
|
655 |
|
656 //check if vCal otherwise export as iCal |
|
657 if( aType == EVCal ) |
|
658 { |
|
659 ExportVCalL( aEntry, rs ); |
|
660 } |
|
661 else |
|
662 { |
|
663 ExportICalL( aEntry, rs ); |
|
664 } |
|
665 |
|
666 rs.CommitL(); |
|
667 |
|
668 CleanupStack::PopAndDestroy(&rs); |
|
669 CleanupStack::PopAndDestroy(&aFs); |
|
670 |
|
671 ++iFileNumber; |
|
672 } |
|
673 #endif |
|
674 // End of File |