mobilemessaging/mmsui/notmtmsrc/NotMtmUiData.cpp
changeset 79 2981cb3aa489
parent 0 72b543305e3a
equal deleted inserted replaced
25:84d9eb65b26f 79:2981cb3aa489
       
     1 /*
       
     2 * Copyright (c) 2004 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 Notification MTM UI data methods.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include "NotMtmUiData.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 <NotUi.rsg>
       
    38 #include <muiu.mbg>                         // for notif icon bitmaps
       
    39 #include <messagingvariant.hrh>
       
    40 #include <avkon.rsg>
       
    41 #include "NotMtmUiPanic.h"
       
    42 #include "MmsMtmConst.h"
       
    43 #include <mmserrors.h>
       
    44 #include <mmsconst.h>                       // for KUidMsgTypeMultimedia
       
    45 
       
    46 #include <featmgr.h>  
       
    47 #include <StringLoader.h>           // StringLoader link against CommonEngine.lib
       
    48 
       
    49 #include <centralrepository.h>    // link against centralrepository.lib
       
    50 #include <messaginginternalcrkeys.h> // for Central Repository keys
       
    51 
       
    52 // CONSTANTS
       
    53 const TInt KMmsReadIconIndex = 0;
       
    54 const TInt KMmsUnreadIconIndex = 1;
       
    55 
       
    56 // MACROS
       
    57 // LOCAL CONSTANTS AND MACROS
       
    58 // MODULE DATA STRUCTURES
       
    59 // LOCAL FUNCTION PROTOTYPES
       
    60 
       
    61 // ==================== LOCAL FUNCTIONS ====================
       
    62 
       
    63 // ---------------------------------------------------------
       
    64 // NewNotMtmUiDataL
       
    65 // Factory function
       
    66 // ---------------------------------------------------------
       
    67 //
       
    68 EXPORT_C CBaseMtmUiData* NewNotMtmUiDataL( CRegisteredMtmDll& aRegisteredDll )
       
    69     {
       
    70     return CNotMtmUiData::NewL( aRegisteredDll );
       
    71     }
       
    72 
       
    73 
       
    74 // ================= MEMBER FUNCTIONS =======================
       
    75 
       
    76 // ---------------------------------------------------------
       
    77 // CNotMtmUiData::CMmsMtmUiData
       
    78 // C++ constructor
       
    79 // ---------------------------------------------------------
       
    80 //
       
    81 CNotMtmUiData::CNotMtmUiData( CRegisteredMtmDll& aRegisteredDll )
       
    82     :   CBaseMtmUiData( aRegisteredDll )
       
    83     {
       
    84     }
       
    85 
       
    86 // ---------------------------------------------------------
       
    87 // CNotMtmUiData::ConstructL
       
    88 // Symbian OS default constructor can leave.
       
    89 // ---------------------------------------------------------
       
    90 //
       
    91 void CNotMtmUiData::ConstructL()
       
    92     {
       
    93     // KFeatureIdMMSNotificationsView is needed in CNotMtmUiData::PopulateArraysL,
       
    94     // which is called from CBaseMtmUiData::ConstructL();
       
    95     
       
    96     // Get supported features from feature manager.
       
    97     FeatureManager::InitializeLibL();
       
    98     
       
    99     // KFeatureIdMmsNonDestructiveForward has been deprecated
       
   100     // Check of TMsvEntry::iMtmData2 & KMmsStoredInMMBox replaces it. 
       
   101     // MMSEngine sets KMmsStoredInMMBox for received notifications
       
   102     
       
   103     if ( FeatureManager::FeatureSupported( KFeatureIdMMSNotificationsView ) )
       
   104         {
       
   105         iNotUiDataFlags |= ENotificationsViewInMce;
       
   106         }
       
   107     FeatureManager::UnInitializeLib();
       
   108     CBaseMtmUiData::ConstructL();
       
   109 
       
   110     //  Get mms local variation values
       
   111     TInt featureBitmask = 0;
       
   112     
       
   113     CRepository* repository = CRepository::NewL( KCRUidMuiuVariation );
       
   114     repository->Get( KMuiuMmsFeatures, featureBitmask );
       
   115     delete repository;
       
   116     repository = NULL;
       
   117     if ( featureBitmask & KMmsFeatureIdNotificationForward )
       
   118         {
       
   119         iNotUiDataFlags |= EForwardSupported;
       
   120         }
       
   121     featureBitmask = 0;
       
   122     
       
   123     }
       
   124 
       
   125 
       
   126 // ---------------------------------------------------------
       
   127 // CNotMtmUiData::NewL
       
   128 // Two-phased constructor.
       
   129 // ---------------------------------------------------------
       
   130 //
       
   131 CNotMtmUiData* CNotMtmUiData::NewL( CRegisteredMtmDll& aRegisteredDll )
       
   132     {
       
   133     LOGTEXT( _L8( "MmsMtmUiData::NewL" ) );
       
   134     CNotMtmUiData* self = new ( ELeave ) CNotMtmUiData( aRegisteredDll );
       
   135     
       
   136     CleanupStack::PushL( self );
       
   137     self->ConstructL();
       
   138     CleanupStack::Pop(); //self
       
   139 
       
   140     return self;
       
   141     }
       
   142 
       
   143     
       
   144 // ---------------------------------------------------------
       
   145 // CNotMtmUiData::~CMmsMtmUiData
       
   146 // Destructor.
       
   147 // ---------------------------------------------------------
       
   148 //
       
   149 CNotMtmUiData::~CNotMtmUiData()
       
   150     {
       
   151     }
       
   152 
       
   153 // ---------------------------------------------------------
       
   154 // CNotMtmUiData::OperationSupportedL
       
   155 // ---------------------------------------------------------
       
   156 //
       
   157 TInt CNotMtmUiData::OperationSupportedL(
       
   158     TInt aFunctionId,
       
   159     const TMsvEntry& aContext ) const
       
   160     {
       
   161     LOGTEXT2( _L16( "NotMtmUiData - OperationSupported: %d" ), aContext.Id() ); 
       
   162     if( ( aContext.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd ) // Notification
       
   163         {
       
   164         TNotUiMsgStatus msgstatus = MsgStatus( aContext );
       
   165 
       
   166         // Only Message Info for messages is a supported operation
       
   167         if ( ( aFunctionId == KMtmUiFunctionMessageInfo ) &&
       
   168             ( aContext.iType == KUidMsvMessageEntry ) )
       
   169             {   // Info is always supported for messages
       
   170             LOGTEXT( _L8( "NotMtmUiData - Operation Message Info supported" ) );
       
   171             return 0;
       
   172             }
       
   173 
       
   174         if ( ( aFunctionId == KMtmUiFunctionFetchMMS ) &&
       
   175             ( aContext.iType == KUidMsvMessageEntry ) )
       
   176             {
       
   177 
       
   178             if( aContext.iMtmData2 & KMmsNewOperationForbidden ) // New Forbidden
       
   179                 {
       
   180                 LOGTEXT( _L8( "NotMtmUiData - Operation Retrieve not supported" ) );
       
   181                 return R_EIK_TBUF_NOT_AVAILABLE;
       
   182                 }
       
   183             // If notification is succesfully routed to app 
       
   184             // aContext.iMtmData2 & KMmsMessageRoutedToApplication is ETrue and
       
   185             // if notification is NOT succesfully routed to app 
       
   186             // aContext.iError is KMmsErrorUnregisteredApplication.
       
   187             if(    ( aContext.iError == KMmsErrorUnregisteredApplication ) // To unregistered application
       
   188                 || ( aContext.iMtmData2 & KMmsMessageRoutedToApplication ) )
       
   189                 {
       
   190                 LOGTEXT( _L8( "NotMtmUiData - Operation Retrieve not supported" ) );
       
   191                 return R_EIK_TBUF_NOT_AVAILABLE;
       
   192                 }
       
   193 
       
   194             if( msgstatus == EMsgStatusDeleted )
       
   195                 { // Msg already been deleted from server
       
   196                 LOGTEXT( _L8( "NotMtmUiData - Operation Retrieve not supported" ) );
       
   197                 return R_EIK_TBUF_NOT_AVAILABLE;
       
   198                 }
       
   199 
       
   200             if( msgstatus == EMsgStatusReadyForFetching 
       
   201                 || msgstatus == EMsgStatusFailed )
       
   202                 {   // Fetch is supported if the msg is waiting or something has been failed
       
   203                 LOGTEXT( _L8( "NotMtmUiData - Operation Retrieve message supported" ) );
       
   204                 return 0;
       
   205                 }
       
   206 
       
   207             if (    msgstatus == EMsgStatusForwarded 
       
   208                 &&  aContext.iMtmData2 & KMmsStoredInMMBox )
       
   209                 { // Fetch is supported if it's forwarded and multiple forward is supported
       
   210                 LOGTEXT( _L8( "NotMtmUiData - Operation Retrieve supported" ) );
       
   211                 return 0;
       
   212                 }
       
   213 
       
   214             // Otherwise it's not supported
       
   215             LOGTEXT( _L8( "NotMtmUiData - Operation Retrieve not supported" ) );
       
   216             return R_EIK_TBUF_NOT_AVAILABLE;
       
   217             }
       
   218 
       
   219 
       
   220         if (    ( aFunctionId == KMtmUiFunctionDeleteMessage )
       
   221             &&  ( aContext.iType == KUidMsvMessageEntry )
       
   222             &&  ( aContext.iMtmData2 & KMmsNewOperationForbidden ) ) // New Forbidden
       
   223                 {
       
   224                 LOGTEXT( _L8( "NotMtmUiData - Operation Delete not supported" ) );
       
   225                 return R_EIK_TBUF_NOT_AVAILABLE;
       
   226                 }
       
   227 
       
   228         if ( ( aFunctionId == KMtmUiFunctionDeleteMessage ) &&
       
   229             ( aContext.iType == KUidMsvMessageEntry ) &&
       
   230             ( msgstatus != EMsgStatusRetrieving ) &&
       
   231             ( msgstatus != EMsgStatusForwarding ) )
       
   232             {   // Delete is supported if msg is not retrieving or forwarding
       
   233             LOGTEXT( _L8( "NotMtmUiData - Operation Delete message supported" ) );
       
   234             return 0;
       
   235             }
       
   236 
       
   237         if ( ( aFunctionId == KMtmUiFunctionOpenMessage ) &&
       
   238             ( aContext.iType == KUidMsvMessageEntry ) &&
       
   239             ( aContext.iMtmData2 & KMmsNewOperationForbidden ) &&
       
   240             ( aContext.iMtmData2 & KMmsOperationForward  ) &&
       
   241             ( !( aContext.iMtmData2 & KMmsOperationFetch ) ) )
       
   242             {   // Open is supported only if forward is in progress
       
   243             LOGTEXT( _L8( "NotMtmUiData - Operation Open message supported" ) );
       
   244             return 0;
       
   245             }
       
   246 
       
   247 
       
   248         if ( ( aFunctionId == KMtmUiFunctionOpenMessage ) &&
       
   249             ( aContext.iType == KUidMsvMessageEntry ) &&
       
   250             ( msgstatus != EMsgStatusRetrieving ) &&
       
   251             ( msgstatus != EMsgStatusWaiting ) )
       
   252             {   // Open is supported if msg is not retrieving or forwarding
       
   253             LOGTEXT( _L8( "NotMtmUiData - Operation Open message supported" ) );
       
   254             return 0;
       
   255             }
       
   256 
       
   257         if ( ( aFunctionId == KMtmUiFunctionMoveTo ) &&
       
   258             ( aContext.iType == KUidMsvMessageEntry ) )
       
   259             {   // Move is never supported
       
   260             LOGTEXT( _L8( "NotMtmUiData - Operation MoveTo not supported" ) );
       
   261             return R_EIK_TBUF_NOT_AVAILABLE;
       
   262             }
       
   263             
       
   264         if ( ( aFunctionId == KMtmUiFunctionForward ) &&
       
   265             ( aContext.iType == KUidMsvMessageEntry ) )
       
   266             {
       
   267 
       
   268             if( aContext.iMtmData2 & KMmsNewOperationForbidden ) // New Forbidden
       
   269                 {
       
   270                 LOGTEXT( _L8( "NotMtmUiData - Operation Forward not supported" ) );
       
   271                 return R_EIK_TBUF_NOT_AVAILABLE;
       
   272                 }
       
   273 
       
   274             if( iNotUiDataFlags & EForwardSupported )
       
   275                 {
       
   276 
       
   277                 if( msgstatus == EMsgStatusDeleted )
       
   278                     {   // Forward not supported if msg has been deleted
       
   279                     LOGTEXT( _L8( "NotMtmUiData - Operation Retrieve not supported" ) );
       
   280                     return R_EIK_TBUF_NOT_AVAILABLE;
       
   281                     }
       
   282 
       
   283                 // If notification is succesfully routed to app 
       
   284                 // aContext.iMtmData2 & KMmsMessageRoutedToApplication is ETrue and
       
   285                 // if notification is NOT succesfully routed to app 
       
   286                 // aContext.iError is KMmsErrorUnregisteredApplication.
       
   287                 if(    ( aContext.iError == KMmsErrorUnregisteredApplication ) // To unregistered application
       
   288                     || ( aContext.iMtmData2 & KMmsMessageRoutedToApplication ) )
       
   289                     {
       
   290                     LOGTEXT( _L8( "NotMtmUiData - Operation Forward not supported" ) );
       
   291                     return R_EIK_TBUF_NOT_AVAILABLE;
       
   292                     }
       
   293 
       
   294                 if ( msgstatus == EMsgStatusReadyForFetching
       
   295                     || msgstatus == EMsgStatusFailed )
       
   296                     { // Forward supported if it's ready or failed
       
   297                     LOGTEXT( _L8( "NotMtmUiData - Operation Forward supported" ) );
       
   298                     return 0;
       
   299                     }
       
   300 
       
   301                 if (    msgstatus == EMsgStatusForwarded
       
   302                     &&  aContext.iMtmData2 & KMmsStoredInMMBox )
       
   303                     { // Forward supported if it's forwarded and multiple forward supported
       
   304                     LOGTEXT( _L8( "NotMtmUiData - Operation Forward supported" ) );
       
   305                     return 0;
       
   306                     }
       
   307                 // Otherwise forward is not supported
       
   308                 LOGTEXT( _L8( "NotMtmUiData - Operation Forward not supported" ) );
       
   309                 return R_EIK_TBUF_NOT_AVAILABLE;
       
   310                 }
       
   311             else
       
   312                 {   // If forward is not supported at all -> it's not supported
       
   313                 LOGTEXT( _L8( "NotMtmUiData - Operation Forward not supported" ) );
       
   314                 return R_EIK_TBUF_NOT_AVAILABLE;
       
   315                 }
       
   316             }
       
   317 
       
   318         }
       
   319     else if( ( aContext.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageForwardReq ) // Forward request
       
   320         {
       
   321         // Only Message Info for messages is a supported operation
       
   322         if ( ( aFunctionId == KMtmUiFunctionMessageInfo ) &&
       
   323             ( aContext.iType == KUidMsvMessageEntry ) )
       
   324             { // Info always supported
       
   325             LOGTEXT( _L8( "NotMtmUiData - Operation Message Info supported" ) );
       
   326             return 0;
       
   327             }
       
   328 
       
   329         if ( ( aFunctionId == KMtmUiFunctionDeferSending ) &&
       
   330             ( aContext.iType == KUidMsvMessageEntry ) )
       
   331             { // Defer never supported
       
   332             LOGTEXT( _L8( "NotMtmUiData - Operation Defer sending not supported" ) );
       
   333             return R_EIK_TBUF_NOT_AVAILABLE;
       
   334             }
       
   335 
       
   336         if ( ( aFunctionId == KMtmUiFunctionMoveTo ) &&
       
   337             ( aContext.iType == KUidMsvMessageEntry ) )
       
   338             { // MoveTo never supported
       
   339             LOGTEXT( _L8( "NotMtmUiData - Operation MoveTo not supported" ) );
       
   340             return R_EIK_TBUF_NOT_AVAILABLE;
       
   341             }
       
   342 
       
   343         if ( ( aFunctionId == KMtmUiFunctionDeleteMessage ) &&
       
   344             ( aContext.iType == KUidMsvMessageEntry ) )
       
   345             { // Delete supported
       
   346             LOGTEXT( _L8( "NotMtmUiData - Operation Delete supported" ) );
       
   347             return 0;
       
   348             }
       
   349 
       
   350         if ( ( aFunctionId == KMtmUiFunctionOpenMessage ) &&
       
   351             ( aContext.iType == KUidMsvMessageEntry ) &&
       
   352             ( aContext.Parent( ) == KMsvSentEntryId ) )
       
   353             { // Open supported in Sent items only
       
   354             LOGTEXT( _L8( "NotMtmUiData - Operation Open supported in Sent" ) );
       
   355             return 0;
       
   356             }
       
   357 
       
   358         if ( ( aFunctionId == KMtmUiFunctionSend ) &&
       
   359             ( aContext.iType == KUidMsvMessageEntry ) )
       
   360             { // Send is supported
       
   361             LOGTEXT( _L8( "NotMtmUiData - Operation Send supported" ) );
       
   362             return 0;
       
   363             } 
       
   364         }
       
   365     
       
   366     if ( ( aFunctionId == KMtmUiFunctionDeleteMessage ) &&
       
   367         ( aContext.iType == KUidMsvMessageEntry ) &&
       
   368         ! ( aContext.iMtmData2 & KMmsNewOperationForbidden ) ) 
       
   369         {
       
   370         LOGTEXT( _L8( "NotMtmUiData - Operation Delete is supported as message type is treated as Unknown" ) );
       
   371         return 0;
       
   372         }
       
   373         
       
   374     LOGTEXT( _L8( "NotMtmUiData - Operation not supported" ) );
       
   375     return R_EIK_TBUF_NOT_AVAILABLE;
       
   376     }
       
   377 
       
   378 
       
   379 // ---------------------------------------------------------
       
   380 // CNotMtmUiData::QueryCapability
       
   381 // The default UI capability checker (UI MTM may have also minimal
       
   382 // UI specific checks also)
       
   383 // ---------------------------------------------------------
       
   384 //
       
   385 TInt CNotMtmUiData::QueryCapability(
       
   386     TUid aFunctionId,
       
   387     TInt& aResponse ) const
       
   388     {
       
   389     TInt error = KErrNone;
       
   390 
       
   391     switch ( aFunctionId.iUid )
       
   392         {
       
   393         // Supported:
       
   394         case KUidMtmQueryMaxTotalMsgSizeValue:
       
   395             aResponse = KMaxTInt;
       
   396             break;
       
   397         case KUidMsvMtmQueryEditorUidValue:
       
   398             aResponse = KNotViewer;
       
   399             break;
       
   400         case KUidMsvMtmQueryViewerUidValue:
       
   401             aResponse = KNotViewer;
       
   402             break;
       
   403         case KUidMsvMtmQuerySupportLinks: // flow through
       
   404         case KUidMsvMtmUiQueryMessagingInitialisation: // flow through. This is also in UI MTM!
       
   405         case KUidMsvMtmQueryFactorySettings: // This is also in UI MTM!
       
   406             aResponse = ETrue;
       
   407             break;
       
   408         case KUidMtmQuerySupportAttachmentsValue:
       
   409         case KUidMtmQueryCanReceiveMsgValue:
       
   410         case KUidMsvMtmQueryMessageInfo:
       
   411             break;
       
   412 
       
   413         default:
       
   414             // All others - Not Supported. At least these:
       
   415             //KUidMtmQueryCanCreateNewMsgValue
       
   416             //KUidMtmQueryCanSendMsgValue
       
   417             //KUidMtmQuerySupportedBodyValue: text part(s) are attachments!
       
   418             //KUidMtmQueryMaxBodySizeValue: texts part(s) are attachments!
       
   419             //KUidMtmQuerySupportSubjectValue: subject is supported in Viewer, but not in Editor
       
   420             //KUidMsvMtmUiQueryCanPrintPreviewMsgValue: no printing in Series 60
       
   421             //KUidMsvMtmUiQueryCanPrintMsgValue: no printing in Series 60
       
   422             //KUidMtmQueryMaxRecipientCountValue
       
   423             //KUidMtmQuerySupportsBioMsgValue
       
   424             //KUidMtmQuerySendAsRequiresRenderedImageValue
       
   425             //KUidMtmQuerySendAsRenderingUidValue
       
   426             //KUidMsvMtmUiQueryExtendedOpenProgress
       
   427             //KUidMsvMtmUiQueryExtendedGetMailProgress
       
   428             //KUidMsvMtmUiQueryConnectionOrientedServices
       
   429             //KUidMsvMtmUiQueryServiceAttributes
       
   430             //KUidMsvMtmUiQueryCanGetNew
       
   431             //KUidMsvMtmUiQueryCanOpenServiceOnAction
       
   432             //KUidMtmQueryOffLineAllowedValue
       
   433             //KUidMtmQuerySupportsSchedulingValue
       
   434             //KUidMtmQuerySupportsFolderValue
       
   435 
       
   436             error = KErrNotSupported;
       
   437         }
       
   438     LOGTEXT2( _L16( "NotMtmUiData - QueryCapability: %d" ), error );
       
   439     return error;   
       
   440     }
       
   441 
       
   442 // ---------------------------------------------------------
       
   443 // CNotMtmUiData::ContextIcon
       
   444 // Returns the array of icons relevant to given entry
       
   445 // ---------------------------------------------------------
       
   446 //
       
   447 const CNotMtmUiData::CBitmapArray& CNotMtmUiData::ContextIcon(
       
   448     const TMsvEntry& aContext,
       
   449     TInt /*aStateFlags*/ ) const
       
   450     {
       
   451     //    Return the set of icons (i.e. different sizes) appropriate to the current context
       
   452     __ASSERT_DEBUG( aContext.iMtm == KUidMsgMMSNotification, Panic( EMmsWrongMtm ) );
       
   453     __ASSERT_DEBUG( aContext.iType.iUid != KUidMsvFolderEntryValue, Panic( EMmsFoldersNotSupported ) );
       
   454     __ASSERT_DEBUG( aContext.iType.iUid != KUidMsvAttachmentEntryValue, Panic( EMmsNoIconForAttachment ) );
       
   455 
       
   456     const TInt bmpIndex = aContext.Unread() ? KMmsUnreadIconIndex : KMmsReadIconIndex;
       
   457     return *iIconArrays->At( bmpIndex );
       
   458     }
       
   459 
       
   460 // ---------------------------------------------------------
       
   461 // CNotMtmUiData::CanCreateEntryL
       
   462 // ---------------------------------------------------------
       
   463 //
       
   464 TBool CNotMtmUiData::CanCreateEntryL(
       
   465     const TMsvEntry& /*aParent*/,
       
   466     TMsvEntry& /*aNewEntry*/,
       
   467     TInt& aReasonResourceId ) const
       
   468     {
       
   469     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   470     return EFalse;
       
   471     }
       
   472 
       
   473 // ---------------------------------------------------------
       
   474 // CNotMtmUiData::CanOpenEntryL
       
   475 // ---------------------------------------------------------
       
   476 //
       
   477 TBool CNotMtmUiData::CanOpenEntryL(
       
   478     const TMsvEntry& /*aContext*/,
       
   479     TInt& aReasonResourceId ) const
       
   480     {
       
   481     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   482     return EFalse;
       
   483     }
       
   484 
       
   485 // ---------------------------------------------------------
       
   486 // CNotMtmUiData::CanCloseEntryL
       
   487 // ---------------------------------------------------------
       
   488 //
       
   489 TBool CNotMtmUiData::CanCloseEntryL(
       
   490     const TMsvEntry& /*aContext*/,
       
   491     TInt& aReasonResourceId ) const
       
   492     {
       
   493     aReasonResourceId=R_EIK_TBUF_NOT_AVAILABLE;
       
   494     return EFalse;
       
   495     }
       
   496 
       
   497 // ---------------------------------------------------------
       
   498 // CNotMtmUiData::CanViewEntryL
       
   499 // ---------------------------------------------------------
       
   500 //
       
   501 TBool CNotMtmUiData::CanViewEntryL(
       
   502     const TMsvEntry& /*aContext*/,
       
   503     TInt& aReasonResourceId ) const
       
   504     {
       
   505     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   506     return EFalse;
       
   507     }
       
   508 
       
   509 // ---------------------------------------------------------
       
   510 // CNotMtmUiData::CanEditEntryL
       
   511 // ---------------------------------------------------------
       
   512 //
       
   513 TBool CNotMtmUiData::CanEditEntryL(
       
   514     const TMsvEntry& /*aContext*/,
       
   515     TInt& aReasonResourceId ) const
       
   516     {
       
   517     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   518     return EFalse;
       
   519     }
       
   520 
       
   521 // ---------------------------------------------------------
       
   522 // CNotMtmUiData::CanDeleteFromEntryL
       
   523 // ---------------------------------------------------------
       
   524 //
       
   525 TBool CNotMtmUiData::CanDeleteFromEntryL(
       
   526     const TMsvEntry& /*aContext*/,
       
   527     TInt& aReasonResourceId ) const
       
   528     {
       
   529     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   530     return EFalse;
       
   531     }
       
   532 
       
   533 // ---------------------------------------------------------
       
   534 // CNotMtmUiData::CanDeleteServiceL
       
   535 // ---------------------------------------------------------
       
   536 //
       
   537 TBool CNotMtmUiData::CanDeleteServiceL(
       
   538     const TMsvEntry& /*aService*/,
       
   539     TInt& aReasonResourceId ) const
       
   540     {
       
   541     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   542     return EFalse;
       
   543     }
       
   544 
       
   545 // ---------------------------------------------------------
       
   546 // CNotMtmUiData::CanCopyMoveToEntryL
       
   547 // ---------------------------------------------------------
       
   548 //
       
   549 TBool CNotMtmUiData::CanCopyMoveToEntryL(
       
   550     const TMsvEntry& /*aContext*/,
       
   551     TInt& aReasonResourceId ) const
       
   552     {
       
   553     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   554     return EFalse;
       
   555     }
       
   556 
       
   557 // ---------------------------------------------------------
       
   558 // CNotMtmUiData::CanCopyMoveFromEntryL
       
   559 // ---------------------------------------------------------
       
   560 //
       
   561 TBool CNotMtmUiData::CanCopyMoveFromEntryL(
       
   562     const TMsvEntry& /*aContext*/,
       
   563     TInt& aReasonResourceId ) const
       
   564     {
       
   565     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   566     return EFalse;
       
   567     }
       
   568 
       
   569 // ---------------------------------------------------------
       
   570 // CNotMtmUiData::CanReplyToEntryL
       
   571 // ---------------------------------------------------------
       
   572 //
       
   573 TBool CNotMtmUiData::CanReplyToEntryL(
       
   574     const TMsvEntry& aContext,
       
   575     TInt& aReasonResourceId ) const
       
   576     {
       
   577     __ASSERT_DEBUG(aContext.iMtm == KUidMsgMMSNotification, Panic(EMmsWrongMtm));
       
   578     if ( aContext.iMtm == KUidMsgMMSNotification
       
   579         && aContext.iType == KUidMsvMessageEntry
       
   580         && aContext.ReadOnly()
       
   581         && aContext.iDetails.Length() )
       
   582         {
       
   583         return ETrue;
       
   584         }
       
   585     else
       
   586         {
       
   587         aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   588         return EFalse;
       
   589         }
       
   590     }
       
   591 
       
   592 // ---------------------------------------------------------
       
   593 // CNotMtmUiData::CanForwardEntryL
       
   594 // ---------------------------------------------------------
       
   595 //
       
   596 TBool CNotMtmUiData::CanForwardEntryL(
       
   597     const TMsvEntry& /*aContext*/,
       
   598     TInt& aReasonResourceId ) const
       
   599     {
       
   600     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   601     return EFalse;
       
   602     }
       
   603 
       
   604 // ---------------------------------------------------------
       
   605 // CNotMtmUiData::CanCancelL
       
   606 // ---------------------------------------------------------
       
   607 //
       
   608 TBool CNotMtmUiData::CanCancelL(
       
   609     const TMsvEntry& /*aContext*/,
       
   610     TInt& aReasonResourceId ) const
       
   611     {
       
   612     aReasonResourceId = R_EIK_TBUF_NOT_AVAILABLE;
       
   613     return EFalse;
       
   614     }
       
   615 
       
   616 // ---------------------------------------------------------
       
   617 // CNotMtmUiData::StatusTextL
       
   618 // Shows the text in outbox
       
   619 // ---------------------------------------------------------
       
   620 //
       
   621 HBufC* CNotMtmUiData::StatusTextL( const TMsvEntry& aContext ) const
       
   622     {
       
   623     LOGTEXT2( _L16( "NotMtmUiData - StatusTextL: %d" ), aContext.Id() );
       
   624     TInt res = 0;
       
   625     TBool needForSubject( EFalse );
       
   626 
       
   627     if( ( aContext.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd )
       
   628         {
       
   629         //notification
       
   630         TNotUiMsgStatus inboxstatus;
       
   631         inboxstatus = MsgStatus( aContext );
       
   632         switch ( inboxstatus )
       
   633             {
       
   634             case EMsgStatusRetrieving:      // retrieving in progress
       
   635                 res = R_NOTMTM_INBOX_STATUS_RETRIEVING;
       
   636                 break;
       
   637 
       
   638             case EMsgStatusWaiting:         // scheduled for automatic fetching
       
   639                 res = R_NOTMTM_INBOX_STATUS_WAITING;
       
   640                 break;
       
   641 
       
   642             case EMsgStatusForwarding:      // forwarding in progress
       
   643                 res = R_NOTMTM_INBOX_STATUS_FORWARDING;
       
   644                 break;
       
   645 
       
   646             case EMsgStatusForwarded:       // forwarded
       
   647                 res = R_NOTMTM_INBOX_STATUS_FORWARDED;
       
   648                 break;
       
   649 
       
   650             case EMsgStatusFailed:          // failed
       
   651                 res = R_NOTMTM_INBOX_STATUS_FAILED;
       
   652                 break;
       
   653 
       
   654             case EMsgStatusDeleted:
       
   655                 {
       
   656                 if( aContext.Parent( ) == KMsvGlobalInBoxIndexEntryId )
       
   657                     {
       
   658                     res = R_NOTMTM_INBOX_STATUS_DELETED;
       
   659                     break;
       
   660                     }
       
   661                 //Let non-inbox entries to flow to next one
       
   662                 //because entry in mmbox view can not be "deleted from server"
       
   663                 }
       
   664             case EMsgStatusReadyForFetching: //get subject as status text
       
   665                 res = R_NOTMTM_INBOX_STATUS_NORMAL;
       
   666                 needForSubject = ETrue; 
       
   667                 break;
       
   668 
       
   669             default:
       
   670                 // This state is set at start - ignore
       
   671                 break;
       
   672 
       
   673             }
       
   674         }
       
   675     else 
       
   676         {
       
   677         if( (aContext.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageForwardReq )
       
   678             {
       
   679             TUint sendingState(0);
       
   680             sendingState = aContext.SendingState();
       
   681             //outbox states
       
   682             switch ( sendingState )
       
   683                 {
       
   684                 case KMsvSendStateSending:          // sending in progress.
       
   685                     res = R_NOTMTM_OUTBOX_STATUS_SENDING;
       
   686                     break;
       
   687 
       
   688                 case KMsvSendStateSuspended:        // set when in offline by mmsengine
       
   689                 case KMsvSendStateResend:           // set when offline->online by mmsengine
       
   690                 case KMsvSendStateWaiting:
       
   691                 case KMsvSendStateScheduled:        // not set in mmsengine
       
   692                     res = R_NOTMTM_OUTBOX_STATUS_WAITING;
       
   693                     break;
       
   694 
       
   695                 case KMsvSendStateFailed:
       
   696                     res = R_NOTMTM_OUTBOX_STATUS_FAILED;
       
   697                     break;
       
   698 
       
   699                 case KMsvSendStateSent:             // sent -> moving to sent items
       
   700                 case KMsvSendStateNotApplicable:    // not set in mmsengine
       
   701                 case KMsvSendStateUponRequest:      // not set in mmsengine
       
   702                 case KMsvSendStateUnknown:
       
   703                 default:
       
   704                     // This state is set at start - ignore
       
   705                     break;
       
   706                 }
       
   707             }
       
   708         }
       
   709 
       
   710     if( needForSubject )
       
   711         { 
       
   712         if( aContext.iDescription.Length( ) > 0 )
       
   713             { // Subject needed and it exists
       
   714             return aContext.iDescription.AllocL( );
       
   715             }
       
   716         }
       
   717     
       
   718     if ( !res )
       
   719         {   // Just in case returns an empty string
       
   720         return HBufC::NewL( 0 );
       
   721         }
       
   722 
       
   723     // Returns the status of the message
       
   724     HBufC* statusText = StringLoader::LoadL( res );
       
   725 
       
   726     return statusText;
       
   727     }
       
   728 
       
   729 // ---------------------------------------------------------
       
   730 // CNotMtmUiData::PopulateArraysL
       
   731 // Populate MTM specific arrays: functions and bitmaps
       
   732 // ---------------------------------------------------------
       
   733 //
       
   734 void CNotMtmUiData::PopulateArraysL()
       
   735     {
       
   736     ReadFunctionsFromResourceFileL( R_NOT_MTM_FUNCTION_ARRAY );
       
   737 
       
   738     if (    ! ( iNotUiDataFlags & ENotificationsViewInMce ) 
       
   739         &&  iMtmSpecificFunctions )
       
   740         {
       
   741         TInt count = iMtmSpecificFunctions->Count();
       
   742         for ( TInt i = 0; i < count ; i ++ )
       
   743             {
       
   744             if ( iMtmSpecificFunctions->At( i ).iFunctionId == KMtmUiFunctionMMBox )
       
   745                 {
       
   746                 iMtmSpecificFunctions->Delete( i );
       
   747                 iMtmSpecificFunctions->Compress( );
       
   748                 break;
       
   749                 }
       
   750             }
       
   751         }
       
   752 
       
   753     // Populate bitmap array
       
   754     TParse fileParse;
       
   755     fileParse.Set( KMmsMtmUiBitmapFile, &KDC_APP_BITMAP_DIR, NULL );
       
   756     CreateSkinnedBitmapsL(
       
   757         fileParse.FullName(), 
       
   758         EMbmMuiuQgn_prop_mce_notif_read, 
       
   759         EMbmMuiuQgn_prop_mce_notif_unread_mask );
       
   760     }
       
   761 
       
   762 // ---------------------------------------------------------
       
   763 // CMmsMtmUiData::CreateSkinnedBitmapsL
       
   764 // Creates bitmaps and skinned masks with correct TAknsItemID
       
   765 // ---------------------------------------------------------
       
   766 //
       
   767 void CNotMtmUiData::CreateSkinnedBitmapsL( const TDesC& aBitmapFile,
       
   768                                           TInt aStartBitmap,
       
   769                                           TInt aEndBitmap )
       
   770     {
       
   771     CBitmapArray* array = NULL;
       
   772     for ( TInt i = aStartBitmap; i <= aEndBitmap; i += KMmsNumberOfZoomStates )
       
   773         {
       
   774         array = new( ELeave ) CArrayPtrFlat<CFbsBitmap>( KMmsNumberOfZoomStates );
       
   775         CleanupStack::PushL( array );
       
   776 
       
   777         TAknsItemID skinId;
       
   778         switch ( i )
       
   779             {
       
   780             case EMbmMuiuQgn_prop_mce_notif_read:
       
   781                 {
       
   782                 skinId.Set( KAknsIIDQgnPropMceNotifRead );
       
   783                 break;
       
   784                 }
       
   785             case EMbmMuiuQgn_prop_mce_notif_unread:
       
   786                 {
       
   787                 skinId.Set( KAknsIIDQgnPropMceNotifUnread );
       
   788                 break;
       
   789                 }
       
   790             default:
       
   791                 {
       
   792                 User::Leave( KErrNotFound );
       
   793                 break;
       
   794                 }
       
   795             }
       
   796 
       
   797         CFbsBitmap* bitmap = NULL;
       
   798         CFbsBitmap* mask = NULL;
       
   799         AknsUtils::CreateIconL(
       
   800             AknsUtils::SkinInstance(),
       
   801             skinId,
       
   802             bitmap,
       
   803             mask,
       
   804             aBitmapFile,
       
   805             i,
       
   806             i + 1 );
       
   807 
       
   808         CleanupStack::PushL( bitmap );
       
   809         CleanupStack::PushL( mask );        
       
   810         array->AppendL( bitmap );
       
   811         CleanupStack::Pop();
       
   812         array->AppendL( mask );
       
   813         CleanupStack::Pop();
       
   814 
       
   815         iIconArrays->AppendL( array );
       
   816         CleanupStack::Pop();// array
       
   817         }
       
   818     }
       
   819 
       
   820 // ---------------------------------------------------------
       
   821 // CNotMtmUiData::GetResourceFileName
       
   822 // ---------------------------------------------------------
       
   823 //
       
   824 void CNotMtmUiData::GetResourceFileName( TFileName& aFileName ) const
       
   825     {
       
   826     aFileName = KNotMtmResourceFile; 
       
   827     }
       
   828 
       
   829 // ---------------------------------------------------------
       
   830 // CNotMtmUiData::MsgStatus
       
   831 // ---------------------------------------------------------
       
   832 //
       
   833 TNotUiMsgStatus CNotMtmUiData::MsgStatus( const TMsvEntry& aEntry ) const
       
   834     {
       
   835     LOGTEXT2( _L16( "CNotMtmUiData::MsgStatus: aEntry.iMtmData2 0x%x" ), aEntry.iMtmData2 ); 
       
   836     TNotUiMsgStatus status = EMsgStatusNull;
       
   837     
       
   838     // operationMask includes operation type. It is not bitmap but ordinal number. 
       
   839     // It does not include operation status and result
       
   840     TInt operationMask = (aEntry.iMtmData2 & KMmsOperationIdentifier) ;
       
   841     
       
   842     // Note! Ongoing operation resets every bit of operation type, operation status
       
   843     // and result. E.g. If message has been forwarded and then fetching starts, 
       
   844     // information about forwarding is lost
       
   845     
       
   846     if( ( aEntry.iMtmData1 & KMmsMessageTypeMask ) == KMmsMessageMNotificationInd ) // Notification
       
   847         {
       
   848         if(     operationMask == KMmsOperationFetch 
       
   849             &&  OperationOngoing( aEntry ) )
       
   850             { 
       
   851             // It's in retrieving state
       
   852             status = EMsgStatusRetrieving;
       
   853             }
       
   854         else if(    operationMask == KMmsOperationForward
       
   855                 &&  OperationOngoing( aEntry ) )
       
   856             { 
       
   857             // It's in forwarding state
       
   858             status = EMsgStatusForwarding;
       
   859             }
       
   860         else if(    operationMask == KMmsOperationForward
       
   861                 &&  OperationFinished( aEntry )
       
   862                 &&  !( aEntry.iMtmData2 & KMmsOperationResult ) )
       
   863             { 
       
   864             // It's been forwarded succesfully
       
   865             status = EMsgStatusForwarded;
       
   866             }
       
   867         else if(    operationMask == KMmsOperationFetch 
       
   868                 &&  OperationFinished( aEntry )
       
   869                 &&   (  aEntry.iMtmData2 & KMmsOperationResult 
       
   870                     ||  aEntry.iError ) )
       
   871             { 
       
   872             // Fetch has been failed
       
   873             status = EMsgStatusFailed;
       
   874             }
       
   875         else if(    operationMask == KMmsOperationDelete
       
   876                 &&  OperationFinished( aEntry )
       
   877                 &&  !( aEntry.iMtmData2 & KMmsOperationResult ) )
       
   878             { 
       
   879             // It's been deleted succesfully
       
   880             status = EMsgStatusDeleted;
       
   881             }
       
   882         else 
       
   883             {   // Normal waiting state
       
   884             status = EMsgStatusReadyForFetching;
       
   885             }
       
   886         }
       
   887     LOGTEXT2( _L16( "CNotMtmUiData::MsgStatus: returns %d" ), status ); 
       
   888     return status;
       
   889     }
       
   890 
       
   891 // ================= OTHER EXPORTED FUNCTIONS ==============
       
   892 
       
   893 // ---------------------------------------------------------
       
   894 // OperationOngoing
       
   895 // ---------------------------------------------------------
       
   896 //
       
   897 TBool CNotMtmUiData::OperationOngoing( const TMsvEntry& aEntry ) const
       
   898     {
       
   899     return (    aEntry.iMtmData2 & KMmsOperationOngoing 
       
   900             &&  !( aEntry.iMtmData2 & KMmsOperationFinished ) );
       
   901     }
       
   902 
       
   903 // ---------------------------------------------------------
       
   904 // OperationFinished
       
   905 // ---------------------------------------------------------
       
   906 //
       
   907 TBool CNotMtmUiData::OperationFinished( const TMsvEntry& aEntry ) const
       
   908     {
       
   909     return (    aEntry.iMtmData2 & KMmsOperationFinished
       
   910             &&  !( aEntry.iMtmData2 & KMmsOperationOngoing ) );
       
   911     }
       
   912 
       
   913 
       
   914 //  End of File