mobilemessaging/unieditor/mtm/src/UniMtmUiData.cpp
changeset 79 2981cb3aa489
parent 0 72b543305e3a
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2005-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:  
       
    15 *       Provides UNI MTM UI data methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "UniMtmUiData.h"
       
    23 
       
    24 #include <mtclbase.h>
       
    25 #include <eikon.rsg>
       
    26 #include <data_caging_path_literals.hrh> 
       
    27 
       
    28 #include <coemain.h>
       
    29 #include <AknsUtils.h>
       
    30 #include <AknsConstants.h>
       
    31 
       
    32 #include <mtmuids.h>
       
    33 #include <msvids.h>
       
    34 #include <msvuids.h>
       
    35 #include <mtmuidef.hrh>
       
    36 
       
    37 #include <MmsUi.rsg>
       
    38 #include <muiu.mbg>                         // for MMS icon bitmaps
       
    39 #include <avkon.rsg>
       
    40 
       
    41 #include <StringLoader.h>           // StringLoader
       
    42 
       
    43 #include <UniMtms.rsg>
       
    44 
       
    45 #include "UniMtmPanic.h"
       
    46 #include "UniMtmConst.h"
       
    47 #include "UniMtmUi.h"
       
    48 
       
    49 #include "UniMsvEntry.h"
       
    50 #include "UniEditorUids.hrh"
       
    51 
       
    52 // CONSTANTS
       
    53 const TInt KMceMmsPriority = 1;
       
    54 
       
    55 const TInt KUniSmsIconIndex = 0;
       
    56 const TInt KUniMmsIconIndex = 1;
       
    57 const TInt KUniPriorityHighIconIndex = 2;
       
    58 const TInt KUniPriorityLowIconIndex = 3;
       
    59 
       
    60 // MACROS
       
    61 // LOCAL CONSTANTS AND MACROS
       
    62 // MODULE DATA STRUCTURES
       
    63 // LOCAL FUNCTION PROTOTYPES
       
    64 
       
    65 // ==================== LOCAL FUNCTIONS ====================
       
    66 
       
    67 // ---------------------------------------------------------
       
    68 // NewUniMtmUiDataL
       
    69 // Factory function
       
    70 // ---------------------------------------------------------
       
    71 //
       
    72 EXPORT_C CBaseMtmUiData* NewUniMtmUiDataL( CRegisteredMtmDll& aRegisteredDll )
       
    73     {
       
    74     return CUniMtmUiData::NewL( aRegisteredDll );
       
    75     }
       
    76 
       
    77 
       
    78 // ================= MEMBER FUNCTIONS =======================
       
    79 
       
    80 // ---------------------------------------------------------
       
    81 // CUniMtmUiData::CUniMtmUiData
       
    82 // C++ constructor
       
    83 // ---------------------------------------------------------
       
    84 //
       
    85 CUniMtmUiData::CUniMtmUiData( CRegisteredMtmDll& aRegisteredDll )
       
    86     :   CBaseMtmUiData( aRegisteredDll )
       
    87     {
       
    88     }
       
    89 
       
    90 // ---------------------------------------------------------
       
    91 // CUniMtmUiData::ConstructL
       
    92 // Symbian OS default constructor can leave.
       
    93 // ---------------------------------------------------------
       
    94 //
       
    95 void CUniMtmUiData::ConstructL()
       
    96     {
       
    97     CBaseMtmUiData::ConstructL();
       
    98     }
       
    99 
       
   100 
       
   101 // ---------------------------------------------------------
       
   102 // CUniMtmUiData::NewL
       
   103 // Two-phased constructor.
       
   104 // ---------------------------------------------------------
       
   105 //
       
   106 CUniMtmUiData* CUniMtmUiData::NewL( CRegisteredMtmDll& aRegisteredDll )
       
   107     {
       
   108     CUniMtmUiData* self = new ( ELeave ) CUniMtmUiData( aRegisteredDll );
       
   109     
       
   110     CleanupStack::PushL( self );
       
   111     self->ConstructL();
       
   112     CleanupStack::Pop( self ); //self
       
   113     return self;
       
   114     }
       
   115 
       
   116     
       
   117 // ---------------------------------------------------------
       
   118 // CUniMtmUiData::~CUniMtmUiData
       
   119 // Destructor.
       
   120 // ---------------------------------------------------------
       
   121 //
       
   122 CUniMtmUiData::~CUniMtmUiData()
       
   123     {
       
   124     }
       
   125 
       
   126 
       
   127 // ---------------------------------------------------------
       
   128 // CUniMtmUiData::OperationSupportedL
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 TInt CUniMtmUiData::OperationSupportedL(
       
   132     TInt aFunctionId,
       
   133     const TMsvEntry& aContext ) const
       
   134     {
       
   135     // Only Message Info for messages is a supported operation
       
   136     if ( ( aFunctionId == KMtmUiFunctionMessageInfo ) &&
       
   137         ( aContext.iType == KUidMsvMessageEntry ) )
       
   138         {
       
   139         return KErrNone;
       
   140         }
       
   141     return R_EIK_TBUF_NOT_AVAILABLE;
       
   142     }
       
   143 
       
   144 
       
   145 // ---------------------------------------------------------
       
   146 // CUniMtmUiData::QueryCapability
       
   147 // The default UI capability checker (UI MTM may have also minimal
       
   148 // UI specific checks also)
       
   149 // ---------------------------------------------------------
       
   150 //
       
   151 TInt CUniMtmUiData::QueryCapability(
       
   152     TUid aFunctionId,
       
   153     TInt& aResponse ) const
       
   154     {
       
   155     TInt error = KErrNone;
       
   156 
       
   157     switch ( aFunctionId.iUid )
       
   158         {
       
   159         // Supported:
       
   160         case KUidMtmQueryMaxTotalMsgSizeValue:
       
   161             aResponse = KMaxTInt;
       
   162             break;
       
   163         case KUidMsvMtmQueryEditorUidValue:
       
   164             {
       
   165             aResponse = KUidUniEditorApplication;
       
   166             break;
       
   167             }
       
   168         case KUidMsvMtmQuerySupportLinks: // flow through
       
   169         case KUidMsvMtmQuerySupportEditor:
       
   170             aResponse = ETrue;
       
   171             break;
       
   172         case KUidMtmQuerySupportAttachmentsValue:
       
   173         case KUidMtmQueryCanSendMsgValue:
       
   174         case KUidMtmQueryCanReceiveMsgValue:
       
   175         case KUidMtmQueryCanCreateNewMsgValue:
       
   176         case KUidMsvMtmQueryMessageInfo:
       
   177             break;
       
   178 
       
   179         default:
       
   180             // All others - Not Supported. At least these:
       
   181             //KUidMsvMtmQueryViewerUidValue
       
   182             //KUidMtmQuerySupportedBodyValue: text part(s) are attachments!
       
   183             //KUidMtmQueryMaxBodySizeValue: texts part(s) are attachments!
       
   184             //KUidMtmQuerySupportSubjectValue: subject is supported in Viewer, but not in Editor
       
   185             //KUidMsvMtmUiQueryCanPrintPreviewMsgValue: no printing in Series 60
       
   186             //KUidMsvMtmUiQueryCanPrintMsgValue: no printing in Series 60
       
   187             //KUidMtmQueryMaxRecipientCountValue
       
   188             //KUidMtmQuerySupportsBioMsgValue
       
   189             //KUidMtmQuerySendAsRequiresRenderedImageValue
       
   190             //KUidMtmQuerySendAsRenderingUidValue
       
   191             //KUidMsvMtmUiQueryExtendedOpenProgress
       
   192             //KUidMsvMtmUiQueryExtendedGetMailProgress
       
   193             //KUidMsvMtmUiQueryConnectionOrientedServices
       
   194             //KUidMsvMtmUiQueryServiceAttributes
       
   195             //KUidMsvMtmUiQueryCanGetNew
       
   196             //KUidMsvMtmUiQueryCanOpenServiceOnAction
       
   197             //KUidMtmQueryOffLineAllowedValue
       
   198             //KUidMtmQuerySupportsSchedulingValue
       
   199             //KUidMtmQuerySupportsFolderValue
       
   200 
       
   201             error = KErrNotSupported;
       
   202         }
       
   203     return error;   
       
   204     }
       
   205 
       
   206 
       
   207 
       
   208 // ---------------------------------------------------------
       
   209 // CUniMtmUiData::ContextIcon
       
   210 // Returns the array of icons relevant to given entry
       
   211 // ---------------------------------------------------------
       
   212 //
       
   213 const CUniMtmUiData::CBitmapArray& CUniMtmUiData::ContextIcon(
       
   214     const TMsvEntry& aContext,
       
   215     TInt aStateFlags ) const
       
   216     {
       
   217     //    Return the set of icons (i.e. different sizes) appropriate to the current context
       
   218     __ASSERT_DEBUG( aContext.iMtm == Type(), Panic( EUniWrongMtm ) );
       
   219     __ASSERT_DEBUG( aContext.iType.iUid != KUidMsvFolderEntryValue, Panic( EUniFoldersNotSupported ) );
       
   220     __ASSERT_DEBUG( aContext.iType.iUid != KUidMsvAttachmentEntryValue, Panic( EUniNoIconForAttachment ) );
       
   221 
       
   222 	TInt bmpIndex = 0;
       
   223 
       
   224 	if( aStateFlags == KMceMmsPriority )
       
   225 		{
       
   226         if ( aContext.Priority() == EMsvHighPriority )
       
   227             {
       
   228             bmpIndex = KUniPriorityHighIconIndex;
       
   229             }
       
   230         else if ( aContext.Priority() == EMsvLowPriority )
       
   231             {
       
   232             bmpIndex = KUniPriorityLowIconIndex;
       
   233             }
       
   234 		}
       
   235 	else
       
   236 		{
       
   237 	    TUniMessageCurrentType currType = TUniMsvEntry::CurrentMessageType( aContext );	
       
   238 	    bmpIndex = ( currType == EUniMessageCurrentTypeSms )?KUniSmsIconIndex : KUniMmsIconIndex;
       
   239 		}
       
   240     
       
   241     return *iIconArrays->At( bmpIndex );
       
   242     
       
   243     }
       
   244 
       
   245 // ---------------------------------------------------------
       
   246 // CUniMtmUiData::CanCreateEntryL
       
   247 // ---------------------------------------------------------
       
   248 //
       
   249 TBool CUniMtmUiData::CanCreateEntryL(
       
   250     const TMsvEntry& /*aParent*/,
       
   251     TMsvEntry& /*aNewEntry*/,
       
   252     TInt& aReasonResourceId ) const
       
   253     {
       
   254     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   255     return EFalse;
       
   256     }
       
   257 
       
   258 // ---------------------------------------------------------
       
   259 // CUniMtmUiData::CanOpenEntryL
       
   260 // ---------------------------------------------------------
       
   261 //
       
   262 TBool CUniMtmUiData::CanOpenEntryL(
       
   263     const TMsvEntry& /*aContext*/,
       
   264     TInt& aReasonResourceId ) const
       
   265     {
       
   266     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   267     return EFalse;
       
   268     }
       
   269 
       
   270 // ---------------------------------------------------------
       
   271 // CUniMtmUiData::CanCloseEntryL
       
   272 // ---------------------------------------------------------
       
   273 //
       
   274 TBool CUniMtmUiData::CanCloseEntryL(
       
   275     const TMsvEntry& /*aContext*/,
       
   276     TInt& aReasonResourceId ) const
       
   277     {
       
   278     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   279     return EFalse;
       
   280     }
       
   281 
       
   282 // ---------------------------------------------------------
       
   283 // CUniMtmUiData::CanViewEntryL
       
   284 // ---------------------------------------------------------
       
   285 //
       
   286 TBool CUniMtmUiData::CanViewEntryL(
       
   287     const TMsvEntry& /*aContext*/,
       
   288     TInt& aReasonResourceId ) const
       
   289     {
       
   290     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   291     return EFalse;
       
   292     }
       
   293 
       
   294 // ---------------------------------------------------------
       
   295 // CUniMtmUiData::CanEditEntryL
       
   296 // ---------------------------------------------------------
       
   297 //
       
   298 TBool CUniMtmUiData::CanEditEntryL(
       
   299     const TMsvEntry& /*aContext*/,
       
   300     TInt& aReasonResourceId ) const
       
   301     {
       
   302     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   303     return EFalse;
       
   304     }
       
   305 
       
   306 // ---------------------------------------------------------
       
   307 // CUniMtmUiData::CanDeleteFromEntryL
       
   308 // ---------------------------------------------------------
       
   309 //
       
   310 TBool CUniMtmUiData::CanDeleteFromEntryL(
       
   311     const TMsvEntry& /*aContext*/,
       
   312     TInt& aReasonResourceId ) const
       
   313     {
       
   314     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   315     return EFalse;
       
   316     }
       
   317 
       
   318 // ---------------------------------------------------------
       
   319 // CUniMtmUiData::CanDeleteServiceL
       
   320 // ---------------------------------------------------------
       
   321 //
       
   322 TBool CUniMtmUiData::CanDeleteServiceL(
       
   323     const TMsvEntry& /*aService*/,
       
   324     TInt& aReasonResourceId ) const
       
   325     {
       
   326     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   327     return EFalse;
       
   328     }
       
   329 
       
   330 // ---------------------------------------------------------
       
   331 // CUniMtmUiData::CanCopyMoveToEntryL
       
   332 // ---------------------------------------------------------
       
   333 //
       
   334 TBool CUniMtmUiData::CanCopyMoveToEntryL(
       
   335     const TMsvEntry& /*aContext*/,
       
   336     TInt& aReasonResourceId ) const
       
   337     {
       
   338     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   339     return EFalse;
       
   340     }
       
   341 
       
   342 // ---------------------------------------------------------
       
   343 // CUniMtmUiData::CanCopyMoveFromEntryL
       
   344 // ---------------------------------------------------------
       
   345 //
       
   346 TBool CUniMtmUiData::CanCopyMoveFromEntryL(
       
   347     const TMsvEntry& /*aContext*/,
       
   348     TInt& aReasonResourceId ) const
       
   349     {
       
   350     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   351     return EFalse;
       
   352     }
       
   353 
       
   354 // ---------------------------------------------------------
       
   355 // CUniMtmUiData::CanReplyToEntryL
       
   356 // ---------------------------------------------------------
       
   357 //
       
   358 TBool CUniMtmUiData::CanReplyToEntryL(
       
   359     const TMsvEntry& /*aContext*/,
       
   360     TInt& aReasonResourceId ) const
       
   361     {
       
   362     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   363     return EFalse;
       
   364     }
       
   365 
       
   366 // ---------------------------------------------------------
       
   367 // CUniMtmUiData::CanForwardEntryL
       
   368 // ---------------------------------------------------------
       
   369 //
       
   370 TBool CUniMtmUiData::CanForwardEntryL(
       
   371     const TMsvEntry& /*aContext*/,
       
   372     TInt& aReasonResourceId ) const
       
   373     {
       
   374     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   375     return EFalse;
       
   376     }
       
   377 
       
   378 // ---------------------------------------------------------
       
   379 // CUniMtmUiData::CanCancelL
       
   380 // ---------------------------------------------------------
       
   381 //
       
   382 TBool CUniMtmUiData::CanCancelL(
       
   383     const TMsvEntry& /*aContext*/,
       
   384     TInt& aReasonResourceId ) const
       
   385     {
       
   386     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   387     return EFalse;
       
   388     }
       
   389 
       
   390 // ---------------------------------------------------------
       
   391 // CUniMtmUiData::StatusTextL
       
   392 // Shows the text in outbox
       
   393 // ---------------------------------------------------------
       
   394 //
       
   395 HBufC* CUniMtmUiData::StatusTextL( const TMsvEntry& /*aContext*/ ) const
       
   396     {
       
   397     return HBufC::NewL( 0 );
       
   398     }
       
   399 
       
   400 // ---------------------------------------------------------
       
   401 // CUniMtmUiData::PopulateArraysL
       
   402 // Populate MTM specific arrays: functions and bitmaps
       
   403 // ---------------------------------------------------------
       
   404 //
       
   405 void CUniMtmUiData::PopulateArraysL()
       
   406     {
       
   407     ReadFunctionsFromResourceFileL( R_UNI_MTM_FUNCTION_ARRAY );
       
   408 
       
   409     // Populate bitmap array
       
   410     TParse fileParse;
       
   411     fileParse.Set( KUniMtmUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL );
       
   412     CreateSkinnedBitmapsL(
       
   413         fileParse.FullName(), 
       
   414         EMbmMuiuQgn_prop_mce_sms_read, 
       
   415         EMbmMuiuQgn_prop_mce_sms_read_mask );
       
   416     CreateSkinnedBitmapsL(
       
   417         fileParse.FullName(), 
       
   418         EMbmMuiuQgn_prop_mce_mms_read, 
       
   419         EMbmMuiuQgn_prop_mce_mms_read_mask );   
       
   420     CreateSkinnedBitmapsL( 
       
   421     	fileParse.FullName(),
       
   422 		EMbmMuiuQgn_indi_mce_priority_high,
       
   423 		EMbmMuiuQgn_indi_mce_priority_low_mask );	
       
   424     }
       
   425 
       
   426 // ---------------------------------------------------------
       
   427 // CUniMtmUiData::CreateSkinnedBitmapsL
       
   428 // Populate MTM specific bitmaps
       
   429 // ---------------------------------------------------------
       
   430 //
       
   431 void CUniMtmUiData::CreateSkinnedBitmapsL( const TDesC& aBitmapFile,
       
   432                                           TInt aStartBitmap,
       
   433                                           TInt aEndBitmap )
       
   434     {
       
   435     CBitmapArray* array = NULL;
       
   436     for ( TInt i = aStartBitmap; i <= aEndBitmap; i += KUniNumberOfZoomStates )
       
   437         {
       
   438         array = new( ELeave ) CArrayPtrFlat<CFbsBitmap>( KUniNumberOfZoomStates );
       
   439         CleanupStack::PushL( array );
       
   440 
       
   441         TAknsItemID skinId;
       
   442         switch ( i )
       
   443             {
       
   444             case EMbmMuiuQgn_prop_mce_mms_read:
       
   445                 {
       
   446                 skinId.Set( KAknsIIDQgnPropMceMmsRead );
       
   447                 break;
       
   448                 }
       
   449             case EMbmMuiuQgn_prop_mce_sms_read:
       
   450                 {
       
   451                 skinId.Set( KAknsIIDQgnPropMceSmsRead );
       
   452                 break;
       
   453                 }
       
   454             case EMbmMuiuQgn_indi_mce_priority_high:
       
   455                 {
       
   456                 skinId.Set( KAknsIIDQgnIndiTodoHighAdd );
       
   457                 break;
       
   458                 }
       
   459             case EMbmMuiuQgn_indi_mce_priority_low:
       
   460                 {
       
   461                 skinId.Set( KAknsIIDQgnIndiTodoLowAdd );
       
   462                 break;
       
   463                 }
       
   464             default:
       
   465                 {
       
   466                 User::Leave( KErrNotFound );
       
   467                 break;
       
   468                 }
       
   469             }
       
   470 
       
   471         CFbsBitmap* bitmap = NULL;
       
   472         CFbsBitmap* mask = NULL;
       
   473         AknsUtils::CreateIconL(
       
   474             AknsUtils::SkinInstance(),
       
   475             skinId,
       
   476             bitmap,
       
   477             mask,
       
   478             aBitmapFile,
       
   479             i,
       
   480             i + 1 );
       
   481 
       
   482         CleanupStack::PushL( mask );
       
   483         CleanupStack::PushL( bitmap );       
       
   484         array->AppendL( bitmap );
       
   485         CleanupStack::Pop( bitmap  );
       
   486         array->AppendL( mask );
       
   487         CleanupStack::Pop( mask );
       
   488 
       
   489         iIconArrays->AppendL( array );
       
   490         CleanupStack::Pop( array ); 
       
   491         }
       
   492     }
       
   493 
       
   494 // ---------------------------------------------------------
       
   495 // CUniMtmUiData::GetResourceFileName
       
   496 // Self explanatory.
       
   497 // ---------------------------------------------------------
       
   498 //
       
   499 void CUniMtmUiData::GetResourceFileName( TFileName& aFileName ) const
       
   500     {
       
   501     aFileName = KUniMtmResourceFile; 
       
   502     }
       
   503 
       
   504 // ================= OTHER EXPORTED FUNCTIONS ==============
       
   505 
       
   506 //  End of File