|
1 /* |
|
2 * Copyright (c) 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: Implementation of the class CFsUiDataMtm. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "emailtrace.h" |
|
21 #include <MtmExtendedCapabilities.hrh> |
|
22 #include <msvuids.h> |
|
23 #include <msvids.h> |
|
24 #include <mtmuids.h> |
|
25 #include <coemain.h> |
|
26 #include <AknIconUtils.h> |
|
27 #include <data_caging_path_literals.hrh> |
|
28 |
|
29 #include <fsuidatamtm.mbg> |
|
30 #include "fsmtmsuids.h" |
|
31 #include <fsuidatamtm.rsg> |
|
32 #include "fsmtmsconstants.h" |
|
33 #include "cfsuidatamtm.h" |
|
34 |
|
35 // FREESTYLE EMAIL FRAMEWORK INCLUDES |
|
36 #include "CFSMailCommon.h" |
|
37 #include "CFSMailClient.h" |
|
38 #include "CFSMailBox.h" |
|
39 |
|
40 |
|
41 #include <gulicon.h> |
|
42 #include "MFSMailBrandManager.h" |
|
43 |
|
44 // GLOBAL EXPORTS. |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // Panic |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 GLDEF_C void Panic(TInt aPanic) |
|
51 { |
|
52 |
|
53 User::Panic(_L("FsUiMtms"), aPanic); |
|
54 |
|
55 } |
|
56 |
|
57 // --------------------------------------------------------------------------- |
|
58 // NewMtmUiDataLayerL |
|
59 // --------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C CBaseMtmUiData* NewMtmUiDataLayerL( |
|
62 CRegisteredMtmDll& aRegisteredDll ) |
|
63 // Factory function |
|
64 { |
|
65 return CFsUiDataMtm::NewL( aRegisteredDll ); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------------------------- |
|
69 // CFsUiDataMtm::CFsUiDataMtm |
|
70 // --------------------------------------------------------------------------- |
|
71 // |
|
72 CFsUiDataMtm::CFsUiDataMtm( CRegisteredMtmDll& aRegisteredMtmDll ): |
|
73 CBaseMtmUiData( aRegisteredMtmDll ) |
|
74 { |
|
75 FUNC_LOG; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CFsUiDataMtm::ConstructL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CFsUiDataMtm::ConstructL() |
|
83 { |
|
84 FUNC_LOG; |
|
85 CBaseMtmUiData::ConstructL(); |
|
86 // No need to allocated as ConstructL will alocate and baseclass itself delets |
|
87 // memory allocated. |
|
88 // iIconArrays = new (ELeave) CArrayPtrSeg<CBitmapArray>(2); |
|
89 } |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CFsUiDataMtm::CFsUiDataMtm |
|
93 // --------------------------------------------------------------------------- |
|
94 // |
|
95 CFsUiDataMtm::~CFsUiDataMtm() |
|
96 { |
|
97 FUNC_LOG; |
|
98 |
|
99 iMailboxIds.Close(); |
|
100 |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CFsUiDataMtm::NewL |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 EXPORT_C CFsUiDataMtm* CFsUiDataMtm::NewL( |
|
108 CRegisteredMtmDll& aRegisteredMtmDll ) |
|
109 { |
|
110 FUNC_LOG; |
|
111 |
|
112 CFsUiDataMtm* self = new(ELeave) CFsUiDataMtm( aRegisteredMtmDll ); |
|
113 CleanupStack::PushL( self ); |
|
114 self->ConstructL(); |
|
115 CleanupStack::Pop(); |
|
116 |
|
117 return self; |
|
118 } |
|
119 |
|
120 // --------------------------------------------------------------------------- |
|
121 // CFsUiDataMtm::PopulateArraysL |
|
122 // Initialises bitmaps and function information. |
|
123 // --------------------------------------------------------------------------- |
|
124 // |
|
125 void CFsUiDataMtm::PopulateArraysL() |
|
126 { |
|
127 FUNC_LOG; |
|
128 |
|
129 // Populate function array |
|
130 ReadFunctionsFromResourceFileL( R_FS_FUNCTION_ARRAY ); |
|
131 |
|
132 // Add the icon information here. |
|
133 TFileName dllFileName; |
|
134 Dll::FileName( dllFileName ); |
|
135 TParse parse; |
|
136 parse.Set( KFsUiDataMtmUdBitmapFile, &KDC_BITMAP_DIR, &dllFileName ); |
|
137 TFileName bitmapFileName= parse.FullName(); |
|
138 |
|
139 // Support for White label branding added |
|
140 CFSMailClient* mailClient = CFSMailClient::NewL(); |
|
141 CleanupClosePushL(*mailClient); |
|
142 MFSMailBrandManager& brandManager = mailClient->GetBrandManagerL(); |
|
143 RPointerArray<CFSMailBox> mailboxes; |
|
144 CleanupResetAndDestroyClosePushL( mailboxes ); |
|
145 TFSMailMsgId id; |
|
146 |
|
147 mailClient->ListMailBoxes( id, mailboxes ); |
|
148 |
|
149 iIconArrays->Reset(); |
|
150 iMailboxIds.Reset(); |
|
151 |
|
152 for ( TInt i = 0; i <= mailboxes.Count(); i++ ) // Last round is for setting the default mb icon at the end of the list |
|
153 { |
|
154 CFbsBitmap* bitmap(0); |
|
155 CFbsBitmap* bitmapMask(0); |
|
156 CArrayPtrFlat<CFbsBitmap>* array = new (ELeave) CArrayPtrFlat<CFbsBitmap>( 2 ); |
|
157 CleanupStack::PushL( array ); // +2 array |
|
158 array->SetReserveL( 2 ); // AppendLs will not LEAVE |
|
159 |
|
160 CGulIcon* brandedIcon( NULL ); |
|
161 TInt err; |
|
162 |
|
163 if ( i < mailboxes.Count() ) // Do not execute for the last round |
|
164 { |
|
165 TRAP( err, brandedIcon = brandManager.GetGraphicL( EFSMailboxIcon, mailboxes[i]->GetId() ) ); |
|
166 } |
|
167 if ( err == KErrNone && brandedIcon ) |
|
168 { |
|
169 bitmap = brandedIcon->Bitmap(); |
|
170 bitmapMask = brandedIcon->Mask(); |
|
171 brandedIcon->SetBitmapsOwnedExternally( ETrue ); |
|
172 CleanupStack::PushL( bitmap ); |
|
173 array->AppendL( bitmap ); |
|
174 CleanupStack::Pop( bitmap ); |
|
175 bitmap = 0; |
|
176 CleanupStack::PushL( bitmapMask ); |
|
177 array->AppendL( bitmapMask ); |
|
178 CleanupStack::Pop( bitmapMask ); |
|
179 bitmapMask = 0; |
|
180 iIconArrays->AppendL( array ); |
|
181 iMailboxIds.Append( (mailboxes[i]->GetId()).Id() ); |
|
182 } |
|
183 else |
|
184 { |
|
185 // Icon was not found from the branding manager or last round for the default icon |
|
186 TRAPD( err, AknIconUtils::CreateIconL( bitmap, bitmapMask, bitmapFileName, |
|
187 EMbmFsuidatamtmQgn_prop_cmail_inbox_small, EMbmFsuidatamtmQgn_prop_cmail_inbox_small + 1 )); |
|
188 if( err != KErrNone ) |
|
189 { |
|
190 } |
|
191 CleanupStack::PushL( bitmap ); |
|
192 array->AppendL( bitmap ); |
|
193 CleanupStack::Pop( bitmap ); |
|
194 bitmap = 0; |
|
195 CleanupStack::PushL( bitmapMask ); |
|
196 array->AppendL( bitmapMask ); |
|
197 CleanupStack::Pop( bitmapMask ); |
|
198 bitmapMask = 0; |
|
199 // INFO: This is not working for some reason, otherwise above code is not required. |
|
200 // CreateBitmapsL(2, KFsUiDataMtmUdBitmapFile, EMbmFsuidatamtmFsmailbox, |
|
201 // EMbmFsuidatamtmLastElement); |
|
202 iIconArrays->AppendL( array ); |
|
203 iMailboxIds.Append(0); |
|
204 } |
|
205 if ( brandedIcon ) |
|
206 { |
|
207 delete brandedIcon; |
|
208 } |
|
209 CleanupStack::Pop( array ); |
|
210 } |
|
211 |
|
212 CleanupStack::PopAndDestroy( &mailboxes ); |
|
213 CleanupStack::PopAndDestroy( mailClient ); |
|
214 |
|
215 } |
|
216 |
|
217 // --------------------------------------------------------------------------- |
|
218 // CFsUiDataMtm::CFsUiDataMtm |
|
219 // --------------------------------------------------------------------------- |
|
220 // |
|
221 void CFsUiDataMtm::HandleSessionEventL( TMsvSessionEvent /*aEvent*/, |
|
222 TAny* /*aArg1*/, TAny* /*aArg2*/, TAny* /*aArg3*/ ) |
|
223 { |
|
224 FUNC_LOG; |
|
225 //For now don't do anything. |
|
226 } |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CFsUiDataMtm::GetResourceFileName |
|
230 // From CBaseMtmUiData: Gets the resource file name associated with MTM Ui |
|
231 // Data |
|
232 // --------------------------------------------------------------------------- |
|
233 // |
|
234 void CFsUiDataMtm::GetResourceFileName(TFileName &aFileName) const |
|
235 { |
|
236 FUNC_LOG; |
|
237 |
|
238 TFileName dllFileName; |
|
239 Dll::FileName( dllFileName ); |
|
240 TParse parse; |
|
241 parse.Set( KFsUiDataMtmUdResourceFile, &KDC_MTM_RESOURCE_DIR, &dllFileName ); |
|
242 aFileName= parse.FullName(); |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // CFsUiDataMtm::ContextIcon |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 const CBaseMtmUiData::CBitmapArray& CFsUiDataMtm::ContextIcon( |
|
250 const TMsvEntry& aContext, TInt /*aStateFlags*/ ) const |
|
251 { |
|
252 FUNC_LOG; |
|
253 for ( TInt i = 0; i < iIconArrays->Count() - 1; i++ ) |
|
254 { |
|
255 if ( iMailboxIds[i] == aContext.iMtmData2 ) |
|
256 { |
|
257 return *(iIconArrays->At( i )); |
|
258 } |
|
259 } |
|
260 return *(iIconArrays->At( iIconArrays->Count() - 1)); // Default icon |
|
261 } |
|
262 |
|
263 // --------------------------------------------------------------------------- |
|
264 // CFsUiDataMtm::MtmSpecificFunctions |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 const CArrayFix<CBaseMtmUiData::TMtmUiFunction>& CFsUiDataMtm::MtmSpecificFunctions() const |
|
268 { |
|
269 FUNC_LOG; |
|
270 return *iMtmSpecificFunctions; |
|
271 } |
|
272 |
|
273 // --------------------------------------------------------------------------- |
|
274 // CFsUiDataMtm::CanCancelL |
|
275 // Tests if the current operation on the entry can be cancelled. |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 TBool CFsUiDataMtm::CanCancelL( |
|
279 const TMsvEntry &/*aContext*/, TInt &aReasonResourceId ) const |
|
280 { |
|
281 FUNC_LOG; |
|
282 |
|
283 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
284 |
|
285 return EFalse; |
|
286 } |
|
287 |
|
288 // --------------------------------------------------------------------------- |
|
289 // CFsUiDataMtm::CanCloseEntryL() |
|
290 // Tests if a close operation is supported. |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 TBool CFsUiDataMtm::CanCloseEntryL( const TMsvEntry &/*aContext*/, |
|
294 TInt &/*aReasonResourceId*/ ) const |
|
295 { |
|
296 FUNC_LOG; |
|
297 return EFalse; |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------------------------- |
|
301 // CFsUiDataMtm::CanCopyMoveFromEntryL |
|
302 // Tests whether a copy from or move from operation is supported. |
|
303 // --------------------------------------------------------------------------- |
|
304 // |
|
305 TBool CFsUiDataMtm::CanCopyMoveFromEntryL( |
|
306 const TMsvEntry& /*aContext*/, TInt& aReasonResourceId ) const |
|
307 { |
|
308 FUNC_LOG; |
|
309 |
|
310 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
311 |
|
312 return EFalse; |
|
313 } |
|
314 |
|
315 // --------------------------------------------------------------------------- |
|
316 // CFsUiDataMtm::CanCopyMoveToEntryL |
|
317 // Tests if a copy from or move to operation is supported. |
|
318 // --------------------------------------------------------------------------- |
|
319 // |
|
320 TBool CFsUiDataMtm::CanCopyMoveToEntryL( |
|
321 const TMsvEntry& /*aContext*/, TInt& aReasonResourceId ) const |
|
322 { |
|
323 FUNC_LOG; |
|
324 |
|
325 //ActiveSync Does not support Copying or Moving a Mail into the Inbox. |
|
326 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
327 |
|
328 return EFalse; |
|
329 } |
|
330 |
|
331 // --------------------------------------------------------------------------- |
|
332 // CFsUiDataMtm::CanCreateEntryL |
|
333 // Tests if an entry can be created as a child. |
|
334 // --------------------------------------------------------------------------- |
|
335 // |
|
336 TBool CFsUiDataMtm::CanCreateEntryL( const TMsvEntry& aParent, |
|
337 TMsvEntry &aNewEntry, TInt &aReasonResourceId ) const |
|
338 { |
|
339 FUNC_LOG; |
|
340 if ((aNewEntry.iMtm == KUidMsgValTypeFsMtmVal) && |
|
341 (aNewEntry.iType == KUidMsvServiceEntry) ) |
|
342 { |
|
343 aReasonResourceId=0; |
|
344 // --- Can create services if they are off root --- |
|
345 return (aParent.Id() == KMsvRootIndexEntryIdValue); |
|
346 } |
|
347 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
348 |
|
349 return EFalse; |
|
350 } |
|
351 |
|
352 // --------------------------------------------------------------------------- |
|
353 // CFsUiDataMtm::CanDeleteFromEntryL |
|
354 // Tests if a delete operation is supported. |
|
355 // --------------------------------------------------------------------------- |
|
356 // |
|
357 TBool CFsUiDataMtm::CanDeleteFromEntryL( const TMsvEntry &/*aContext*/, |
|
358 TInt &aReasonResourceId) const |
|
359 { |
|
360 FUNC_LOG; |
|
361 |
|
362 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
363 |
|
364 return EFalse; |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // CFsUiDataMtm::CanDeleteServiceL |
|
369 // Tests if the service entry can be deleted. |
|
370 // --------------------------------------------------------------------------- |
|
371 // |
|
372 TBool CFsUiDataMtm::CanDeleteServiceL( |
|
373 const TMsvEntry& /*aService*/, TInt& aReasonResourceId) const |
|
374 { |
|
375 FUNC_LOG; |
|
376 |
|
377 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
378 |
|
379 return EFalse; |
|
380 } |
|
381 |
|
382 // --------------------------------------------------------------------------- |
|
383 // CFsUiDataMtm::CanEditEntryL( ) |
|
384 // Tests if the entry can be edited. |
|
385 // --------------------------------------------------------------------------- |
|
386 // |
|
387 TBool CFsUiDataMtm::CanEditEntryL( const TMsvEntry &/*aContext*/, |
|
388 TInt &aReasonResourceId) const |
|
389 { |
|
390 FUNC_LOG; |
|
391 |
|
392 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
393 |
|
394 return EFalse; |
|
395 } |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // CFsUiDataMtm::CanForwardEntryL |
|
399 // |
|
400 // Tests if an entry can be forwarded. |
|
401 // --------------------------------------------------------------------------- |
|
402 // |
|
403 TBool CFsUiDataMtm::CanForwardEntryL( const TMsvEntry &/*aContext*/, |
|
404 TInt &aReasonResourceId) const |
|
405 { |
|
406 FUNC_LOG; |
|
407 |
|
408 aReasonResourceId=R_FS_NOT_SUPPORTED; |
|
409 |
|
410 return EFalse; |
|
411 } |
|
412 |
|
413 // --------------------------------------------------------------------------- |
|
414 // CFsUiDataMtm::CanOpenEntryL |
|
415 // Tests if an entry can be opened. |
|
416 // --------------------------------------------------------------------------- |
|
417 // |
|
418 TBool CFsUiDataMtm::CanOpenEntryL( const TMsvEntry& /*aContext*/, |
|
419 TInt& aReasonResourceId) const |
|
420 { |
|
421 FUNC_LOG; |
|
422 |
|
423 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
424 |
|
425 return EFalse; |
|
426 } |
|
427 |
|
428 // --------------------------------------------------------------------------- |
|
429 // CFsUiDataMtm::CanReplyToEntryL |
|
430 // Tests if an entry can be replied to. |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 TBool CFsUiDataMtm::CanReplyToEntryL( const TMsvEntry& /*aContext*/, |
|
434 TInt& aReasonResourceId) const |
|
435 { |
|
436 FUNC_LOG; |
|
437 |
|
438 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
439 |
|
440 return EFalse; |
|
441 } |
|
442 |
|
443 // --------------------------------------------------------------------------- |
|
444 // CFsUiDataMtm::CanViewEntryL |
|
445 // Tests if an entry can be viewed. |
|
446 // --------------------------------------------------------------------------- |
|
447 // |
|
448 TBool CFsUiDataMtm::CanViewEntryL( const TMsvEntry &/*aContext*/, |
|
449 TInt &aReasonResourceId) const |
|
450 { |
|
451 FUNC_LOG; |
|
452 |
|
453 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
454 |
|
455 return EFalse; |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // CFsUiDataMtm::CanUnDeleteFromEntryL |
|
460 // Tests if the entry can be undeleted. |
|
461 // --------------------------------------------------------------------------- |
|
462 // |
|
463 TBool CFsUiDataMtm::CanUnDeleteFromEntryL( const TMsvEntry&/*aContext*/, |
|
464 TInt &aReasonResourceId) const |
|
465 { |
|
466 FUNC_LOG; |
|
467 |
|
468 aReasonResourceId = R_FS_NOT_SUPPORTED; |
|
469 |
|
470 return EFalse; |
|
471 } |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // CFsUiDataMtm::OperationSupportedL |
|
475 // Tests if an MTM-specific operation is appropriate to the specified entry. |
|
476 // --------------------------------------------------------------------------- |
|
477 // |
|
478 TInt CFsUiDataMtm::OperationSupportedL( |
|
479 TInt aOperationId, const TMsvEntry &/*aContext*/) const |
|
480 { |
|
481 FUNC_LOG; |
|
482 |
|
483 switch(aOperationId) |
|
484 { |
|
485 case KMtmUiFunctionSendAs: |
|
486 return KErrNone; // Operation *IS* supported |
|
487 default: |
|
488 break; |
|
489 } |
|
490 return R_FS_NOT_SUPPORTED; |
|
491 } |
|
492 // --------------------------------------------------------------------------- |
|
493 // CFsUiDataMtm::QueryCapability |
|
494 // Queries if the MTM supports a particular capability, specified by a UID. |
|
495 // --------------------------------------------------------------------------- |
|
496 // |
|
497 TInt CFsUiDataMtm::QueryCapability( TUid aCapability, TInt &aResponse) const |
|
498 { |
|
499 FUNC_LOG; |
|
500 |
|
501 RProcess process;//SCANNER |
|
502 TSecureId sid = process.SecureId(); |
|
503 TInt rc = KErrNone; |
|
504 switch ( aCapability.iUid ) |
|
505 { |
|
506 // These are defined in mtmdef.hrh in epoc32\include |
|
507 case KUidMtmQueryMaxBodySizeValue: |
|
508 aResponse = KMaxTInt; |
|
509 break; |
|
510 |
|
511 case KUidMtmQueryMaxTotalMsgSizeValue: |
|
512 aResponse=KMaxTInt; |
|
513 break; |
|
514 |
|
515 case KUidMtmQuerySupportedBodyValue: |
|
516 aResponse = KMtm7BitBody | KMtm8BitBody | KMtm16BitBody; |
|
517 break; |
|
518 |
|
519 case KUidMsvMtmQuerySupportEditor: |
|
520 aResponse=ETrue; |
|
521 break; |
|
522 |
|
523 // --- Supported non-valued capabilities --- |
|
524 case KUidMtmQuerySupportAttachmentsValue: |
|
525 case KUidMtmQueryCanSendMsgValue: |
|
526 case KUidMtmQueryCanCreateNewMsgValue: //0x10008b24 - 268471076 |
|
527 // INFO - Because of one of these Freestyle is coming under |
|
528 // Writemessga ->Shortmessage, Multimediamesage, .. Freestyle |
|
529 // When Freestyle Install is not yet executed but MTM resouce file |
|
530 // is compiled. |
|
531 // Solution - Compare with sid.iID EAknsMinorQgnMenuMceLst = 0x100058C5 |
|
532 // defined in aknsconstants.hrh. |
|
533 |
|
534 //Disabling SendAs for Calendar is removed. |
|
535 aResponse=ETrue; |
|
536 break; |
|
537 |
|
538 default: |
|
539 rc = KErrNotSupported; |
|
540 } |
|
541 |
|
542 return rc; |
|
543 } |
|
544 // --------------------------------------------------------------------------- |
|
545 // CFsUiDataMtm::StatusTextL |
|
546 // Provides status text for the sending state of the entry. |
|
547 // --------------------------------------------------------------------------- |
|
548 // |
|
549 HBufC* CFsUiDataMtm::StatusTextL( const TMsvEntry& /*aContext*/ ) const |
|
550 { |
|
551 FUNC_LOG; |
|
552 |
|
553 return HBufC::NewL(0); |
|
554 } |
|
555 |
|
556 // End of file |
|
557 |