|
1 // Copyright (c) 2002-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 @internalComponent |
|
19 */ |
|
20 |
|
21 #ifndef __AGNVERSIT_H__ |
|
22 #define __AGNVERSIT_H__ |
|
23 |
|
24 #include <e32base.h> |
|
25 #include <e32std.h> |
|
26 #include <vcal.h> |
|
27 #include <tz.h> |
|
28 #include "calversit.h" |
|
29 #include <caldataexchange.h> |
|
30 |
|
31 #include "agmvcal.h" |
|
32 |
|
33 class TTzRule; |
|
34 class CAgnVCalConverter; |
|
35 |
|
36 class CCalImportExportActive : public CActive |
|
37 { |
|
38 public: |
|
39 CCalImportExportActive(CAgnVCalConverter& aConverter); |
|
40 ~CCalImportExportActive(); |
|
41 void Start(); |
|
42 |
|
43 // from CActive |
|
44 void RunL(); |
|
45 void DoCancel(); |
|
46 TInt RunError(TInt aError); |
|
47 private: |
|
48 CAgnVCalConverter& iConverter; |
|
49 }; |
|
50 |
|
51 class CAgnVCalConverter : public CAgnVersit |
|
52 { |
|
53 public: |
|
54 |
|
55 enum TState |
|
56 { |
|
57 EIdle, |
|
58 EImporting, |
|
59 EExporting, |
|
60 }; |
|
61 |
|
62 static CAgnVCalConverter* NewL(); |
|
63 |
|
64 //from MAgnVersit |
|
65 void ImportVCalL(TInt aFlags, RReadStream& aReadStream, RPointerArray<CCalEntry>& aEntryArray); |
|
66 void ExportVCalL(RWriteStream& aWriteStream, const RPointerArray<CCalEntry>& aEntryArray, const Versit::TVersitCharSet aCharSet); |
|
67 |
|
68 ~CAgnVCalConverter(); |
|
69 |
|
70 void ImportVCalAsyncL(TInt aFlags, RReadStream& aReadStream, RPointerArray<CCalEntry>& aEntryArray, MCalDataExchangeCallBack& aObserver); |
|
71 void ExportVCalAsyncL(RWriteStream& aWriteStream, RPointerArray<CCalEntry>& aCalEntryArray, MCalDataExchangeCallBack& aObserver, const Versit::TVersitCharSet aCharSet); |
|
72 //To be called by CCalImportExportActive |
|
73 void NextExportStepL(); |
|
74 void NextImportStepL(); |
|
75 void CancelImportExport(TInt aError = KErrNone); |
|
76 CAgnVCalConverter::TState AsyncState() const; |
|
77 private: |
|
78 void ConstructL(); |
|
79 |
|
80 CTzRules* ImportTzRulesL(CParserVCal& aCalParser) const; |
|
81 CTzRules* DaylightRulesL(CParserVCal& aCalParser, TTimeIntervalMinutes aStdOffset) const; |
|
82 TTzRule TzRuleL(TTimeIntervalMinutes aOldTzOffset, TTimeIntervalMinutes aNewTzOffset, TTime aStartTime, TTime aEndTime) const; |
|
83 TTimeIntervalMinutes StandardTimeOffsetL(CParserVCal& aCalParser) const; |
|
84 TBool ValidDaylightProperty(CParserProperty& aDaylightProperty) const; |
|
85 void ConvertEntryToVCalAndExportL(CParserVCal* aVcal, const RPointerArray<CCalEntry>& aEntryArray, RWriteStream& aWriteStream); |
|
86 void ExportEntryBySameTzL(RWriteStream& aWriteStream); |
|
87 void ExportEntryWithoutTzRuleL(RWriteStream& aWriteStream); |
|
88 void FindEntryWithoutTzRuleL(RPointerArray<CCalEntry>& aSameTzEntry); |
|
89 void FindSameTzEntryL(RPointerArray<CCalEntry>& aSameTzEntry); |
|
90 void CheckCompletion(); |
|
91 void InitialiseSameTzEntryArrayL(); |
|
92 private: |
|
93 TBool iTzConnected; |
|
94 RTz iTzServer; |
|
95 |
|
96 // for asynchronous import / export |
|
97 MCalDataExchangeCallBack* iObserver; |
|
98 |
|
99 CCalImportExportActive* iImportExportActive; |
|
100 RPointerArray<CCalEntry>* iEntryArray; //Not owned |
|
101 RPointerArray<CCalEntry>* iSametzEntries; //Not owned. The entries with same tz rule or do have tz rules |
|
102 RPointerArray<CParserVCal>* iVCalArray; //Array of vCal used when importing asynchronously. |
|
103 RArray<TInt> iEntryIndexToExport;//Each of its element is the index of the entries in the array of iEntryArray |
|
104 |
|
105 CVCalToAgendaEntryConverter* iImportConverter; |
|
106 CAgendaEntryToVCalConverter* iExportConverter; |
|
107 Versit::TVersitCharSet iCharSet; |
|
108 |
|
109 RWriteStream* iWriteStream; |
|
110 CParserVCal* iVCal; |
|
111 TState iAsyncState; |
|
112 |
|
113 TInt iTotalNumEntry; //The number of entries |
|
114 TInt iTotalCounter; //The counter out of total entries |
|
115 TInt iSameTzCounter; //The counter out of number of entries with the particular tz |
|
116 TInt iMaxNumEntryInStep; //The maxum number of entries to import\export in one step |
|
117 }; |
|
118 |
|
119 /** |
|
120 @internalComponent |
|
121 @released |
|
122 */ |
|
123 enum TAgnVersitPanic |
|
124 { |
|
125 EAgnVersitPanicNotNull, |
|
126 EAgnVersitPanicNoEntryArray, |
|
127 EAgnVersitPanicNoAAlarmProps, |
|
128 EAgnVersitPanicWrongTimeType, |
|
129 EAgnVersitWrongAttribute, |
|
130 EAgnVersitPanicWrongArgument, |
|
131 EAgnVersitPanicImportExportFailure |
|
132 }; |
|
133 |
|
134 extern void Panic(TAgnVersitPanic aPanic); |
|
135 |
|
136 #endif |