--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/psln/pslnslidesetdialog/src/pslnslidesetdrmverifier.cpp Wed Sep 01 12:16:19 2010 +0100
@@ -0,0 +1,166 @@
+/*
+* Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies).
+* All rights reserved.
+* This component and the accompanying materials are made available
+* under the terms of "Eclipse Public License v1.0"
+* which accompanies this distribution, and is available
+* at the URL "http://www.eclipse.org/legal/epl-v10.html".
+*
+* Initial Contributors:
+* Nokia Corporation - initial contribution.
+*
+* Contributors:
+*
+* Description: DRM Verifier for slide set image sets.
+*
+*/
+
+
+// INCLUDE FILES
+#include "pslnslidesetdrmverifier.h"
+#include <pslnslidesetdialogrsc.rsg>
+#include <pslnslidesetdialoginterface.h>
+
+#include <DRMHelper.h>
+#include <aknnotewrappers.h>
+#include <StringLoader.h>
+
+const TInt KPslnDrmVerifyLimit = 50;
+// ============================ MEMBER FUNCTIONS ===============================
+
+// -----------------------------------------------------------------------------
+// C++ constructor can NOT contain any code, that might leave.
+// -----------------------------------------------------------------------------
+//
+CPslnSlideSetDRMVerifier::CPslnSlideSetDRMVerifier( TInt aType )
+ : iType ( aType )
+ {
+ }
+
+// -----------------------------------------------------------------------------
+// Symbian 2nd phase constructor can leave.
+// -----------------------------------------------------------------------------
+//
+void CPslnSlideSetDRMVerifier::ConstructL()
+ {
+ iDRMHelper = CDRMHelper::NewL( *CCoeEnv::Static() );
+ }
+
+// -----------------------------------------------------------------------------
+// Two-phased constructor.
+// -----------------------------------------------------------------------------
+//
+CPslnSlideSetDRMVerifier* CPslnSlideSetDRMVerifier::NewL( TInt aType )
+ {
+ CPslnSlideSetDRMVerifier* self =
+ new( ELeave ) CPslnSlideSetDRMVerifier( aType );
+ CleanupStack::PushL( self );
+ self->ConstructL();
+ CleanupStack::Pop( self );
+ return self;
+ }
+
+// -----------------------------------------------------------------------------
+// Destructor.
+// -----------------------------------------------------------------------------
+//
+CPslnSlideSetDRMVerifier::~CPslnSlideSetDRMVerifier()
+ {
+ delete iDRMHelper;
+ }
+
+// -----------------------------------------------------------------------------
+// Verifies user selected images. Used by MGFetch.
+// -----------------------------------------------------------------------------
+//
+TBool CPslnSlideSetDRMVerifier::VerifySelectionL( const MDesCArray* aSelectedFiles )
+ {
+ if ( aSelectedFiles )
+ {
+ if( aSelectedFiles->MdcaCount() < 1 )
+ {
+ // Download item
+ return ETrue;
+ }
+ }
+ else
+ {
+ // no aSelectedFiles.
+ return EFalse;
+ }
+
+ TInt res = KErrNone;
+ TBool canBeAutomated = EFalse;
+ if ( iDRMHelper )
+ {
+ if ( iType == EPslnWallpaperDialog )
+ {
+ res = iDRMHelper->SetAutomatedType(
+ CDRMHelper::EAutomatedTypeWallpaper );
+ }
+ else
+ {
+ res = iDRMHelper->SetAutomatedType(
+ CDRMHelper::EAutomatedTypeScreenSaver );
+ }
+ if ( res != KErrNone )
+ {
+ ShowErrorNoteL( R_PSLN_SLIDE_SET_DRM_ERROR );
+ }
+ else
+ {
+ // Go through the selected files.
+ TInt fileCount = aSelectedFiles->MdcaCount() - 1;
+ if ( fileCount > KPslnDrmVerifyLimit )
+ {
+ fileCount = KPslnDrmVerifyLimit;
+ }
+ for ( TInt index = fileCount; index >= 0; index-- )
+ {
+ // First check DRM issues.
+ res = iDRMHelper->CanSetAutomated(
+ aSelectedFiles->MdcaPoint( index ),
+ canBeAutomated );
+ if ( res == KErrNone && !canBeAutomated )
+ {
+ ShowErrorNoteL( R_PSLN_SLIDE_SET_DRM_ERROR );
+ return EFalse;
+ }
+ else if ( res != KErrNone )
+ {
+ if ( res == KErrUnderflow )
+ {
+ // Do not show error note for corrupted image and let it pass.
+ canBeAutomated = ETrue;
+ }
+ else
+ {
+ iDRMHelper->HandleErrorL( res,
+ aSelectedFiles->MdcaPoint( index ) );
+ return EFalse;
+ }
+ }
+ else
+ {
+ // Empty.
+ }
+ }
+ }
+ }
+ return canBeAutomated;
+ }
+
+// -----------------------------------------------------------------------------
+// Shows error note.
+// -----------------------------------------------------------------------------
+//
+void CPslnSlideSetDRMVerifier::ShowErrorNoteL( TInt aResourceId ) const
+ {
+ HBufC* errorText = StringLoader::LoadLC( aResourceId );
+ CAknInformationNote* note = new( ELeave ) CAknInformationNote( EFalse );
+ note->ExecuteLD( *errorText );
+ CleanupStack::PopAndDestroy( errorText );
+ }
+
+// End of file
+