|
1 /* |
|
2 * Copyright (c) 2005 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: |
|
15 * Bio control for iCalendar messages. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include <eikon.hrh> |
|
25 #include <e32base.h> |
|
26 #include <eikmenup.h> |
|
27 #include <msvapi.h> |
|
28 #include <s32file.h> // RFileReadStream |
|
29 #include <stringloader.h> // StringLoader |
|
30 #include <msgbiocontrolobserver.h> // MMsgBioControlObserver |
|
31 #include <crichbio.h> // CRichBio |
|
32 #include <msgbioutils.h> |
|
33 #include "CICalBC.h" // CICalendarBioControl |
|
34 #include <bldvariant.hrh> // __SERIES60_HELP |
|
35 #include <csxhelp/smart.hlp.hrh> |
|
36 #include <FeatMgr.h> |
|
37 #include <MMsvAttachmentManager.h> |
|
38 #include <f32file.h> |
|
39 #include <MeetingRequestUids.hrh> |
|
40 #include <avkon.hrh> |
|
41 |
|
42 |
|
43 // LOCAL CONSTANTS AND MACROS |
|
44 const TInt KLengthBeginICalendar = 15; // "BEGIN:VCALENDAR" -string length |
|
45 const TInt KICalBcHeightReductionBva = 9; |
|
46 |
|
47 _LIT(KAvkonResourceFile, "avkon.rsc"); |
|
48 |
|
49 // MEMBER FUNCTIONS |
|
50 |
|
51 CICalendarBioControl::~CICalendarBioControl() |
|
52 { |
|
53 FeatureManager::UnInitializeLib(); |
|
54 iVCalStream.Close(); |
|
55 delete iICalContainer; |
|
56 } |
|
57 |
|
58 EXPORT_C CMsgBioControl* CICalendarBioControl::NewL( |
|
59 MMsgBioControlObserver& aObserver, |
|
60 CMsvSession* aSession, |
|
61 TMsvId aId, |
|
62 TMsgBioMode aEditorOrViewerMode, |
|
63 const RFile* aFile ) |
|
64 { |
|
65 CICalendarBioControl* self = new(ELeave) CICalendarBioControl( |
|
66 aObserver, |
|
67 aSession, |
|
68 aId, |
|
69 aEditorOrViewerMode, |
|
70 aFile ); |
|
71 CleanupStack::PushL(self); |
|
72 self->ConstructL(); |
|
73 CleanupStack::Pop(); //self |
|
74 return self; |
|
75 } |
|
76 |
|
77 void CICalendarBioControl::SetAndGetSizeL(TSize& aSize) |
|
78 { |
|
79 if ( iIsFileBased ) |
|
80 { |
|
81 SetPosition(TPoint(0, KICalBcHeightReductionBva)); |
|
82 aSize.iHeight -= KICalBcHeightReductionBva; |
|
83 iViewer->SetSize(aSize); |
|
84 } |
|
85 else |
|
86 { |
|
87 iViewer->SetSize(aSize); |
|
88 } |
|
89 SetSizeWithoutNotification(aSize); |
|
90 } |
|
91 |
|
92 void CICalendarBioControl::SetMenuCommandSetL(CEikMenuPane& aMenuPane) |
|
93 { |
|
94 if (!IsEditor()) |
|
95 { |
|
96 if ( iIsFileBased ) |
|
97 { |
|
98 iICalContainer->DynInitMenuPaneL(0,&aMenuPane); |
|
99 } |
|
100 } |
|
101 } |
|
102 |
|
103 TBool CICalendarBioControl::HandleBioCommandL(TInt aCommand) |
|
104 { |
|
105 return iICalContainer->HandleCommandL(aCommand); |
|
106 } |
|
107 |
|
108 TRect CICalendarBioControl::CurrentLineRect() const |
|
109 { |
|
110 //return iViewer->CurrentLineRect(); |
|
111 return TRect(); |
|
112 } |
|
113 |
|
114 TBool CICalendarBioControl::IsFocusChangePossible( |
|
115 TMsgFocusDirection /*aDirection*/) const |
|
116 { |
|
117 return EFalse; |
|
118 } |
|
119 |
|
120 HBufC* CICalendarBioControl::HeaderTextL() const |
|
121 { |
|
122 return KNullDesC().AllocL(); |
|
123 } |
|
124 |
|
125 TInt CICalendarBioControl::VirtualHeight() |
|
126 { |
|
127 return 0; |
|
128 } |
|
129 |
|
130 TInt CICalendarBioControl::VirtualVisibleTop() |
|
131 { |
|
132 return 0; |
|
133 } |
|
134 |
|
135 TBool CICalendarBioControl::IsCursorLocation(TMsgCursorLocation /*aLocation*/) const |
|
136 { |
|
137 return EFalse; |
|
138 } |
|
139 |
|
140 TInt CICalendarBioControl::CountComponentControls() const |
|
141 { |
|
142 return 1; // the viewer component |
|
143 } |
|
144 |
|
145 CCoeControl* CICalendarBioControl::ComponentControl(TInt aIndex) const |
|
146 { |
|
147 if (aIndex == 0) |
|
148 { |
|
149 return iViewer; |
|
150 } |
|
151 return NULL; |
|
152 } |
|
153 |
|
154 void CICalendarBioControl::SizeChanged() |
|
155 { |
|
156 iViewer->SetExtent(Position(), iViewer->Size()); |
|
157 } |
|
158 |
|
159 void CICalendarBioControl::FocusChanged(TDrawNow /*aDrawNow*/) |
|
160 { |
|
161 iViewer->SetFocus(IsFocused()); |
|
162 } |
|
163 |
|
164 void CICalendarBioControl::SetContainerWindowL(const CCoeControl& aContainer) |
|
165 { |
|
166 CCoeControl::SetContainerWindowL(aContainer); |
|
167 iParentControl = const_cast<CCoeControl*>(&aContainer); |
|
168 |
|
169 iICalContainer->ViewMessageL(iVCalStream,*this); |
|
170 } |
|
171 |
|
172 TKeyResponse CICalendarBioControl::OfferKeyEventL( |
|
173 const TKeyEvent& aKeyEvent, |
|
174 TEventCode aType) |
|
175 { |
|
176 return iViewer->OfferKeyEventL(aKeyEvent, aType); |
|
177 } |
|
178 |
|
179 void CICalendarBioControl::FileBasedAddMenuItemL(CEikMenuPane& aMenuPane, |
|
180 TInt aStringRes, TInt aCommandOffset) |
|
181 { |
|
182 CEikMenuPaneItem::SData menuItem; |
|
183 menuItem.iCascadeId = NULL; |
|
184 menuItem.iFlags = NULL; |
|
185 HBufC* menuItemText(StringLoader::LoadLC(aStringRes, iCoeEnv)); |
|
186 TPtr textPtr = menuItemText->Des(); |
|
187 if(textPtr.Length() > CEikMenuPaneItem::SData::ENominalTextLength) |
|
188 { |
|
189 menuItem.iText.Format(textPtr.MidTPtr(0,CEikMenuPaneItem::SData::ENominalTextLength) ); |
|
190 } |
|
191 else |
|
192 { |
|
193 menuItem.iText.Format(textPtr); |
|
194 } |
|
195 CleanupStack::PopAndDestroy(menuItemText); // (string) |
|
196 menuItem.iCommandId = iBioControlObserver.FirstFreeCommand() |
|
197 + aCommandOffset; |
|
198 aMenuPane.InsertMenuItemL(menuItem, 0); |
|
199 iICalContainer->DynInitMenuPaneL(0,&aMenuPane); |
|
200 } |
|
201 |
|
202 void CICalendarBioControl::OpenStreamLC(RFileReadStream& aStream, |
|
203 TFileName& aFileName) |
|
204 { |
|
205 User::LeaveIfError( aStream.Open( |
|
206 CCoeEnv::Static()->FsSession(), |
|
207 aFileName, |
|
208 EFileStream )); |
|
209 aStream.PushL(); |
|
210 } |
|
211 |
|
212 CICalendarBioControl::CICalendarBioControl( |
|
213 MMsgBioControlObserver& aObserver, |
|
214 CMsvSession* aSession, |
|
215 TMsvId aId, |
|
216 TMsgBioMode aEditorOrViewerMode, |
|
217 const RFile* aFile ): |
|
218 CMsgBioControl(aObserver, |
|
219 aSession, |
|
220 aId, |
|
221 aEditorOrViewerMode, |
|
222 aFile ) |
|
223 { |
|
224 } |
|
225 |
|
226 void CICalendarBioControl::ConstructL() |
|
227 { |
|
228 LoadResourceL(KAvkonResourceFile); |
|
229 LoadStandardBioResourceL(); |
|
230 |
|
231 // Due to current bio control base problem filehandle & IsFileBased() mustn't |
|
232 // be accessed after construction phase! |
|
233 RFile fileHandle; |
|
234 iIsFileBased = IsFileBased(); |
|
235 if ( iIsFileBased ) |
|
236 { |
|
237 fileHandle = FileHandle(); |
|
238 iVCalStream.Attach( fileHandle ); |
|
239 } |
|
240 else |
|
241 { |
|
242 CMsvEntry* entry = MsvSession().GetEntryL( iId ); |
|
243 CleanupStack::PushL( entry ); |
|
244 CMsvStore* store = entry->ReadStoreL(); |
|
245 CleanupStack::PushL(store); |
|
246 MMsvAttachmentManager& attachMan = store->AttachmentManagerL(); |
|
247 fileHandle = attachMan.GetAttachmentFileL( 0 ); //entry is the first attachment |
|
248 iVCalStream.Attach( fileHandle ); |
|
249 CleanupStack::PopAndDestroy( 2 ); // store, entry |
|
250 } |
|
251 |
|
252 MStreamBuf* buf = iVCalStream.Source(); |
|
253 User::LeaveIfNull(buf); |
|
254 TInt bufferSize = buf->SizeL(); |
|
255 if (bufferSize == 0 || (bufferSize < KLengthBeginICalendar)) |
|
256 { |
|
257 User::Leave(KErrMsgBioMessageNotValid); |
|
258 } |
|
259 |
|
260 FeatureManager::InitializeLibL(); |
|
261 |
|
262 TUid viewerID = TUid::Uid(KUidMsgMailECOMIcalViewImpl); |
|
263 iICalContainer = CMailMessageView::NewL(viewerID); |
|
264 |
|
265 LoadResourceL(iICalContainer->ResourceFile()); |
|
266 |
|
267 fileHandle.Close(); |
|
268 } |
|
269 |
|
270 void CICalendarBioControl::AddAttachmentL( |
|
271 CMsvAttachment& /*aAttachmentInfo*/, |
|
272 TBool /*aCanBeRemoved*/ ) |
|
273 { |
|
274 |
|
275 } |
|
276 |
|
277 void CICalendarBioControl::AddControlL(CCoeControl& aControl) |
|
278 { |
|
279 iViewer = &aControl; |
|
280 } |
|
281 |
|
282 void CICalendarBioControl::AddControlL( TInt /*aControlType*/ ) |
|
283 { |
|
284 } |
|
285 |
|
286 void CICalendarBioControl::AddControlL( MMailMsgBaseControl& /*aControl*/ ) |
|
287 { |
|
288 } |
|
289 |
|
290 CCoeControl& CICalendarBioControl::ParentControl() |
|
291 { |
|
292 return *iParentControl; |
|
293 } |
|
294 |
|
295 CEikStatusPane* CICalendarBioControl::StatusPane() |
|
296 { |
|
297 return NULL; |
|
298 } |
|
299 |
|
300 void CICalendarBioControl::SetTitleTextL(TInt aResourceId) |
|
301 { |
|
302 iTitleResourceID = aResourceId; |
|
303 } |
|
304 |
|
305 void CICalendarBioControl::StartWaitNoteL(/*const TDesC& aText*/) |
|
306 { |
|
307 } |
|
308 |
|
309 void CICalendarBioControl::StopWaitNote() |
|
310 { |
|
311 } |
|
312 |
|
313 void CICalendarBioControl::SetAddressFieldTextL(TInt /*aControlType*/, CDesCArray& /*aText*/) |
|
314 { |
|
315 } |
|
316 void CICalendarBioControl::SetAddressFieldTextL(TInt /*aControlType*/, TDesC& /*aText*/) |
|
317 { |
|
318 } |
|
319 |
|
320 void CICalendarBioControl::SetBodyTextL(CRichText& /*aText*/) |
|
321 { |
|
322 } |
|
323 |
|
324 void CICalendarBioControl::SetSubjectL(const TDesC& /*aText*/) |
|
325 { |
|
326 } |
|
327 |
|
328 TRect CICalendarBioControl::MsgViewRect(TInt /*aPane*/) |
|
329 { |
|
330 return TRect(0,0,0,0); |
|
331 } |
|
332 |
|
333 void CICalendarBioControl::AppUiHandleCommandL(TInt aCommand) |
|
334 { |
|
335 switch( aCommand ) |
|
336 { |
|
337 case EAknSoftkeyBack: |
|
338 { |
|
339 iBioControlObserver.RequestHandleCommandL(MMsgBioControlObserver::EMsgClose); |
|
340 break; |
|
341 } |
|
342 default: |
|
343 { |
|
344 break; |
|
345 } |
|
346 } |
|
347 } |
|
348 |
|
349 TBool CICalendarBioControl::IsNextMessageAvailableL( TBool /*aForward*/) |
|
350 { |
|
351 return EFalse; |
|
352 } |
|
353 |
|
354 void CICalendarBioControl::NextMessageL( TBool /*aForward*/ ) |
|
355 { |
|
356 //empty implementation |
|
357 } |
|
358 |
|
359 |
|
360 // End of File |