messagingfw/deprecate/senduiservices/datautils/src/SendUiFileRightsEngine.cpp
branchRCL_3
changeset 22 d2c4c66342f3
equal deleted inserted replaced
21:e5b3a2155e1a 22:d2c4c66342f3
       
     1 /*
       
     2 * Copyright (c) 2002-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:   Provides functionality for DRM file protection analyzing
       
    15 *                and content MMS compatibility resolving.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 
       
    21 // INCLUDE FILES
       
    22 #include    "SendUiFileRightsEngine.h"
       
    23 #include    <SendUiConsts.h>
       
    24 #include    "SendUiDataUtils.h"
       
    25 
       
    26 #include    <MsgMedia.hrh>
       
    27 #include    <MsgMediaResolver.h>            // Msg Media Resolver
       
    28 #include    <MmsConformance.h>              // MMS Conformance
       
    29 
       
    30 #include    <sendnorm.rsg>
       
    31 #include    <AknQueryDialog.h>              // Query dialog
       
    32 #include    <AknNoteWrappers.h>             // Note dialog
       
    33 #include    <stringresourcereader.h>        // String Resource Reader
       
    34 #include    <stringloader.h>                // Stringloader
       
    35 #include    <data_caging_path_literals.hrh>
       
    36 #include    <mmsconst.h>
       
    37 #include    <fileprotectionresolver.h>
       
    38 #include    <VideoConversionApi.h>
       
    39 #include    <MsgMimeTypes.h>
       
    40 #include    "CSendUiAttachment.h"
       
    41 // CONSTANTS
       
    42 const TInt KFREKiloByte                     = 1024;
       
    43 
       
    44 
       
    45 // ============================ MEMBER FUNCTIONS ===============================
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // CSendUiFileRightsEngine::CSendUiFileRightsEngine
       
    49 // C++ default constructor can NOT contain any code, that
       
    50 // might leave.
       
    51 // -----------------------------------------------------------------------------
       
    52 //
       
    53 CSendUiFileRightsEngine::CSendUiFileRightsEngine( RFs& aFS )
       
    54     : iFileSession( aFS )
       
    55     {
       
    56     }
       
    57 
       
    58 // -----------------------------------------------------------------------------
       
    59 // CSendUiFileRightsEngine::ConstructL
       
    60 // Symbian 2nd phase constructor can leave.
       
    61 // -----------------------------------------------------------------------------
       
    62 //
       
    63 void CSendUiFileRightsEngine::ConstructL()
       
    64     {
       
    65     iProtectionResolver = CFileProtectionResolver::NewL( iFileSession );
       
    66     iMediaResolver = CMsgMediaResolver::NewL();
       
    67     iMmsConformance = CMmsConformance::NewL();
       
    68     }
       
    69 
       
    70 // -----------------------------------------------------------------------------
       
    71 // CSendUiFileRightsEngine::NewL
       
    72 // Two-phased constructor.
       
    73 // -----------------------------------------------------------------------------
       
    74 //
       
    75 EXPORT_C CSendUiFileRightsEngine* CSendUiFileRightsEngine::NewL( RFs& aFs)
       
    76     {
       
    77     CSendUiFileRightsEngine* self = NewLC( aFs );
       
    78     CleanupStack::Pop( self );
       
    79 
       
    80     return self;
       
    81     }
       
    82 
       
    83 // -----------------------------------------------------------------------------
       
    84 // CSendUiFileRightsEngine::NewLC
       
    85 // Two-phased constructor.
       
    86 // -----------------------------------------------------------------------------
       
    87 //
       
    88 EXPORT_C CSendUiFileRightsEngine* CSendUiFileRightsEngine::NewLC( RFs& aFs )
       
    89     {
       
    90     CSendUiFileRightsEngine* self =
       
    91         new( ELeave ) CSendUiFileRightsEngine( aFs );
       
    92 
       
    93     CleanupStack::PushL( self );
       
    94     self->ConstructL();
       
    95 
       
    96     return self;
       
    97     }
       
    98 
       
    99 // Destructor
       
   100 CSendUiFileRightsEngine::~CSendUiFileRightsEngine()
       
   101     {
       
   102     delete iProtectionResolver;
       
   103     delete iMediaResolver;
       
   104     delete iMmsConformance;
       
   105     }
       
   106 
       
   107 // -----------------------------------------------------------------------------
       
   108 // CSendUiFileRightsEngine::ConfirmDrmFileRightsL
       
   109 
       
   110 // Closed content list checking is also done here.
       
   111 // (other items were commented in a header).
       
   112 // -----------------------------------------------------------------------------
       
   113 //
       
   114 EXPORT_C void CSendUiFileRightsEngine::ConfirmDrmFileRightsL(
       
   115     CArrayPtrFlat<CSendUiAttachment>* aAttachments )
       
   116     {
       
   117 	if ( !aAttachments )
       
   118 		{
       
   119 		return;
       
   120 		}
       
   121     TInt fileCount = aAttachments->Count();
       
   122     if ( fileCount )
       
   123         {
       
   124         TInt index = 0;
       
   125         TInt protection = 0;
       
   126         TDataType mimeType;
       
   127 
       
   128         CSendUiDataUtils* dataUtils = CSendUiDataUtils::NewL( iFileSession );
       
   129         CleanupStack::PushL( dataUtils );
       
   130 
       
   131         while ( index < fileCount)
       
   132             {
       
   133             iValidationResults[ESenduiIndexTotalCount]++;
       
   134             CSendUiAttachment& attachment = *(aAttachments->At(index));
       
   135             RFile file = *(attachment.Handle());
       
   136             dataUtils->ResolveFileMimeTypeL( file, mimeType );
       
   137         	protection = iProtectionResolver->ProtectionStatusL( file, mimeType );
       
   138      		attachment.SetMimeType( mimeType );
       
   139             	
       
   140             if ( protection & EFileProtSuperDistributable )
       
   141                 {
       
   142                 iValidationResults[ESenduiIndexDrmSD]++;
       
   143                 }
       
   144             else if ( ( protection & EFileProtForwardLocked ) ||
       
   145                       ( protection & EFileProtClosedContent ) )
       
   146                 {
       
   147                 iInvalidationReason[ESenduiIndexDrmFLOrCCL]++;
       
   148                 iValidationResults[ESenduiIndexDeleted]++;
       
   149                 delete aAttachments->At(index);
       
   150                 aAttachments->Delete( index );
       
   151                 
       
   152                 fileCount--;
       
   153                 index--;
       
   154                 }
       
   155             index++;
       
   156             }
       
   157 
       
   158         CleanupStack::PopAndDestroy( dataUtils );
       
   159         }
       
   160     }
       
   161 
       
   162 // -----------------------------------------------------------------------------
       
   163 // CSendUiFileRightsEngine::ConfirmMmsValidityL
       
   164 // -----------------------------------------------------------------------------
       
   165 //
       
   166 EXPORT_C void CSendUiFileRightsEngine::ConfirmMmsValidityL(
       
   167     CArrayPtrFlat<CSendUiAttachment>* aAttachments,
       
   168     TUid                aServiceId )
       
   169     {
       
   170 	if ( !aAttachments )
       
   171 		{
       
   172 		return;
       
   173 		}
       
   174     TBool removeFilePath = EFalse;
       
   175     TInt index = 0;
       
   176     TInt fileCount = aAttachments->Count();
       
   177     TInt attachmentsSize = 0;
       
   178     // MMS image size is set to original for MMS upload service,
       
   179     // otherwise oversize images are not filtered away from array
       
   180     if( aServiceId == KMmsDirectUpload || aServiceId == KMmsIndirectUpload )
       
   181         {
       
   182         // Image size setting not used since only MIME type conformance is checked.
       
   183         iMmsConformance->SetCreationMode( ETrue );
       
   184         }
       
   185     if ( fileCount )
       
   186         {
       
   187         while ( index < fileCount)
       
   188             {
       
   189             
       
   190             // Validate file for MMS
       
   191             CSendUiAttachment& attachment = *(aAttachments->At(index));
       
   192             removeFilePath = AnalyzeMmsValidationResultL( *(aAttachments->At(index) ), attachmentsSize );
       
   193 	  
       
   194             if ( removeFilePath )
       
   195                 {
       
   196                 delete aAttachments->At(index);
       
   197                 aAttachments->Delete( index );
       
   198                 iValidationResults[ESenduiIndexDeleted]++;
       
   199                 fileCount--;
       
   200                 index--;
       
   201                 }
       
   202 
       
   203             index++;
       
   204             }
       
   205         }
       
   206     }
       
   207 
       
   208 // -----------------------------------------------------------------------------
       
   209 // CSendUiFileRightsEngine::ShowDrmAndMmsInfoL
       
   210 // Shows DRM confirmation query and/or error note, if needed.
       
   211 // Returns EFalse if user cancels sending.
       
   212 // (other items were commented in a header).
       
   213 // -----------------------------------------------------------------------------
       
   214 //
       
   215 EXPORT_C TBool CSendUiFileRightsEngine::ShowDrmAndMmsInfoL( TUid aServiceId )
       
   216     {
       
   217     TBool showDrmQuery = EFalse;
       
   218     TBool showErrorNotification = EFalse;
       
   219     TUint drmQueryTextId = 0;
       
   220     TUint noteTextId = 0;
       
   221     TUint valueForNote = 0;
       
   222     TFREErrorNoteType noteType = EInformationNote;
       
   223 
       
   224     // Information query and/or error note is shown if needed
       
   225     if ( iValidationResults[ESenduiIndexDeleted] )
       
   226         {
       
   227         ResolveErrorNoteL( aServiceId, noteTextId, noteType, valueForNote );
       
   228         showErrorNotification = ETrue;
       
   229         }
       
   230 
       
   231     // Possible DRM query is shown only if all files are not deleted.
       
   232     if ( iValidationResults[ESenduiIndexDeleted] <
       
   233          iValidationResults[ESenduiIndexTotalCount] )
       
   234         {
       
   235         if ( iValidationResults[ESenduiIndexDrmSD] )
       
   236             {
       
   237             ResolveDrmQuery( aServiceId, drmQueryTextId );
       
   238             showDrmQuery = ETrue;
       
   239             }
       
   240         }
       
   241 
       
   242     // Show error note if needed
       
   243     if ( showErrorNotification )
       
   244         {
       
   245         ShowErrorNotificationL( noteTextId, noteType, valueForNote );
       
   246         }
       
   247 
       
   248     // Show query if needed
       
   249     if ( showDrmQuery )
       
   250         {
       
   251         return ShowConfirmationQueryL(
       
   252             drmQueryTextId, R_SENDUI_DRM_FORWARDLOCKED_CONTENT_QUERY );
       
   253         }
       
   254 
       
   255     return ETrue;
       
   256     }
       
   257 
       
   258 // -----------------------------------------------------------------------------
       
   259 // CSendUiFileRightsEngine::CalculateTotalSizeOfFiles
       
   260 // -----------------------------------------------------------------------------
       
   261 //
       
   262 EXPORT_C TInt CSendUiFileRightsEngine::CalculateTotalSizeOfFiles(
       
   263     CArrayPtrFlat<CSendUiAttachment>* aAttachments,
       
   264     TBool aLinksSupported )
       
   265 {
       
   266 	if ( !aAttachments )
       
   267 		{
       
   268 		return 0;
       
   269 		}
       
   270     TUint totalSize = 0;
       
   271   
       
   272     TInt index = 0;
       
   273     for ( index = 0; index < aAttachments->Count(); index++ )
       
   274         {
       
   275         CSendUiAttachment& attachment = *(aAttachments->At(index));
       
   276         
       
   277         if ( attachment.Type() == CSendUiAttachment::EAttachmentHandle )
       
   278         	{
       
   279         	totalSize += attachment.Size();
       
   280         	}
       
   281     	else
       
   282     		{
       
   283     		if ( !aLinksSupported )
       
   284     			{
       
   285 	    		totalSize += attachment.Size();
       
   286     			}
       
   287     		}
       
   288         
       
   289         }
       
   290     return totalSize;
       
   291 }
       
   292 
       
   293 // -----------------------------------------------------------------------------
       
   294 // CSendUiFileRightsEngine::ClearValidationCounters
       
   295 // -----------------------------------------------------------------------------
       
   296 //
       
   297 EXPORT_C void CSendUiFileRightsEngine::ClearValidationCounters()
       
   298     {
       
   299     TInt index = 0;
       
   300     // Go through the lists
       
   301     for( index = 0; index < ESenduiIndexLastResult; index++ )
       
   302         {
       
   303         iValidationResults[index] = 0;
       
   304         }
       
   305 
       
   306     for( index = 0; index < ESenduiIndexLastInvalid; index++ )
       
   307         {
       
   308         iInvalidationReason[index] = 0;
       
   309         }
       
   310     }
       
   311 
       
   312 // -----------------------------------------------------------------------------
       
   313 // CSendUiFileRightsEngine::AnalyzeMmsValidationResult
       
   314 // -----------------------------------------------------------------------------
       
   315 // 
       
   316 TBool CSendUiFileRightsEngine::AnalyzeMmsValidationResultL( CSendUiAttachment& aAttachment, TInt& aAttachmentsSize )
       
   317     {
       
   318     TBool attachmentInvalid = ETrue;
       
   319     
       
   320     RImplInfoPtrArray implArray;
       
   321     CleanupStack::PushL( TCleanupItem( CleanupImplArray, &implArray ) );
       
   322     CVideoConversionPlugin::ListImplementationsL( implArray );
       
   323     
       
   324     if ( aAttachment.MimeType() == KMsgMimeVideoMp4 && implArray.Count() != 0 )
       
   325         {
       
   326         attachmentInvalid = EFalse;
       
   327         }
       
   328     else if ( !iMmsConformance->CreationMode() &&
       
   329          !iMmsConformance->IsConformantMime( aAttachment.MimeType() ) )
       
   330         {
       
   331         // Restricted mode and non-conformant MIME
       
   332         iInvalidationReason[ESenduiIndexMmsNotSupported]++;
       
   333         }
       
   334     else if ( aAttachmentsSize + aAttachment.Size() > iMmsConformance->MaxSendSize() &&
       
   335               iMediaResolver->MediaType( aAttachment.MimeType() ) != EMsgMediaImage )
       
   336         {
       
   337         iInvalidationReason[ESenduiIndexMmsTooBig]++;
       
   338         }
       
   339     else
       
   340         {
       
   341         attachmentInvalid = EFalse;
       
   342         }
       
   343 
       
   344 	if ( !attachmentInvalid
       
   345 			&& iMediaResolver->MediaType( aAttachment.MimeType() ) != EMsgMediaImage )
       
   346 	    {
       
   347 	    aAttachmentsSize += aAttachment.Size();
       
   348 	    }
       
   349     
       
   350     CleanupStack::PopAndDestroy( );    //implArray
       
   351     return attachmentInvalid;
       
   352     }
       
   353 
       
   354 // -----------------------------------------------------------------------------
       
   355 // CSendUiFileRightsEngine::ResolveErrorNoteL
       
   356 // -----------------------------------------------------------------------------
       
   357 //
       
   358 void CSendUiFileRightsEngine::ResolveErrorNoteL(
       
   359     TUid                    aServiceId,
       
   360     TUint&                  aResourceId,
       
   361     TFREErrorNoteType&      aNoteType,
       
   362     TUint&                  aValueForNote )
       
   363     {
       
   364     TInt i = 0;
       
   365     TInt errorTypeCount = 0;
       
   366     TUint errorType = 0;
       
   367     TUint totalFileCount = iValidationResults[ESenduiIndexTotalCount];
       
   368     TUint deletedFiles = iValidationResults[ESenduiIndexDeleted];
       
   369 
       
   370     // Own notes for MMS direct upload
       
   371     if ( aServiceId == KMmsDirectUpload )
       
   372         {
       
   373         ResolveMmsUploadErrorNoteL(
       
   374             aResourceId, aNoteType, aValueForNote );
       
   375         return;
       
   376         }
       
   377 
       
   378     // Count amount of different error types, if different errors exists
       
   379     // general error note is shown.
       
   380     for( i = 0; i < ESenduiIndexLastInvalid; i++ )
       
   381         {
       
   382         if ( iInvalidationReason[i] > 0 )
       
   383             {
       
   384             errorType = i;
       
   385             errorTypeCount++;
       
   386             }
       
   387         }
       
   388 
       
   389     if ( errorTypeCount == 0 )
       
   390         { // Should never end up here.
       
   391         aResourceId = R_SENDUI_MME_NONE_CANNOT_INS;
       
   392         return;
       
   393         }
       
   394     else if ( errorTypeCount == 1 )
       
   395         {  
       
   396         switch ( errorType )
       
   397             {
       
   398             case ESenduiIndexDrmFLOrCCL:
       
   399                 {
       
   400                 TUint protectedFiles = iInvalidationReason[ ESenduiIndexDrmFLOrCCL ];
       
   401 
       
   402                 if ( deletedFiles < totalFileCount )
       
   403                     { // Some files are protected
       
   404                     aResourceId = R_SENDUI_DRM_SEND_FORBID_SOME;
       
   405                     }
       
   406                 else
       
   407                     { // All files are protected
       
   408                     if ( protectedFiles == 1 )
       
   409                         { // One protected file
       
   410                         aResourceId = R_SENDUI_DRM_SEND_FORBID_ONE;
       
   411                         }
       
   412                     else
       
   413                         { // Many protected files
       
   414                         aResourceId = R_SENDUI_DRM_ALL_FILES_DELETED;
       
   415                         }
       
   416                     }
       
   417                 }            
       
   418                 break;
       
   419             case ESenduiIndexAlreadyInUse:
       
   420                 {
       
   421                 if ( deletedFiles == totalFileCount )
       
   422                     { // All files are in use
       
   423                     User::Leave( KErrInUse );
       
   424                     }
       
   425                 else
       
   426                     { // Some files are in use
       
   427                     aResourceId = R_SENDUI_MME_SOME_INSERTED;
       
   428                     }
       
   429                 }
       
   430                 break;
       
   431             case ESenduiIndexMmsTooBig:
       
   432                 {
       
   433                 if ( deletedFiles == totalFileCount )
       
   434                     { // All files are too big
       
   435                     aResourceId = R_SENDUI_MME_ONE_TOO_BIG;
       
   436                     }
       
   437                 else
       
   438                     { // Some files are too big
       
   439                     aResourceId = R_SENDUI_MME_MANY_TOO_BIG;
       
   440                     }
       
   441 
       
   442                 aNoteType = EConfirmationQuery;
       
   443                 aValueForNote = iMmsConformance->MaxSendSize();
       
   444                 aValueForNote /= KFREKiloByte ;
       
   445                 }
       
   446                 break;
       
   447             case ESenduiIndexMmsNotSupported:
       
   448                 {
       
   449                 // Different notes when creation mode is locked
       
   450                 if ( iMmsConformance->CreationModeUserChangeable() &&
       
   451                      !iMmsConformance->CreationMode() )
       
   452                     {
       
   453                     if ( deletedFiles == totalFileCount )
       
   454                         { // All files are not supported
       
   455                         aResourceId = deletedFiles > 1 ?
       
   456                             R_SENDUI_MME_RMODE_FILES_NOT_SUPPORTED :
       
   457                             R_SENDUI_MME_RMODE_FILE_NOT_SUPPORTED;
       
   458                         }
       
   459                     else
       
   460                         { // Some files are not supported
       
   461                         aResourceId = R_SENDUI_MME_RMODE_SOME_NOT_SUPPORTED;
       
   462                         }
       
   463                     }
       
   464                 else
       
   465                     {
       
   466                     if ( deletedFiles == totalFileCount )
       
   467                         { // All files are not supported
       
   468                         aResourceId = deletedFiles > 1 ?
       
   469                             R_SENDUI_MME_FILES_NOT_SUPPORTED :
       
   470                             R_SENDUI_MME_FILE_NOT_SUPPORTED;
       
   471                         }
       
   472                     else
       
   473                         { // Some files are not supported
       
   474                         aResourceId = R_SENDUI_MME_SOME_FILES_DELETED;
       
   475                         }
       
   476                     }
       
   477                 }
       
   478                 break;
       
   479             case ESenduiIndexBadHandle:
       
   480             default:
       
   481                 {
       
   482                 aResourceId = R_SENDUI_MME_NONE_CANNOT_INS;
       
   483                 }
       
   484                 break;
       
   485             }
       
   486         }
       
   487     else // Different kind of errors exist, show general error note
       
   488         {
       
   489         if ( totalFileCount == deletedFiles )
       
   490             { // Can't send any file
       
   491             aResourceId = R_SENDUI_MME_NONE_CANNOT_INS;
       
   492             }
       
   493         else
       
   494             { // Some files can be send
       
   495             aResourceId = R_SENDUI_MME_SOME_INSERTED;
       
   496             }
       
   497         }
       
   498     }
       
   499 
       
   500 // -----------------------------------------------------------------------------
       
   501 // CSendUiFileRightsEngine::ResolveMmsUploadErrorNoteL
       
   502 // -----------------------------------------------------------------------------
       
   503 //
       
   504 void CSendUiFileRightsEngine::ResolveMmsUploadErrorNoteL(
       
   505     TUint&                      aResourceId,
       
   506     TFREErrorNoteType&          aNoteType,
       
   507     TUint&                      aValueForNote )
       
   508     {
       
   509     TInt i = 0;
       
   510     TInt errorTypeCount = 0;
       
   511     TUint errorType = 0;
       
   512     TUint totalFileCount = iValidationResults[ESenduiIndexTotalCount];
       
   513     TUint deletedFiles = iValidationResults[ESenduiIndexDeleted];
       
   514 
       
   515     // Count amount of different error types, if different errors exists
       
   516     // general error note is shown.
       
   517     for( i = 0; i < ESenduiIndexLastInvalid; i++ )
       
   518         {
       
   519         if ( iInvalidationReason[i] > 0 )
       
   520             {
       
   521             errorType = i;
       
   522             errorTypeCount++;
       
   523             }
       
   524         }
       
   525 
       
   526     if ( errorTypeCount == 0 )
       
   527         { // Should never end up here.
       
   528         return;
       
   529         }
       
   530     else if ( errorTypeCount == 1 )
       
   531         {  
       
   532         switch ( errorType )
       
   533             {
       
   534             case ESenduiIndexDrmFLOrCCL:
       
   535                 {
       
   536                 TUint protectedFiles = iInvalidationReason[ ESenduiIndexDrmFLOrCCL ];
       
   537 
       
   538                 if ( deletedFiles < totalFileCount )
       
   539                     { // Some files are protected
       
   540                     aResourceId = R_SENDUI_DRM_SEND_FORBID_SOME;
       
   541                     }
       
   542                 else
       
   543                     { // All files are protected
       
   544                     if ( protectedFiles == 1 )
       
   545                         { // One protected file
       
   546                         aResourceId = R_SENDUI_DRM_SEND_FORBID_ONE;
       
   547                         }
       
   548                     else
       
   549                         { // Many protected files
       
   550                         aResourceId = R_SENDUI_DRM_ALL_FILES_DELETED;
       
   551                         }
       
   552                     }
       
   553                 }
       
   554                 break;
       
   555             case ESenduiIndexAlreadyInUse:
       
   556                 {
       
   557                 if ( deletedFiles == totalFileCount )
       
   558                     { // All files are in use
       
   559                     User::Leave( KErrInUse );
       
   560                     }
       
   561                 else
       
   562                     { // Some files are in use
       
   563                     aResourceId = R_SENDUI_MMS_UPLOAD_SOME_FILES_DELETED;
       
   564                     }
       
   565                 }
       
   566                 break;
       
   567             case ESenduiIndexMmsTooBig:
       
   568                 {
       
   569                 aResourceId = deletedFiles > 1 ?
       
   570                     R_SENDUI_MMS_UPLOAD_MANY_TOO_BIG : 
       
   571                     R_SENDUI_MMS_UPLOAD_ONE_TOO_BIG;
       
   572 
       
   573                 aNoteType = EConfirmationQuery;
       
   574                 aValueForNote = iMmsConformance->MaxSendSize();
       
   575                 aValueForNote /= KFREKiloByte ;
       
   576                 }
       
   577                 break;
       
   578             case ESenduiIndexMmsNotSupported:
       
   579             default:
       
   580                 {
       
   581                 if ( deletedFiles == totalFileCount )
       
   582                     { // All files are not supported
       
   583                     aResourceId = deletedFiles > 1 ?
       
   584                         R_SENDUI_MMS_UPLOAD_FILES_NOT_SUPPORTED :
       
   585                         R_SENDUI_MMS_UPLOAD_FILE_NOT_SUPPORTED;
       
   586                     }
       
   587                 else
       
   588                     { // Some files are not supported
       
   589                     aResourceId = R_SENDUI_MMS_UPLOAD_SOME_FILES_DELETED;
       
   590                     }
       
   591                 }
       
   592                 break;
       
   593             }
       
   594         }
       
   595     else // Different kind of errors exist, show general error note
       
   596         {
       
   597         if ( totalFileCount == deletedFiles )
       
   598             { // Can't send any file
       
   599             aResourceId = R_SENDUI_MMS_UPLOAD_NONE_CANNOT_INS;
       
   600             }
       
   601         else
       
   602             { // Some files can be send
       
   603             aResourceId = R_SENDUI_MMS_UPLOAD_SOME_INSERTED;
       
   604             }
       
   605         }   
       
   606     }
       
   607 
       
   608 // -----------------------------------------------------------------------------
       
   609 // CSendUiFileRightsEngine::ResolveDrmQuery
       
   610 // -----------------------------------------------------------------------------
       
   611 //
       
   612 void CSendUiFileRightsEngine::ResolveDrmQuery(
       
   613     TUid        aServiceId,
       
   614     TUint&      aResourceId )
       
   615     {
       
   616     TUint totalFileCount = iValidationResults[ESenduiIndexTotalCount];
       
   617     TUint drmProtectedFiles = iInvalidationReason[ ESenduiIndexDrmFLOrCCL ];
       
   618     TUint drmSdFiles = iValidationResults[ ESenduiIndexDrmSD ];
       
   619     TUint unprotectedFiles = totalFileCount - drmProtectedFiles - drmSdFiles;
       
   620     
       
   621     if ( unprotectedFiles > 0 )
       
   622         { // Some DRM SD protected files and unprotected files
       
   623         // Different query for direct MMS upload service
       
   624         if ( aServiceId == KMmsDirectUpload )
       
   625             {
       
   626             aResourceId = R_SENDUI_MMS_UPLOAD_DRM_SOME_SD;
       
   627             }
       
   628         else
       
   629             {
       
   630             aResourceId = R_SENDUI_DRM_SEVERAL_DISTRUTABLE;
       
   631             }
       
   632         }
       
   633     else
       
   634         { // Only DRM protected files
       
   635         // Different query for direct MMS upload service
       
   636         if ( aServiceId == KMmsDirectUpload || 
       
   637              aServiceId == KMmsIndirectUpload )
       
   638             {
       
   639             aResourceId = drmSdFiles > 1 ? 
       
   640                 R_SENDUI_MMS_UPLOAD_DRM_MANY_SD : 
       
   641                 R_SENDUI_MMS_UPLOAD_DRM_ONE_SD;
       
   642             }
       
   643         else
       
   644             {
       
   645             aResourceId = drmSdFiles > 1 ? 
       
   646                 R_SENDUI_DRM_MANY_SD_ITEMS : 
       
   647                 R_SENDUI_DRM_SINGLE_DISTRUTABLE;
       
   648             }
       
   649         }
       
   650     }
       
   651 
       
   652 // -----------------------------------------------------------------------------
       
   653 // CSendUiFileRightsEngine::ShowErrorNotificationL
       
   654 // -----------------------------------------------------------------------------
       
   655 //
       
   656 void CSendUiFileRightsEngine::ShowErrorNotificationL(
       
   657     TUint                   aResourceId,
       
   658     TFREErrorNoteType       aErrorNoteType, 
       
   659     TUint                   aValueForNote ) const
       
   660     {
       
   661     switch ( aErrorNoteType )
       
   662         {
       
   663         case EErrorNote:
       
   664             {
       
   665             ShowErrorNoteL( aResourceId );
       
   666             break;
       
   667             }
       
   668         case EInformationNote:
       
   669             {
       
   670             ShowInformationNoteL( aResourceId );
       
   671             break;
       
   672             }
       
   673         case EConfirmationQuery:
       
   674             {
       
   675             ShowConfirmationQueryL(
       
   676                 aResourceId,
       
   677                 R_SENDUI_CONFIRMABLE_INFO,
       
   678                 aValueForNote );
       
   679             break;
       
   680             }
       
   681         default: // Shouldn't end up here
       
   682             break;
       
   683         }
       
   684     }
       
   685 
       
   686 // -----------------------------------------------------------------------------
       
   687 // CSendUiFileRightsEngine::ShowErrorNoteL
       
   688 // -----------------------------------------------------------------------------
       
   689 //
       
   690 void CSendUiFileRightsEngine::ShowErrorNoteL( TUint aTextResourceId ) const
       
   691     {
       
   692     // Get text to be shown
       
   693     HBufC* text = StringLoader::LoadLC( aTextResourceId );
       
   694 
       
   695     // Create the note and show it
       
   696     CAknErrorNote* note = new (ELeave) CAknErrorNote(ETrue);
       
   697     note->ExecuteLD( text->Des() );
       
   698 
       
   699     CleanupStack::PopAndDestroy( text ); // text
       
   700     }
       
   701 
       
   702 // -----------------------------------------------------------------------------
       
   703 // CSendUiFileRightsEngine::ShowConfirmationQueryL
       
   704 // -----------------------------------------------------------------------------
       
   705 //
       
   706 TBool CSendUiFileRightsEngine::ShowConfirmationQueryL( 
       
   707     TUint    aTextResourceId,
       
   708     TUint    aNoteResourceId,
       
   709     TUint    aValueForNote ) const
       
   710     {
       
   711     HBufC* text = NULL;
       
   712     
       
   713     if ( aValueForNote == 0 )
       
   714         {
       
   715         text = StringLoader::LoadLC( aTextResourceId );
       
   716         }
       
   717     else
       
   718         {
       
   719         text = StringLoader::LoadLC( aTextResourceId, aValueForNote );
       
   720         }
       
   721 
       
   722     CAknQueryDialog* dlg = CAknQueryDialog::NewL();
       
   723 
       
   724     TInt result = dlg->ExecuteLD( aNoteResourceId, *text );
       
   725     
       
   726     CleanupStack::PopAndDestroy( text );
       
   727 
       
   728     // ETrue, if Yes or Selection key were pressed
       
   729     // Otherwise EFalse
       
   730     return result; 
       
   731     }
       
   732 
       
   733 // -----------------------------------------------------------------------------
       
   734 // CSendUiFileRightsEngine::ShowInformationNoteL
       
   735 // -----------------------------------------------------------------------------
       
   736 //
       
   737 EXPORT_C void CSendUiFileRightsEngine::ShowInformationNoteL(
       
   738     TUint aTextResourceId ) const
       
   739     {
       
   740     // Get text to be shown
       
   741     HBufC* text = StringLoader::LoadLC( aTextResourceId );
       
   742 
       
   743     // Create the note and show it
       
   744     CAknInformationNote* note = new (ELeave) CAknInformationNote( ETrue );
       
   745     note->ExecuteLD( text->Des() );    
       
   746 
       
   747     CleanupStack::PopAndDestroy( text ); // text
       
   748     }
       
   749 
       
   750 // -----------------------------------------------------------------------------
       
   751 // CSendUiFileRightsEngine::CleanupImplArray
       
   752 // -----------------------------------------------------------------------------
       
   753 //
       
   754 void CSendUiFileRightsEngine::CleanupImplArray( TAny* aAny )
       
   755     {
       
   756     RImplInfoPtrArray* implArray = 
       
   757         reinterpret_cast<RImplInfoPtrArray*>( aAny );
       
   758     implArray->ResetAndDestroy();
       
   759     implArray->Close();
       
   760     }
       
   761 
       
   762 
       
   763 //  End of File