psln/Src/PslnDRMImplementation.cpp
changeset 37 89c890c70182
parent 34 6b5204869ed5
child 45 667edd0b8678
equal deleted inserted replaced
34:6b5204869ed5 37:89c890c70182
     1 /*
       
     2 * Copyright (c) 2004-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:  Utility class that verifies content's that it is in accordance 
       
    15 *                with DRM.
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 // INCLUDE FILES
       
    21 #include <DRMHelper.h>
       
    22 #include <aknnotewrappers.h>
       
    23 #include <StringLoader.h>
       
    24 #include <psln.rsg>
       
    25 
       
    26 #include "PslnDRMImplementation.h"
       
    27 
       
    28 // ============================ MEMBER FUNCTIONS ===============================
       
    29 
       
    30 // -----------------------------------------------------------------------------
       
    31 // C++ default constructor can NOT contain any code, that might leave.
       
    32 // -----------------------------------------------------------------------------
       
    33 //
       
    34 CPslnDRMImplementation::CPslnDRMImplementation()
       
    35     {
       
    36     }
       
    37 
       
    38 // -----------------------------------------------------------------------------
       
    39 // Symbian 2nd phase constructor can leave.
       
    40 // -----------------------------------------------------------------------------
       
    41 //
       
    42 void CPslnDRMImplementation::ConstructL()
       
    43     {
       
    44     iDRMHelper = CDRMHelper::NewL(*CCoeEnv::Static());
       
    45     }
       
    46 
       
    47 // -----------------------------------------------------------------------------
       
    48 // Two-phased constructor.
       
    49 // -----------------------------------------------------------------------------
       
    50 //
       
    51 CPslnDRMImplementation* CPslnDRMImplementation::NewL()
       
    52     {
       
    53     CPslnDRMImplementation* self = new(ELeave) CPslnDRMImplementation();
       
    54     CleanupStack::PushL( self );
       
    55     self->ConstructL();
       
    56     CleanupStack::Pop( self );
       
    57     return self;
       
    58     }
       
    59 
       
    60 // -----------------------------------------------------------------------------
       
    61 // Destructor.
       
    62 // -----------------------------------------------------------------------------
       
    63 //
       
    64 CPslnDRMImplementation::~CPslnDRMImplementation()
       
    65     {
       
    66     delete iDRMHelper;
       
    67     }
       
    68 
       
    69 // -----------------------------------------------------------------------------
       
    70 // CPslnDRMImplementation::VerifySelectionL
       
    71 // -----------------------------------------------------------------------------
       
    72 //
       
    73 TBool CPslnDRMImplementation::VerifySelectionL(const MDesCArray* aSelectedFiles)
       
    74     {
       
    75     if(!aSelectedFiles)
       
    76     	{
       
    77     	User::Leave(KErrArgument);    	
       
    78     	}
       
    79     
       
    80     if(aSelectedFiles->MdcaCount() == 0)
       
    81         {
       
    82         return ETrue;
       
    83         }
       
    84 
       
    85     User::LeaveIfError(iDRMHelper->SetAutomatedType(CDRMHelper::EAutomatedTypeWallpaper));
       
    86 
       
    87     TBool canBeAutomated = EFalse;
       
    88     TInt error = iDRMHelper->CanSetAutomated(aSelectedFiles->MdcaPoint(0), canBeAutomated);
       
    89     
       
    90     if(error == KErrNone)
       
    91     	{
       
    92     	if(!canBeAutomated)
       
    93     		{
       
    94 		    ShowErrorNoteL( R_PSLN_QTN_DRM_PREV_RIGHTS_SET );
       
    95     		}
       
    96     		
       
    97     	return canBeAutomated;
       
    98     	}
       
    99     else if( error == KErrUnderflow )
       
   100         {
       
   101         ShowErrorNoteL( R_PSLN_IMAGE_CORRUPTED );
       
   102         }
       
   103     else if ( ( error != KErrNone ) || !canBeAutomated )
       
   104         {
       
   105         if ( iDRMHelper )
       
   106             {
       
   107             iDRMHelper->HandleErrorL(
       
   108                         error, 
       
   109                         aSelectedFiles->MdcaPoint( 0 ) );
       
   110             }
       
   111         }
       
   112 
       
   113     return EFalse;
       
   114     }
       
   115     
       
   116 // -----------------------------------------------------------------------------
       
   117 // CPslnDRMImplementation::ShowErrorNoteL
       
   118 // -----------------------------------------------------------------------------
       
   119 //
       
   120 void CPslnDRMImplementation::ShowErrorNoteL( TInt  aResourceId  ) 
       
   121     {
       
   122     HBufC* errorText = StringLoader::LoadLC(aResourceId);
       
   123     CAknInformationNote* note = new(ELeave) CAknInformationNote(EFalse);
       
   124     note->ExecuteLD(*errorText);
       
   125     CleanupStack::PopAndDestroy(errorText);
       
   126     }
       
   127 // End of File