27
|
1 |
/*
|
|
2 |
* Copyright (c) 2002-2007 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: Bio control for vCalendar messages
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
|
|
20 |
|
|
21 |
// INCLUDE FILES
|
|
22 |
#include "VCalendarBioControl.h" // CVCalendarBioControl
|
|
23 |
#include "VCalBcDataFiller.h" // CVCalBcDataFiller
|
|
24 |
#include "VCalLog.h" // Logging functionality
|
|
25 |
#include "VCalBcPanics.h"
|
|
26 |
|
|
27 |
#include <eikon.hrh>
|
|
28 |
#include <eikmenup.h>
|
|
29 |
#include <msvapi.h>
|
|
30 |
#include <s32file.h> // RFileReadStream
|
|
31 |
#include <StringLoader.h> // StringLoader
|
|
32 |
#include <msgbiocontrolObserver.h> // MMsgBioControlObserver
|
|
33 |
#include <vcalbc.rsg> // resouce identifiers
|
|
34 |
#include <CRichBio.h> // CRichBio
|
|
35 |
#include <CalenImporter.h> // CCalenImporter
|
|
36 |
#include <calentryview.h> // CCalEntryView
|
|
37 |
#include <MsgBioUtils.h>
|
|
38 |
#include <bldvariant.hrh> // __SERIES60_HELP
|
|
39 |
#include <csxhelp/smart.hlp.hrh>
|
|
40 |
#include <featmgr.h>
|
|
41 |
#include <calsession.h>
|
|
42 |
#include <mmsvattachmentmanager.h>
|
|
43 |
#include <sysutil.h>
|
|
44 |
#include <ecom/ecom.h>
|
|
45 |
#include <AknDef.h>
|
|
46 |
#include <AiwServiceHandler.h> // CAiwServiceHandler
|
|
47 |
#include <SmsViewer.rsg>
|
|
48 |
#include <bva.rsg>
|
|
49 |
#include <AiwCommon.hrh>
|
|
50 |
#include <data_caging_path_literals.hrh>
|
|
51 |
|
|
52 |
// LOCAL CONSTANTS AND MACROS
|
|
53 |
|
|
54 |
const TInt KVCalBcLeaveCodeCorrupt = KErrMsgBioMessageNotValid;
|
|
55 |
const TInt KIndexFirst = 0;
|
|
56 |
const TInt KLengthBeginVCalendar = 15; // "BEGIN:VCALENDAR" -string length
|
|
57 |
const TInt KVCalBcHeightReductionBva = 9;
|
|
58 |
//recognition string for ical
|
|
59 |
_LIT8(KVersionICal, "VERSION:2.0");
|
|
60 |
//recognition string for vcal
|
|
61 |
_LIT8(KVersionVCal, "VERSION:1.0");
|
|
62 |
const TInt KReadDataAmount = 256;
|
|
63 |
|
|
64 |
|
|
65 |
_LIT(KVCalBCResourceFile, "vcalbc.rsc");
|
|
66 |
_LIT(KAvkonResourceFile, "avkon.rsc");
|
|
67 |
_LIT(KSmsViewerResourceFile, "smsviewer.rsc");
|
|
68 |
_LIT(KBvaResourceFile, "bva.rsc");
|
|
69 |
|
|
70 |
// MEMBER FUNCTIONS
|
|
71 |
|
|
72 |
CVCalendarBioControl::~CVCalendarBioControl()
|
|
73 |
{
|
|
74 |
FeatureManager::UnInitializeLib();
|
|
75 |
iFileHandle.Close();
|
|
76 |
delete iViewer;
|
|
77 |
iCalEntryArray.ResetAndDestroy();
|
|
78 |
delete iCalEntryView;
|
|
79 |
delete iSession;
|
|
80 |
if( iCalAiwServiceHandler )
|
|
81 |
{
|
|
82 |
delete iCalAiwServiceHandler;
|
|
83 |
iCalAiwServiceHandler = NULL;
|
|
84 |
}
|
|
85 |
}
|
|
86 |
|
|
87 |
EXPORT_C CMsgBioControl* CVCalendarBioControl::NewL(
|
|
88 |
MMsgBioControlObserver& aObserver,
|
|
89 |
CMsvSession* aSession,
|
|
90 |
TMsvId aId,
|
|
91 |
TMsgBioMode aEditorOrViewerMode,
|
|
92 |
const RFile* aFile)
|
|
93 |
{
|
|
94 |
LOG("CVCalendarBioControl::NewL begin");
|
|
95 |
CVCalendarBioControl* self = new(ELeave) CVCalendarBioControl(
|
|
96 |
aObserver,
|
|
97 |
aSession,
|
|
98 |
aId,
|
|
99 |
aEditorOrViewerMode,
|
|
100 |
aFile);
|
|
101 |
CleanupStack::PushL(self);
|
|
102 |
self->ConstructL();
|
|
103 |
CleanupStack::Pop(); //self
|
|
104 |
return self;
|
|
105 |
}
|
|
106 |
|
|
107 |
void CVCalendarBioControl::SetAndGetSizeL(TSize& aSize)
|
|
108 |
{
|
|
109 |
if(iIsFileBased)
|
|
110 |
{
|
|
111 |
SetPosition(TPoint(0,KVCalBcHeightReductionBva));
|
|
112 |
aSize.iHeight -= KVCalBcHeightReductionBva;
|
|
113 |
iViewer->SetAndGetSizeL(aSize);
|
|
114 |
SetSizeWithoutNotification(aSize);
|
|
115 |
}
|
|
116 |
else
|
|
117 |
{
|
|
118 |
iViewer->SetAndGetSizeL(aSize);
|
|
119 |
|
|
120 |
//the following compares the window size against the
|
|
121 |
//"virtual" height of the viewer. This way there is no
|
|
122 |
//scrolling if virtualHeight is less than window size
|
|
123 |
if(iViewer->VirtualHeight() <= Window().Size().iHeight)
|
|
124 |
{
|
|
125 |
aSize.iHeight = iViewer->VirtualHeight();
|
|
126 |
SetSizeWithoutNotification(aSize);
|
|
127 |
}
|
|
128 |
else
|
|
129 |
{
|
|
130 |
SetSizeWithoutNotification(aSize);
|
|
131 |
}
|
|
132 |
}
|
|
133 |
}
|
|
134 |
|
|
135 |
void CVCalendarBioControl::SetMenuCommandSetL(CEikMenuPane& aMenuPane)
|
|
136 |
{
|
|
137 |
if (!IsEditor())
|
|
138 |
{
|
|
139 |
aMenuPane.SetItemDimmed( KAiwCmdSaveToCalendar, EFalse );
|
|
140 |
|
|
141 |
if( !iCalAiwServiceHandler )
|
|
142 |
{
|
|
143 |
iCalAiwServiceHandler = CAiwServiceHandler :: NewL();
|
|
144 |
}
|
|
145 |
|
|
146 |
// Adding to Calendar is only supported for received calendar messages
|
|
147 |
// At this stage, aFile which is given to constructor is corrupted.
|
|
148 |
// Base class method IsFileBased() cannot be used because file handle
|
|
149 |
// in invalid. Guilty: \s60\avkon\src\AknOpenFileService.cpp
|
|
150 |
// void CAknOpenFileServiceSession::OpenHandleWithParamsL(const RMessage2& aMessage).
|
|
151 |
// File handle which is given to vCal BIO control is ***local variable***
|
|
152 |
// in that method. When vCal is successfully viewed, OpenHandleWithParamsL
|
|
153 |
// completes and causes file handle to be invalid. 30.6.2005 / Sauli Painilainen
|
|
154 |
if( iIsFileBased )
|
|
155 |
{
|
|
156 |
// Attaching the interest to the menu.
|
|
157 |
// This internally load the aiwprovider plug-in.
|
|
158 |
iCalAiwServiceHandler->AttachMenuL( R_BVA_MENU, R_BVA_AIW_CALENDAR_INTEREST );
|
|
159 |
|
|
160 |
// This menu should contain AIW menu placeholder,a sanity check.
|
|
161 |
__ASSERT_DEBUG( iCalAiwServiceHandler->IsAiwMenu( R_BVA_MENU ), Panic( EPanic2 ) );
|
|
162 |
|
|
163 |
if (iCalAiwServiceHandler->IsAiwMenu( R_BVA_MENU ) )
|
|
164 |
{
|
|
165 |
iCalAiwServiceHandler->InitializeMenuPaneL( aMenuPane, R_BVA_MENU,
|
|
166 |
KAiwCmdSaveToCalendar,
|
|
167 |
iCalAiwServiceHandler->InParamListL() );
|
|
168 |
}
|
|
169 |
}
|
|
170 |
else
|
|
171 |
{
|
|
172 |
// Attaching the interest to the menu.
|
|
173 |
// This internally load the aiwprovider plug-in.
|
|
174 |
iCalAiwServiceHandler->AttachMenuL( R_SMSV_OPTIONSMENUPANE, R_SMSV_AIW_CALENDAR_INTEREST );
|
|
175 |
|
|
176 |
// This menu should contain AIW menu placeholder,a sanity check.
|
|
177 |
__ASSERT_DEBUG( iCalAiwServiceHandler->IsAiwMenu( R_SMSV_OPTIONSMENUPANE ), Panic( EPanic2 ) );
|
|
178 |
|
|
179 |
if (iCalAiwServiceHandler->IsAiwMenu( R_SMSV_OPTIONSMENUPANE ) )
|
|
180 |
{
|
|
181 |
iCalAiwServiceHandler->InitializeMenuPaneL( aMenuPane, R_SMSV_OPTIONSMENUPANE,
|
|
182 |
KAiwCmdSaveToCalendar,
|
|
183 |
iCalAiwServiceHandler->InParamListL() );
|
|
184 |
}
|
|
185 |
}
|
|
186 |
}
|
|
187 |
}
|
|
188 |
|
|
189 |
TBool CVCalendarBioControl::HandleBioCommandL(TInt aCommand)
|
|
190 |
{
|
|
191 |
if( aCommand == KAiwCmdSaveToCalendar )
|
|
192 |
{
|
|
193 |
// Sending the filehandle to provider as input parameter.
|
|
194 |
CAiwGenericParamList& inCalParamList = iCalAiwServiceHandler->InParamListL();
|
|
195 |
|
|
196 |
RFile fileHandle;
|
|
197 |
ResolveFileL( fileHandle );
|
|
198 |
TAiwGenericParam calenParam( EGenericParamFile );
|
|
199 |
calenParam.Value().Set( fileHandle );
|
|
200 |
inCalParamList.AppendL( calenParam );
|
|
201 |
iCalAiwServiceHandler->ExecuteMenuCmdL( aCommand,
|
|
202 |
inCalParamList,
|
|
203 |
iCalAiwServiceHandler->OutParamListL(),
|
|
204 |
0, NULL);
|
|
205 |
return ETrue;
|
|
206 |
}
|
|
207 |
return EFalse;
|
|
208 |
}
|
|
209 |
|
|
210 |
TRect CVCalendarBioControl::CurrentLineRect() const
|
|
211 |
{
|
|
212 |
return iViewer->CurrentLineRect();
|
|
213 |
}
|
|
214 |
|
|
215 |
TBool CVCalendarBioControl::IsFocusChangePossible(
|
|
216 |
TMsgFocusDirection aDirection) const
|
|
217 |
{
|
|
218 |
if (aDirection == EMsgFocusUp)
|
|
219 |
{
|
|
220 |
return iViewer->IsCursorLocation(EMsgTop);
|
|
221 |
}
|
|
222 |
return EFalse;
|
|
223 |
}
|
|
224 |
|
|
225 |
HBufC* CVCalendarBioControl::HeaderTextL() const
|
|
226 |
{
|
|
227 |
return StringLoader::LoadL(R_QTN_SM_TITLE_INVITATION, iCoeEnv);
|
|
228 |
}
|
|
229 |
|
|
230 |
TInt CVCalendarBioControl::VirtualHeight()
|
|
231 |
{
|
|
232 |
return iViewer->VirtualHeight();
|
|
233 |
}
|
|
234 |
|
|
235 |
TInt CVCalendarBioControl::VirtualVisibleTop()
|
|
236 |
{
|
|
237 |
return iViewer->VirtualVisibleTop();
|
|
238 |
}
|
|
239 |
|
|
240 |
TBool CVCalendarBioControl::IsCursorLocation(TMsgCursorLocation aLocation) const
|
|
241 |
{
|
|
242 |
return iViewer->IsCursorLocation(aLocation);
|
|
243 |
}
|
|
244 |
void CVCalendarBioControl::GetHelpContext(
|
|
245 |
TCoeHelpContext& aHelpContext) const
|
|
246 |
{
|
|
247 |
if ( FeatureManager::FeatureSupported( KFeatureIdHelp ) )
|
|
248 |
{
|
|
249 |
const TUid KUidSmart = {0x101F4CDA};
|
|
250 |
if ( ! iIsFileBased )
|
|
251 |
{
|
|
252 |
aHelpContext.iContext=IsEditor()?
|
|
253 |
KSMART_HLP_CALENDAREDITOR():KSMART_HLP_CALENDARVIEWER() ;
|
|
254 |
aHelpContext.iMajor=KUidSmart;
|
|
255 |
}
|
|
256 |
else
|
|
257 |
{
|
|
258 |
if ( !IsEditor() )
|
|
259 |
{
|
|
260 |
aHelpContext.iContext=KSMART_HLP_CALPULLMESVIEWER;
|
|
261 |
aHelpContext.iMajor=KUidSmart;
|
|
262 |
}
|
|
263 |
}
|
|
264 |
}
|
|
265 |
}
|
|
266 |
|
|
267 |
|
|
268 |
|
|
269 |
|
|
270 |
TInt CVCalendarBioControl::CountComponentControls() const
|
|
271 |
{
|
|
272 |
return 1; // the viewer component
|
|
273 |
}
|
|
274 |
|
|
275 |
CCoeControl* CVCalendarBioControl::ComponentControl(TInt aIndex) const
|
|
276 |
{
|
|
277 |
if (aIndex == 0)
|
|
278 |
{
|
|
279 |
return iViewer;
|
|
280 |
}
|
|
281 |
return NULL;
|
|
282 |
}
|
|
283 |
|
|
284 |
void CVCalendarBioControl::SizeChanged()
|
|
285 |
{
|
|
286 |
iViewer->SetExtent(Position(), iViewer->Size());
|
|
287 |
}
|
|
288 |
|
|
289 |
void CVCalendarBioControl::FocusChanged(TDrawNow /*aDrawNow*/)
|
|
290 |
{
|
|
291 |
iViewer->SetFocus(IsFocused());
|
|
292 |
}
|
|
293 |
|
|
294 |
void CVCalendarBioControl::SetContainerWindowL(const CCoeControl& aContainer)
|
|
295 |
{
|
|
296 |
|
|
297 |
CCoeControl::SetContainerWindowL(aContainer);
|
|
298 |
|
|
299 |
// The reason for creating the viewer control here is that the
|
|
300 |
// construction of the viewer requires a parent with a window. So it
|
|
301 |
// cannot be done in ConstructL().
|
|
302 |
//
|
|
303 |
iViewer->ConstructL(this);
|
|
304 |
}
|
|
305 |
|
|
306 |
TKeyResponse CVCalendarBioControl::OfferKeyEventL(
|
|
307 |
const TKeyEvent& aKeyEvent,
|
|
308 |
TEventCode aType)
|
|
309 |
{
|
|
310 |
return iViewer->OfferKeyEventL(aKeyEvent, aType);
|
|
311 |
}
|
|
312 |
|
|
313 |
void CVCalendarBioControl::HandleResourceChange( TInt aType )
|
|
314 |
{
|
|
315 |
LOG("CVCalendarBioControl::HandleResourceChange begin");
|
|
316 |
CMsgBioControl::HandleResourceChange( aType );
|
|
317 |
|
|
318 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
319 |
{
|
|
320 |
iViewer->Reset();
|
|
321 |
}
|
|
322 |
LOG("CVCalendarBioControl::HandleResourceChange end");
|
|
323 |
}
|
|
324 |
|
|
325 |
#if defined (__I_CAL_SUPPORT) && defined (RD_MESSAGING_ICAL_IMPORT)
|
|
326 |
void CVCalendarBioControl::ImportVCalendarL()
|
|
327 |
{
|
|
328 |
LOG("CVCalendarBioControl::ImportVCalendarL begin");
|
|
329 |
|
|
330 |
CCalenImporter* calImporter = CCalenImporter::NewL( *iSession );
|
|
331 |
CleanupStack::PushL( calImporter );
|
|
332 |
calImporter->SetImportMode( ECalenImportModeExtended );
|
|
333 |
|
|
334 |
RFile fileHandle;
|
|
335 |
ResolveFileL( fileHandle );
|
|
336 |
RFileReadStream stream( fileHandle,0 );
|
|
337 |
CleanupClosePushL( stream );
|
|
338 |
|
|
339 |
TBuf8<KReadDataAmount> vcalData;
|
|
340 |
|
|
341 |
TInt errRead( KErrNone );
|
|
342 |
TRAP( errRead,stream.ReadL( vcalData,KReadDataAmount ) );
|
|
343 |
|
|
344 |
if( errRead != KErrEof && errRead != KErrNone )
|
|
345 |
{
|
|
346 |
User::Leave( KVCalBcLeaveCodeCorrupt );
|
|
347 |
}
|
|
348 |
|
|
349 |
//return the read stream back to the beginning for import
|
|
350 |
stream.Source()->SeekL( MStreamBuf::ERead, EStreamBeginning, 0 );
|
|
351 |
|
|
352 |
TInt errImport( KErrNone );
|
|
353 |
//Reset the array if its already imported.
|
|
354 |
if(iCalEntryArray.Count())
|
|
355 |
iCalEntryArray.ResetAndDestroy();
|
|
356 |
|
|
357 |
if ( vcalData.FindF( KVersionVCal ) == KErrNotFound )
|
|
358 |
{
|
|
359 |
//using the ICAl import API
|
|
360 |
TRAP( errImport, calImporter->ImportICalendarL( stream, iCalEntryArray ) );
|
|
361 |
}
|
|
362 |
else if ( vcalData.FindF( KVersionICal ) == KErrNotFound )
|
|
363 |
{
|
|
364 |
//using the VCAL import API
|
|
365 |
TRAP( errImport, calImporter->ImportVCalendarL( stream, iCalEntryArray ) );
|
|
366 |
}
|
|
367 |
CleanupStack::PopAndDestroy( 2, calImporter ); //stream, calImporter
|
|
368 |
if( errImport != KErrNone || iCalEntryArray.Count() == 0 )
|
|
369 |
{
|
|
370 |
LOG1("CVCalendarBioControl::ImportVCalendarL ERROR %d", err);
|
|
371 |
LOG1("CVCalendarBioControl::ImportVCalendarL ERROR imported cal entry count %d", iCalEntryArray.Count() );
|
|
372 |
// the data was corrupt
|
|
373 |
User::Leave( KVCalBcLeaveCodeCorrupt );
|
|
374 |
}
|
|
375 |
|
|
376 |
//BIO viewer always sets the local UID to 0 in imported entry
|
|
377 |
iCalEntryArray[0]->SetLocalUidL( TCalLocalUid(0) );
|
|
378 |
|
|
379 |
LOG("CVCalendarBioControl::ImportVCalendarL end");
|
|
380 |
}
|
|
381 |
#else
|
|
382 |
void CVCalendarBioControl::ImportVCalendarL()
|
|
383 |
{
|
|
384 |
LOG("CVCalendarBioControl::ImportVCalendarL begin");
|
|
385 |
|
|
386 |
CCalenImporter* calImporter = CCalenImporter::NewL( *iSession );
|
|
387 |
CleanupStack::PushL( calImporter );
|
|
388 |
calImporter->SetImportMode( ECalenImportModeExtended );
|
|
389 |
|
|
390 |
RFile fileHandle;
|
|
391 |
ResolveFileL( fileHandle );
|
|
392 |
RFileReadStream stream( fileHandle,0 );
|
|
393 |
CleanupClosePushL( stream );
|
|
394 |
|
|
395 |
iCalEntryArray.ResetAndDestroy();
|
|
396 |
TRAPD( err, calImporter->ImportVCalendarL( stream, iCalEntryArray ) );
|
|
397 |
CleanupStack::PopAndDestroy( 2,calImporter );//stream, calImporter
|
|
398 |
if( err != KErrNone || iCalEntryArray.Count() == 0 )
|
|
399 |
{
|
|
400 |
LOG1("CVCalendarBioControl::ImportVCalendarL ERROR %d", err);
|
|
401 |
LOG1("CVCalendarBioControl::ImportVCalendarL ERROR imported cal entry count %d", iCalEntryArray.Count() );
|
|
402 |
// the data was corrupt
|
|
403 |
User::Leave( KVCalBcLeaveCodeCorrupt );
|
|
404 |
}
|
|
405 |
|
|
406 |
//BIO viewer always sets the local UID to 0 in imported entry
|
|
407 |
iCalEntryArray[0]->SetLocalUidL( TCalLocalUid(0) );
|
|
408 |
|
|
409 |
LOG("CVCalendarBioControl::ImportVCalendarL end");
|
|
410 |
}
|
|
411 |
#endif
|
|
412 |
|
|
413 |
void CVCalendarBioControl::ResolveFileL( RFile& aFile )
|
|
414 |
{
|
|
415 |
if ( iIsFileBased )
|
|
416 |
{
|
|
417 |
//if filebased vcalendar message (opened via BVA)
|
|
418 |
//we make a copy to a new handle from class variable iFileHandle
|
|
419 |
aFile.Duplicate( iFileHandle );
|
|
420 |
}
|
|
421 |
else
|
|
422 |
{
|
|
423 |
//if vcal is opened from message then we fetch new handle from attachment
|
|
424 |
CMsvEntry* entry = MsvSession().GetEntryL( iId );
|
|
425 |
CleanupStack::PushL( entry );
|
|
426 |
CMsvStore* store = entry->ReadStoreL();
|
|
427 |
CleanupStack::PushL(store);
|
|
428 |
MMsvAttachmentManager& attachMan = store->AttachmentManagerL();
|
|
429 |
aFile = attachMan.GetAttachmentFileL( 0 ); //entry is the first attachment
|
|
430 |
CleanupStack::PopAndDestroy( 2 ); // store, entry
|
|
431 |
}
|
|
432 |
}
|
|
433 |
|
|
434 |
void CVCalendarBioControl::FileBasedAddMenuItemL(CEikMenuPane& aMenuPane,
|
|
435 |
TInt aStringRes, TInt aCommandOffset)
|
|
436 |
{
|
|
437 |
CEikMenuPaneItem::SData menuItem;
|
|
438 |
menuItem.iCascadeId = NULL;
|
|
439 |
menuItem.iFlags = NULL;
|
|
440 |
menuItem.iText.Format(*StringLoader::LoadLC(aStringRes, iCoeEnv));
|
|
441 |
CleanupStack::PopAndDestroy(); // (string)
|
|
442 |
menuItem.iCommandId = iBioControlObserver.FirstFreeCommand()
|
|
443 |
+ aCommandOffset;
|
|
444 |
aMenuPane.InsertMenuItemL(menuItem, 0);
|
|
445 |
}
|
|
446 |
|
|
447 |
void CVCalendarBioControl::OpenStreamLC(RFileReadStream& aStream,
|
|
448 |
TFileName& aFileName)
|
|
449 |
{
|
|
450 |
User::LeaveIfError( aStream.Open(
|
|
451 |
CCoeEnv::Static()->FsSession(),
|
|
452 |
aFileName,
|
|
453 |
EFileStream ));
|
|
454 |
aStream.PushL();
|
|
455 |
}
|
|
456 |
|
|
457 |
CVCalendarBioControl::CVCalendarBioControl(
|
|
458 |
MMsgBioControlObserver& aObserver,
|
|
459 |
CMsvSession* aSession,
|
|
460 |
TMsvId aId,
|
|
461 |
TMsgBioMode aEditorOrViewerMode,
|
|
462 |
const RFile* aFile):
|
|
463 |
CMsgBioControl(aObserver,
|
|
464 |
aSession,
|
|
465 |
aId,
|
|
466 |
aEditorOrViewerMode,
|
|
467 |
aFile),
|
|
468 |
iCalEntryInitErrno( KErrNone )
|
|
469 |
{
|
|
470 |
}
|
|
471 |
|
|
472 |
void CVCalendarBioControl::ConstructL()
|
|
473 |
{
|
|
474 |
LOG("CVCalendarBioControl::ConstructL begin");
|
|
475 |
|
|
476 |
SetExtension( this );
|
|
477 |
|
|
478 |
iIsFileBased = IsFileBased();
|
|
479 |
|
|
480 |
LoadResourceL(KVCalBCResourceFile);
|
|
481 |
LoadResourceL(KAvkonResourceFile);
|
|
482 |
|
|
483 |
LoadResourceL(KBvaResourceFile, KDC_APP_RESOURCE_DIR);
|
|
484 |
LoadResourceL(KSmsViewerResourceFile, KDC_APP_RESOURCE_DIR);
|
|
485 |
LoadStandardBioResourceL();
|
|
486 |
iSession = CCalSession::NewL();
|
|
487 |
// Which calendar file should be used.
|
|
488 |
TRAPD( err, iSession->OpenL( iSession->DefaultFileNameL() ) );
|
|
489 |
if ( err == KErrNotFound )
|
|
490 |
{
|
|
491 |
// If calendar file was not found, should we create it or not?
|
|
492 |
// I think is not BIO control's responsibility to create it.
|
|
493 |
//
|
|
494 |
iSession->CreateCalFileL( iSession->DefaultFileNameL() );
|
|
495 |
iSession->OpenL( iSession->DefaultFileNameL() );
|
|
496 |
}
|
|
497 |
else
|
|
498 |
{
|
|
499 |
User::LeaveIfError( err );
|
|
500 |
}
|
|
501 |
|
|
502 |
//make a copy of the filehandle if the vcal is opened from a file
|
|
503 |
//this is because it cannot be acquired later since it goes out of scope
|
|
504 |
if ( iIsFileBased )
|
|
505 |
{
|
|
506 |
iFileHandle.Duplicate(FileHandle());
|
|
507 |
}
|
|
508 |
|
|
509 |
RFile fileHandle;
|
|
510 |
ResolveFileL(fileHandle);
|
|
511 |
RFileReadStream stream( fileHandle,0 );
|
|
512 |
CleanupClosePushL( stream );
|
|
513 |
|
|
514 |
MStreamBuf* buf = stream.Source();
|
|
515 |
buf->PushL();
|
|
516 |
User::LeaveIfNull(buf);
|
|
517 |
TInt bufferSize = buf->SizeL();
|
|
518 |
if (bufferSize == 0 || (bufferSize < KLengthBeginVCalendar))
|
|
519 |
{
|
|
520 |
User::Leave(KErrMsgBioMessageNotValid);
|
|
521 |
}
|
|
522 |
FeatureManager::InitializeLibL();
|
|
523 |
|
|
524 |
ImportVCalendarL();
|
|
525 |
iViewer = new (ELeave) CRichBio(ERichBioModeEditorBase);
|
|
526 |
CVCalBcDataFiller::FillViewerWithDataL(
|
|
527 |
*iViewer, *iCalEntryArray[KIndexFirst], *iCoeEnv);
|
|
528 |
|
|
529 |
CleanupStack::PopAndDestroy(2);
|
|
530 |
|
|
531 |
LOG("CVCalendarBioControl::ConstructL end");
|
|
532 |
}
|
|
533 |
|
|
534 |
void CVCalendarBioControl::Progress(TInt /* aPercentageCompleted */)
|
|
535 |
{
|
|
536 |
// Empty
|
|
537 |
}
|
|
538 |
|
|
539 |
void CVCalendarBioControl::Completed(TInt aError)
|
|
540 |
{
|
|
541 |
iCalEntryInitErrno = aError;
|
|
542 |
CActiveScheduler::Stop();
|
|
543 |
}
|
|
544 |
|
|
545 |
TBool CVCalendarBioControl::NotifyProgress()
|
|
546 |
{
|
|
547 |
// Return ETrue if you want progress information.
|
|
548 |
return EFalse;
|
|
549 |
}
|
|
550 |
|
|
551 |
TAny* CVCalendarBioControl::BioControlExtension(TInt aExtensionId)
|
|
552 |
{
|
|
553 |
if ( aExtensionId == KMsgBioControlScrollExtension )
|
|
554 |
{
|
|
555 |
return static_cast<MMsgBioControlScrollExtension*> (this);
|
|
556 |
}
|
|
557 |
else
|
|
558 |
{
|
|
559 |
return NULL;
|
|
560 |
}
|
|
561 |
}
|
|
562 |
|
|
563 |
TInt CVCalendarBioControl::ExtScrollL( TInt aPixelsToScroll,
|
|
564 |
TMsgScrollDirection aDirection )
|
|
565 |
{
|
|
566 |
return iViewer->ScrollL(aPixelsToScroll, aDirection);
|
|
567 |
}
|
|
568 |
|
|
569 |
void CVCalendarBioControl::ExtNotifyViewEvent( TMsgViewEvent aEvent, TInt aParam )
|
|
570 |
{
|
|
571 |
iViewer->NotifyViewEvent( aEvent, aParam );
|
|
572 |
}
|
|
573 |
|
|
574 |
GLDEF_C void Panic(TVCalBcPanic aPanic)
|
|
575 |
{
|
|
576 |
_LIT(KPanicText, "VCalBC.dll");
|
|
577 |
User::Panic(KPanicText, aPanic);
|
|
578 |
}
|
|
579 |
// End of File
|