|
1 /* |
|
2 * Copyright (c) 2008 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 the License "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: CMPPopupList.cpp* |
|
15 */ |
|
16 |
|
17 |
|
18 // Version : %version: 15 % |
|
19 |
|
20 #include <aknpopuplayout.h> |
|
21 #include <eiklbx.h> |
|
22 #include <MPFileDetails.rsg> |
|
23 #include "mppopuplist.h" |
|
24 #include "mpxvideo_debug.h" |
|
25 |
|
26 |
|
27 #include <drmuihandling.h> |
|
28 #include <drmutility.h> |
|
29 #include <drmerrorhandling.h> |
|
30 using namespace DRM; |
|
31 |
|
32 |
|
33 // ----------------------------------------------------------------------------- |
|
34 // CMPPopupList::NewL() |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CMPPopupList* CMPPopupList::NewL( CEikListBox* aListBox, |
|
38 const TDesC& aFilePath, |
|
39 TBool aDrmProtected, |
|
40 TBool aReadingDCFOnly ) |
|
41 { |
|
42 MPX_ENTER_EXIT(_L("CMPPopupList::NewL()")); |
|
43 |
|
44 CMPPopupList* self= new (ELeave) CMPPopupList(); |
|
45 CleanupStack::PushL(self); |
|
46 self->ConstructL( aListBox, aFilePath, aDrmProtected, aReadingDCFOnly ); |
|
47 CleanupStack::Pop(self); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CMPPopupList::NewL() |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 CMPPopupList* CMPPopupList::NewL( CEikListBox* aListBox, |
|
56 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
57 RFile64& aFile, |
|
58 #else |
|
59 RFile& aFile, |
|
60 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
61 TBool aDrmProtected, |
|
62 TBool aReadingDCFOnly ) |
|
63 { |
|
64 MPX_DEBUG(_L("CMPPopupList::NewL (%d)"),aDrmProtected); |
|
65 |
|
66 CMPPopupList* self= new (ELeave) CMPPopupList(); |
|
67 CleanupStack::PushL(self); |
|
68 self->ConstructL( aListBox, aFile, aDrmProtected, aReadingDCFOnly ); |
|
69 CleanupStack::Pop(self); |
|
70 return self; |
|
71 } |
|
72 |
|
73 // ----------------------------------------------------------------------------- |
|
74 // CMPPopupList::ConstructL() |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 void CMPPopupList::ConstructL( CEikListBox* aListBox, |
|
78 const TDesC& aFilePath, |
|
79 TBool aDrmProtected, |
|
80 TBool aReadingDCFOnly ) |
|
81 { |
|
82 MPX_ENTER_EXIT(_L("CMPPopupList::ConstructL()")); |
|
83 |
|
84 iFilePath = aFilePath.AllocL(); |
|
85 iDrmProtected = aDrmProtected; |
|
86 iReadingDCFOnly = aReadingDCFOnly; |
|
87 iListBox = aListBox; |
|
88 TInt cbaResource; |
|
89 |
|
90 // |
|
91 // Construct the softkeys corresponding to Drm or non-Drm status |
|
92 // |
|
93 if ( iDrmProtected && !iReadingDCFOnly ) |
|
94 { |
|
95 cbaResource = R_MP_DRM_FILE_DETAILS_SOFTKEYS_OK_VIEW__OK; |
|
96 } |
|
97 else |
|
98 { |
|
99 cbaResource = R_AVKON_SOFTKEYS_OK_EMPTY__OK; |
|
100 } |
|
101 |
|
102 // |
|
103 // let base class construct the pop-up list |
|
104 // |
|
105 CAknPopupList::ConstructL( aListBox, cbaResource, AknPopupLayouts::EMenuDoubleWindow ); |
|
106 } |
|
107 |
|
108 // CMPPopupList::ConstructL() |
|
109 // ----------------------------------------------------------------------------- |
|
110 // |
|
111 void CMPPopupList::ConstructL( CEikListBox* aListBox, |
|
112 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
113 RFile64& aFile, |
|
114 #else |
|
115 RFile& aFile, |
|
116 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
117 TBool aDrmProtected, |
|
118 TBool aReadingDCFOnly ) |
|
119 { |
|
120 MPX_ENTER_EXIT(_L("CMPPopupList::ConstructL()")); |
|
121 |
|
122 User::LeaveIfError( iFileHandle.Duplicate( aFile ) ); |
|
123 |
|
124 iDrmProtected = aDrmProtected; |
|
125 iReadingDCFOnly = aReadingDCFOnly; |
|
126 iListBox = aListBox; |
|
127 TInt cbaResource; |
|
128 |
|
129 // |
|
130 // Construct the softkeys corresponding to Drm or non-Drm status |
|
131 // |
|
132 if ( iDrmProtected && !iReadingDCFOnly ) |
|
133 { |
|
134 cbaResource = R_MP_DRM_FILE_DETAILS_SOFTKEYS_OK_VIEW__OK; |
|
135 } |
|
136 else |
|
137 { |
|
138 cbaResource = R_AVKON_SOFTKEYS_OK_EMPTY__OK; |
|
139 } |
|
140 |
|
141 // |
|
142 // let base class construct the pop-up list |
|
143 // |
|
144 CAknPopupList::ConstructL( aListBox, cbaResource, AknPopupLayouts::EMenuDoubleWindow ); |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CMPPopupList::~CMPPopupList |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 CMPPopupList::~CMPPopupList() |
|
152 { |
|
153 MPX_ENTER_EXIT(_L("CMPPopupList::~CMPPopupList()")); |
|
154 |
|
155 if( iFileHandle.SubSessionHandle() ) |
|
156 { |
|
157 iFileHandle.Close(); |
|
158 } |
|
159 |
|
160 if( iFilePath ) |
|
161 { |
|
162 delete iFilePath; |
|
163 } |
|
164 } |
|
165 |
|
166 // ----------------------------------------------------------------------------- |
|
167 // CMPPopupList::HandleListBoxEventL |
|
168 // ----------------------------------------------------------------------------- |
|
169 // |
|
170 void CMPPopupList::HandleListBoxEventL( CEikListBox* /* aListBox */ , |
|
171 TListBoxEvent /* aEventType */ ) |
|
172 { |
|
173 MPX_ENTER_EXIT(_L("CMPPopupList::HandleListBoxEventL()")); |
|
174 |
|
175 // |
|
176 // Do nothing except update softkeys according to DRM or non-DRM status |
|
177 // |
|
178 UpdateSoftkeysL(); |
|
179 } |
|
180 |
|
181 // ----------------------------------------------------------------------------- |
|
182 // CMPPopupList::UpdateSoftkeysL |
|
183 // ----------------------------------------------------------------------------- |
|
184 // |
|
185 void CMPPopupList::UpdateSoftkeysL() |
|
186 { |
|
187 MPX_ENTER_EXIT(_L("CMPPopupList::UpdateSoftkeysL()")); |
|
188 |
|
189 if ( iDrmProtected && |
|
190 !iReadingDCFOnly ) |
|
191 { |
|
192 // |
|
193 // When item focus in pop-up details dlg is on Drm item (i.e. License), |
|
194 // LSK is 'Ok' and RSK is 'View' |
|
195 // |
|
196 ButtonGroupContainer()->SetCommandSetL(R_MP_DRM_FILE_DETAILS_SOFTKEYS_OK_VIEW__OK); |
|
197 } |
|
198 else |
|
199 { |
|
200 // |
|
201 // When item focus in pop-up details dlg is on all other non-Drm items (i.e. Title), |
|
202 // LSK is 'Ok' and RSK is empty |
|
203 // |
|
204 ButtonGroupContainer()->SetCommandSetL(R_AVKON_SOFTKEYS_OK_EMPTY__OK); |
|
205 } |
|
206 } |
|
207 |
|
208 // ----------------------------------------------------------------------------- |
|
209 // CMPPopupList::LaunchDrmInfoL |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 void CMPPopupList::LaunchDrmInfoL() |
|
213 { |
|
214 MPX_ENTER_EXIT(_L("CMPPopupList::LaunchDrmInfoL()")); |
|
215 #ifdef SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
216 TInt64 size(0); |
|
217 #else |
|
218 TInt size(0); |
|
219 #endif // SYMBIAN_ENABLE_64_BIT_FILE_SERVER_API |
|
220 TInt err(0); |
|
221 TInt handleExists(0); |
|
222 |
|
223 if ( iFileHandle.SubSessionHandle() ) |
|
224 { |
|
225 err = iFileHandle.Size( size ); |
|
226 } |
|
227 |
|
228 handleExists =(!err && size )? ETrue:EFalse; |
|
229 |
|
230 if(!handleExists) |
|
231 { |
|
232 TUint fileMode = EFileShareReadersOrWriters | EFileStream | EFileRead; |
|
233 RFs fs = CEikonEnv::Static()->FsSession(); |
|
234 |
|
235 User::LeaveIfError(iFileHandle.Open(fs, iFilePath->Des() , fileMode)); |
|
236 } |
|
237 |
|
238 if ( iDrmProtected && ( handleExists || iFilePath ) ) |
|
239 { |
|
240 CDrmUiHandling* drmUiHandler = CDrmUiHandling::NewLC(); |
|
241 TRAPD( err, drmUiHandler->ShowDetailsViewL(iFileHandle) ); |
|
242 |
|
243 if( err != KErrNone ) |
|
244 { |
|
245 drmUiHandler->GetErrorHandler().HandleErrorL( iFileHandle, |
|
246 ContentAccess::EPlay, |
|
247 err, |
|
248 NULL); |
|
249 } |
|
250 CleanupStack::PopAndDestroy(1); // drmUiHandler |
|
251 } |
|
252 } |
|
253 |
|
254 // ----------------------------------------------------------------------------- |
|
255 // CMPPopupList::ProcessCommandL |
|
256 // ----------------------------------------------------------------------------- |
|
257 // |
|
258 void CMPPopupList::ProcessCommandL(TInt aCommandId) |
|
259 { |
|
260 MPX_ENTER_EXIT(_L("CMPPopupList::ProcessCommandL()")); |
|
261 |
|
262 // |
|
263 // Respond to softkey events. |
|
264 // MP Popup only handles the 'View' softkey event, |
|
265 // all other softkey events are handled by Avkon Pop-up |
|
266 // |
|
267 switch (aCommandId) |
|
268 { |
|
269 case EAknSoftkeyView: |
|
270 LaunchDrmInfoL(); |
|
271 break; |
|
272 default: |
|
273 CAknPopupList::ProcessCommandL(aCommandId); |
|
274 break; |
|
275 } |
|
276 } |
|
277 |
|
278 // ----------------------------------------------------------------------------- |
|
279 // CMPPopupList::OfferKeyEventL |
|
280 // ----------------------------------------------------------------------------- |
|
281 // |
|
282 TKeyResponse CMPPopupList::OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType) |
|
283 { |
|
284 MPX_ENTER_EXIT(_L("CMPPopupList::OfferKeyEventL()")); |
|
285 |
|
286 TKeyResponse ret = EKeyWasNotConsumed; |
|
287 |
|
288 if(aKeyEvent.iCode == EKeyEscape) |
|
289 { |
|
290 CancelPopup(); |
|
291 } |
|
292 else |
|
293 { |
|
294 // |
|
295 // pass all remaining events to the list box class |
|
296 // |
|
297 ret = iListBox->OfferKeyEventL(aKeyEvent, aType); |
|
298 |
|
299 // |
|
300 // Update softkeys according to DRM or non-DRM status |
|
301 // |
|
302 UpdateSoftkeysL(); |
|
303 } |
|
304 |
|
305 return ret; |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CMPPopupList::ReConstructDrmSoftkeysL |
|
310 // ----------------------------------------------------------------------------- |
|
311 // |
|
312 void CMPPopupList::ReConstructDrmSoftkeysL( TBool aDrmProtected ) |
|
313 { |
|
314 MPX_ENTER_EXIT(_L("CMPPopupList::ReConstructDrmSoftkeysL()")); |
|
315 |
|
316 // |
|
317 // This method is needed to re-evaluate DRM protection since it may |
|
318 // be inaccurate for playlist during construction time. |
|
319 // Hence, the related softkeys need to be re-constructed here. |
|
320 // |
|
321 |
|
322 iDrmProtected = aDrmProtected; |
|
323 |
|
324 if ( iDrmProtected && !iReadingDCFOnly ) |
|
325 { |
|
326 ButtonGroupContainer()->SetCommandSetL(R_MP_DRM_FILE_DETAILS_SOFTKEYS_OK_VIEW__OK); |
|
327 } |
|
328 } |
|
329 |
|
330 // End of File |