messagingapp/msgui/unifiededitor/src/mmsinsertcheckoperation.cpp
changeset 25 84d9eb65b26f
parent 23 238255e8b033
child 27 e4592d119491
child 37 518b245aa84c
child 79 2981cb3aa489
equal deleted inserted replaced
23:238255e8b033 25:84d9eb65b26f
     1 /*
       
     2  * Copyright (c) 2009 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: mms creation mode checks
       
    15  *
       
    16  */
       
    17 
       
    18 
       
    19 #include "mmsinsertcheckoperation.h"
       
    20 
       
    21 #include <MmsConformance.h>
       
    22 #include <centralrepository.h>
       
    23 #include <mmsconst.h>
       
    24 #include <msgmediainfo.h>
       
    25 #include <fileprotectionresolver.h>
       
    26 
       
    27 #include <MsgMediaResolver.h>
       
    28 #include <DRMHelper.h>
       
    29 #include <MmsEngineInternalCRKeys.h>
       
    30 #include <hbmessagebox.h>
       
    31 
       
    32 #include "s60qconversions.h"
       
    33 #include "debugtraces.h"
       
    34 
       
    35 //DEFINES
       
    36 #define RMODE_INSERT_ERROR hbTrId("Unable to insert. Object format not supported in restricted creation mode.")
       
    37 #define INSERT_ERROR hbTrId("Unable to insert. Object format not supported.")
       
    38 #define INSERT_QUERY_CONFRM hbTrId("The receiving phone may not support this object. Continue?")
       
    39 // -----------------------------------------------------------------------------
       
    40 // MmsInsertCheckOperation::MmsInsertCheckOperation
       
    41 // -----------------------------------------------------------------------------
       
    42 //
       
    43 MmsInsertCheckOperation::MmsInsertCheckOperation()
       
    44 {
       
    45     QDEBUG_WRITE("MmsInsertCheckOperation::MmsInsertCheckOperation start");
       
    46 
       
    47     CRepository* repository = CRepository::NewL(KCRUidMmsEngine);
       
    48     CleanupStack::PushL(repository);
       
    49     TInt creationMode = EMmsCreationModeRestricted;
       
    50     if (repository->Get(KMmsEngineCreationMode, creationMode) == KErrNone) {
       
    51         iCreationMode = creationMode;
       
    52     }
       
    53     CleanupStack::PopAndDestroy(repository);
       
    54 
       
    55     iMmsConformance = CMmsConformance::NewL();
       
    56     iMmsConformance->CheckCharacterSet(EFalse);
       
    57     iMediaResolver = CMsgMediaResolver::NewL();
       
    58     iMediaResolver->SetCharacterSetRecognition(EFalse);
       
    59     iDRMHelper = CDRMHelper::NewL();
       
    60 
       
    61     QDEBUG_WRITE("MmsInsertCheckOperation::MmsInsertCheckOperation end");
       
    62 }
       
    63 
       
    64 // -----------------------------------------------------------------------------
       
    65 // MmsInsertCheckOperation::~MmsInsertCheckOperation
       
    66 // -----------------------------------------------------------------------------
       
    67 //
       
    68 MmsInsertCheckOperation::~MmsInsertCheckOperation()
       
    69 {
       
    70     delete iMmsConformance;
       
    71     delete iMediaResolver;
       
    72     delete iDRMHelper;
       
    73 }
       
    74 
       
    75 // ---------------------------------------------------------
       
    76 // MmsInsertCheckOperation::CheckModeForInsertL
       
    77 // ---------------------------------------------------------
       
    78 //
       
    79 int MmsInsertCheckOperation::checkModeForInsert(const QString& file)
       
    80 {
       
    81     QDEBUG_WRITE("CheckModeForInsert::CheckModeForInsert start");
       
    82     HBufC* filePath = S60QConversions::qStringToS60Desc(file);
       
    83     if (filePath) {
       
    84         CleanupStack::PushL(filePath);
       
    85 
       
    86         RFile fileHandle = iMediaResolver->FileHandleL(*filePath);
       
    87         CleanupClosePushL(fileHandle);
       
    88 
       
    89         CMsgMediaInfo* info = iMediaResolver->CreateMediaInfoL(fileHandle);
       
    90         info->ParseInfoDetails(fileHandle, *iDRMHelper, *this);
       
    91         CleanupStack::PopAndDestroy(2);
       
    92 
       
    93         TMmsConformance conformance = iMmsConformance->MediaConformance(*info);
       
    94         TUint32 confStatus = conformance.iConfStatus;
       
    95 
       
    96         // In "free" mode user can insert images that are larger by dimensions than allowed by conformance
       
    97         if (iCreationMode != EMmsCreationModeRestricted) {
       
    98             TInt i = EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded | EMmsConfNokTooBig;
       
    99             TInt j = ~(EMmsConfNokFreeModeOnly | EMmsConfNokScalingNeeded | EMmsConfNokTooBig);
       
   100 
       
   101             // If user answers yes to Guided mode confirmation query he/she moves to free mode
       
   102             if ((confStatus & i) && !(confStatus & j)) {
       
   103                 if (iCreationMode == EMmsCreationModeFree || info->Protection()
       
   104                     & EFileProtSuperDistributable) {
       
   105                     // SuperDistribution not checked here
       
   106                     // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
       
   107                     confStatus &= ~EMmsConfNokFreeModeOnly;
       
   108                     confStatus &= ~EMmsConfNokScalingNeeded;
       
   109                 }
       
   110                 else if (launchEditorQuery()) {
       
   111                     // Query accepted.
       
   112                     // Mask "FreeModeOnly" and "ScalingNeeded" away in free mode
       
   113                     confStatus &= ~EMmsConfNokFreeModeOnly;
       
   114                     confStatus &= ~EMmsConfNokScalingNeeded;
       
   115                 }
       
   116                 else {
       
   117                     //query not accepted. Stop insertion.
       
   118                     return EInsertQueryAbort;
       
   119                 }
       
   120             }
       
   121         }
       
   122         else if (confStatus & EMmsConfNokDRM || confStatus & EMmsConfNokNotEnoughInfo || confStatus
       
   123             & EMmsConfNokNotSupported || confStatus & EMmsConfNokFreeModeOnly || confStatus
       
   124             & EMmsConfNokCorrupt) {
       
   125             // Sanity check
       
   126             // "Not conformant" assumed if check fails.     
       
   127             if (iCreationMode == EMmsCreationModeRestricted)
       
   128             HbMessageBox::launchInformationMessageBox(RMODE_INSERT_ERROR);
       
   129             else
       
   130             HbMessageBox::launchInformationMessageBox(INSERT_ERROR);
       
   131             
       
   132             return EInsertNotSupported;
       
   133         }
       
   134         delete info;
       
   135     }
       
   136     QDEBUG_WRITE("CheckModeForInsert::CheckModeForInsert end");
       
   137     return EInsertSuccess;
       
   138 }
       
   139 
       
   140 // ---------------------------------------------------------
       
   141 // MmsInsertCheckOperation::launchEditorQuery
       
   142 // ---------------------------------------------------------
       
   143 //
       
   144 bool MmsInsertCheckOperation::launchEditorQuery()
       
   145 {
       
   146     return HbMessageBox::launchQuestionMessageBox(INSERT_QUERY_CONFRM);
       
   147 }
       
   148 
       
   149 // -----------------------------------------------------------------------------
       
   150 // MmsInsertCheckOperation::MediaInfoParsed
       
   151 // -----------------------------------------------------------------------------
       
   152 //
       
   153 void MmsInsertCheckOperation::MediaInfoParsed()
       
   154 {
       
   155 }