|
1 /* |
|
2 * Copyright (c) 2002-2006 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: Engine for ICalViewer |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "CICalEngine.h" |
|
21 |
|
22 //RPointerArray |
|
23 #include <e32std.h> |
|
24 //RFileReadStream |
|
25 #include <s32file.h> |
|
26 //CRichText |
|
27 #include <txtrich.h> |
|
28 //CPlainText |
|
29 #include <txtetext.h> |
|
30 //CCalEntry (Calendar entry API V2) |
|
31 #include <calentry.h> |
|
32 //attachments |
|
33 #include <CMsvAttachment.h> |
|
34 //Entry ui ECOM implemantion |
|
35 #include <CAgnEntryUi.h> |
|
36 |
|
37 |
|
38 #include <MMsvAttachmentManager.h> |
|
39 |
|
40 // Temporary files could always be saved to drive C. |
|
41 _LIT(KDefaultTmpFileName,"C:\\system\\temp\\"); // CSI: 25 # See comment above. |
|
42 _LIT(KDefaultSettingsFileName,"C:\\system\\temp\\icaltmp"); // CSI: 25 # See comment above. |
|
43 |
|
44 // ============================ MEMBER FUNCTIONS =============================== |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CICalEngine::CICalEngine |
|
48 // C++ default constructor can NOT contain any code, that |
|
49 // might leave. |
|
50 // ----------------------------------------------------------------------------- |
|
51 // |
|
52 CICalEngine::CICalEngine() |
|
53 { |
|
54 } |
|
55 |
|
56 // ----------------------------------------------------------------------------- |
|
57 // CICalEngine::ConstructL |
|
58 // Symbian 2nd phase constructor can leave. |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 void CICalEngine::ConstructL() |
|
62 { |
|
63 |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CICalEngine::~CICalEngine |
|
68 // Destructor |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CICalEngine::~CICalEngine() |
|
72 { |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CICalEngine::NewL |
|
77 // Two-phased constructor. |
|
78 // ----------------------------------------------------------------------------- |
|
79 // |
|
80 EXPORT_C CICalEngine* CICalEngine::NewL() |
|
81 { |
|
82 CICalEngine* self = new( ELeave ) CICalEngine; |
|
83 |
|
84 CleanupStack::PushL( self ); |
|
85 self->ConstructL(); |
|
86 CleanupStack::Pop(); |
|
87 |
|
88 return self; |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // CICalEngine::ConvertRichTextToStreamL |
|
93 // ----------------------------------------------------------------------------- |
|
94 // |
|
95 EXPORT_C TInt CICalEngine::ConvertRichTextToStreamL( // CSI: 40 # We must return |
|
96 // the integer value although this |
|
97 // is a leaving method. |
|
98 CRichText* aBuffer, RFileReadStream& aReadStream) |
|
99 { |
|
100 HBufC* extracted = HBufC::NewL(1000); // CSI: 47 # <insert a comment here> |
|
101 CleanupStack::PushL(extracted); |
|
102 TPtr extractedBuf = extracted->Des(); |
|
103 aBuffer->Extract(extractedBuf); |
|
104 |
|
105 RFs fs; |
|
106 User::LeaveIfError( fs.Connect() ); |
|
107 CleanupClosePushL( fs ); |
|
108 fs.MkDirAll( KDefaultTmpFileName ); |
|
109 |
|
110 HBufC8* copy8Bit = HBufC8::NewL( 1000 ); // CSI: 47 # <insert a comment here> |
|
111 CleanupStack::PushL( copy8Bit ); |
|
112 TPtr8 copy8BitPtr = copy8Bit->Des(); |
|
113 |
|
114 copy8BitPtr.Copy( extractedBuf ); |
|
115 |
|
116 RFile file; |
|
117 file.Replace( fs, KDefaultSettingsFileName, EFileWrite ); |
|
118 file.Write( copy8BitPtr ); |
|
119 file.Flush(); |
|
120 file.Close(); |
|
121 |
|
122 CleanupStack::PopAndDestroy( copy8Bit ); |
|
123 |
|
124 aReadStream.Open( fs, KDefaultSettingsFileName, EFileRead ); |
|
125 |
|
126 CleanupStack::PopAndDestroy( 2, extracted ); // CSI: 47 # extracted, fs |
|
127 |
|
128 return KErrNone; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CICalEngine::ParseStreamToCalEntryL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 EXPORT_C CCalEntry* CICalEngine::ParseStreamToCalEntryL( |
|
136 RFileReadStream& /*aReadStream*/) |
|
137 { |
|
138 // Not supported |
|
139 return NULL; |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CICalEngine::ResolveAttachmentsVisibilityL |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C void CICalEngine::ResolveAttachmentsVisibilityL( |
|
147 MMsvAttachmentManager& /*aManager*/, |
|
148 RPointerArray<CMsvAttachment>& /*aAttachementsArray*/, |
|
149 TBool /*aBodyHasOMR*/) |
|
150 { |
|
151 // RFs fs; |
|
152 // User::LeaveIfError(fs.Connect()); |
|
153 // CleanupClosePushL(fs); |
|
154 /* TInt count(aManager.AttachmentCount()); |
|
155 for (TInt index=0; index<count; ++index) |
|
156 { |
|
157 RFile attachmentFile = aManager.GetAttachmentFileL(index); |
|
158 CleanupClosePushL( attachmentFile ); |
|
159 TInt fileSize = 0; |
|
160 User::LeaveIfError( attachmentFile.Size(fileSize) ); |
|
161 |
|
162 HBufC8* fileBuf = HBufC8::NewLC(fileSize); |
|
163 TPtr8 fileBufPtr = fileBuf->Des(); |
|
164 User::LeaveIfError(attachmentFile.Read(fileBufPtr)); |
|
165 |
|
166 TBool isOMR; |
|
167 |
|
168 //isOMR = RecogniseOMREntryL(fileBufPtr); |
|
169 |
|
170 CleanupStack::PopAndDestroy();//fileBuf is not needed any more |
|
171 |
|
172 //if index is 0 AND attachment is OMR it is not included in |
|
173 // the attachments model |
|
174 // UNLESS a body already has OMR. |
|
175 // In that case this another OMR attachment IS included in model |
|
176 if ((isOMR && index > 0) || aBodyHasOMR) |
|
177 { |
|
178 CMsvAttachment* info = aManager.GetAttachmentInfoL(index); |
|
179 CleanupStack::PushL(info); |
|
180 aAttachementsArray.Append(info); |
|
181 } |
|
182 }*/ |
|
183 // CleanupStack::PopAndDestroy(); //fs |
|
184 } |
|
185 |
|
186 // ----------------------------------------------------------------------------- |
|
187 // CICalEngine::CreateEntryUIL |
|
188 // ----------------------------------------------------------------------------- |
|
189 // |
|
190 EXPORT_C MAgnEntryUi* CICalEngine::CreateEntryUIL( const TDesC8& aMtmId ) |
|
191 { |
|
192 MAgnEntryUi* entryUI; |
|
193 entryUI = CAgnEntryUi::NewL( aMtmId ); |
|
194 return entryUI; |
|
195 } |
|
196 |
|
197 // End of File |
|
198 |