|
1 /* |
|
2 * Copyright (c) 2006 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: DRM Verifier for slide set image sets. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "pslnslidesetdrmverifier.h" |
|
21 #include <pslnslidesetdialogrsc.rsg> |
|
22 #include <pslnslidesetdialoginterface.h> |
|
23 |
|
24 #include <DRMHelper.h> |
|
25 #include <aknnotewrappers.h> |
|
26 #include <StringLoader.h> |
|
27 |
|
28 const TInt KPslnDrmVerifyLimit = 50; |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // C++ constructor can NOT contain any code, that might leave. |
|
33 // ----------------------------------------------------------------------------- |
|
34 // |
|
35 CPslnSlideSetDRMVerifier::CPslnSlideSetDRMVerifier( TInt aType ) |
|
36 : iType ( aType ) |
|
37 { |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // Symbian 2nd phase constructor can leave. |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 void CPslnSlideSetDRMVerifier::ConstructL() |
|
45 { |
|
46 iDRMHelper = CDRMHelper::NewL( *CCoeEnv::Static() ); |
|
47 } |
|
48 |
|
49 // ----------------------------------------------------------------------------- |
|
50 // Two-phased constructor. |
|
51 // ----------------------------------------------------------------------------- |
|
52 // |
|
53 CPslnSlideSetDRMVerifier* CPslnSlideSetDRMVerifier::NewL( TInt aType ) |
|
54 { |
|
55 CPslnSlideSetDRMVerifier* self = |
|
56 new( ELeave ) CPslnSlideSetDRMVerifier( aType ); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL(); |
|
59 CleanupStack::Pop( self ); |
|
60 return self; |
|
61 } |
|
62 |
|
63 // ----------------------------------------------------------------------------- |
|
64 // Destructor. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CPslnSlideSetDRMVerifier::~CPslnSlideSetDRMVerifier() |
|
68 { |
|
69 delete iDRMHelper; |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // Verifies user selected images. Used by MGFetch. |
|
74 // ----------------------------------------------------------------------------- |
|
75 // |
|
76 TBool CPslnSlideSetDRMVerifier::VerifySelectionL( const MDesCArray* aSelectedFiles ) |
|
77 { |
|
78 if ( aSelectedFiles ) |
|
79 { |
|
80 if( aSelectedFiles->MdcaCount() < 1 ) |
|
81 { |
|
82 // Download item |
|
83 return ETrue; |
|
84 } |
|
85 } |
|
86 else |
|
87 { |
|
88 // no aSelectedFiles. |
|
89 return EFalse; |
|
90 } |
|
91 |
|
92 TInt res = KErrNone; |
|
93 TBool canBeAutomated = EFalse; |
|
94 if ( iDRMHelper ) |
|
95 { |
|
96 if ( iType == EPslnWallpaperDialog ) |
|
97 { |
|
98 res = iDRMHelper->SetAutomatedType( |
|
99 CDRMHelper::EAutomatedTypeWallpaper ); |
|
100 } |
|
101 else |
|
102 { |
|
103 res = iDRMHelper->SetAutomatedType( |
|
104 CDRMHelper::EAutomatedTypeScreenSaver ); |
|
105 } |
|
106 if ( res != KErrNone ) |
|
107 { |
|
108 ShowErrorNoteL( R_PSLN_SLIDE_SET_DRM_ERROR ); |
|
109 } |
|
110 else |
|
111 { |
|
112 // Go through the selected files. |
|
113 TInt fileCount = aSelectedFiles->MdcaCount() - 1; |
|
114 if ( fileCount > KPslnDrmVerifyLimit ) |
|
115 { |
|
116 fileCount = KPslnDrmVerifyLimit; |
|
117 } |
|
118 for ( TInt index = fileCount; index >= 0; index-- ) |
|
119 { |
|
120 // First check DRM issues. |
|
121 res = iDRMHelper->CanSetAutomated( |
|
122 aSelectedFiles->MdcaPoint( index ), |
|
123 canBeAutomated ); |
|
124 if ( res == KErrNone && !canBeAutomated ) |
|
125 { |
|
126 ShowErrorNoteL( R_PSLN_SLIDE_SET_DRM_ERROR ); |
|
127 return EFalse; |
|
128 } |
|
129 else if ( res != KErrNone ) |
|
130 { |
|
131 if ( res == KErrUnderflow ) |
|
132 { |
|
133 // Do not show error note for corrupted image and let it pass. |
|
134 canBeAutomated = ETrue; |
|
135 } |
|
136 else |
|
137 { |
|
138 iDRMHelper->HandleErrorL( res, |
|
139 aSelectedFiles->MdcaPoint( index ) ); |
|
140 return EFalse; |
|
141 } |
|
142 } |
|
143 else |
|
144 { |
|
145 // Empty. |
|
146 } |
|
147 } |
|
148 } |
|
149 } |
|
150 return canBeAutomated; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // Shows error note. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CPslnSlideSetDRMVerifier::ShowErrorNoteL( TInt aResourceId ) const |
|
158 { |
|
159 HBufC* errorText = StringLoader::LoadLC( aResourceId ); |
|
160 CAknInformationNote* note = new( ELeave ) CAknInformationNote( EFalse ); |
|
161 note->ExecuteLD( *errorText ); |
|
162 CleanupStack::PopAndDestroy( errorText ); |
|
163 } |
|
164 |
|
165 // End of file |
|
166 |