|
1 /* |
|
2 * Copyright (c) 2006-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: Container for DRMSettinsPlugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <aknlists.h> |
|
21 #include <AknUtils.h> |
|
22 #include <csxhelp/drm.hlp.hrh> |
|
23 #include <gslistbox.h> |
|
24 #include <StringLoader.h> |
|
25 #include <drmsettingspluginrsc.rsg> |
|
26 |
|
27 #include "drmsettingsplugincontainer.h" |
|
28 #include "drmsettingsplugin.hrh" |
|
29 #include "drmsettingsmodel.h" |
|
30 |
|
31 const TUid KUidRightsManager = { 0x101F85C7 }; |
|
32 |
|
33 // ========================= MEMBER FUNCTIONS ================================ |
|
34 |
|
35 // --------------------------------------------------------------------------- |
|
36 // CDRMSettingsPluginContainer::ConstructL() |
|
37 // |
|
38 // Symbian OS two phased constructor |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 void CDRMSettingsPluginContainer::ConstructL( const TRect& aRect ) |
|
42 { |
|
43 iListBox = new( ELeave ) CAknSettingStyleListBox; |
|
44 iModel = CDRMSettingsModel::NewL(); |
|
45 |
|
46 if( iOmadrm2Supported ) |
|
47 { |
|
48 BaseConstructL( aRect, R_DRM_SETTINGS_VIEW_TITLE, |
|
49 R_DRM_SETTINGS_LBX ); |
|
50 } |
|
51 else |
|
52 { |
|
53 BaseConstructL( aRect, R_DRM_SETTINGS_VIEW_TITLE, |
|
54 R_DRM_SETTINGS_LBX_NO_OMA2 ); |
|
55 } |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------------------------- |
|
59 // CDRMSettingsPluginContainer::CDRMSettingsPluginContainer() |
|
60 // |
|
61 // Constructor |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 CDRMSettingsPluginContainer::CDRMSettingsPluginContainer( |
|
65 TBool aWmdrmSupported, |
|
66 TBool aOmadrm2Supported ) : iWmdrmSupported( aWmdrmSupported ), |
|
67 iOmadrm2Supported( aOmadrm2Supported ) |
|
68 { |
|
69 } |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CDRMSettingsPluginContainer::~CDRMSettingsPluginContainer() |
|
73 // |
|
74 // Destructor |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 CDRMSettingsPluginContainer::~CDRMSettingsPluginContainer() |
|
78 { |
|
79 if ( iModel ) |
|
80 { |
|
81 delete iModel; |
|
82 } |
|
83 // delete listbox item array |
|
84 if ( iListboxItemArray ) |
|
85 { |
|
86 delete iListboxItemArray; |
|
87 } |
|
88 } |
|
89 |
|
90 |
|
91 // --------------------------------------------------------------------------- |
|
92 // CDRMSettingsPluginContainer::ConstructListBoxL() |
|
93 // |
|
94 // Construct the listbox from resource array. |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 void CDRMSettingsPluginContainer::ConstructListBoxL( TInt aResLbxId ) |
|
98 { |
|
99 iListBox->ConstructL( this, EAknListBoxSelectionList /* | |
|
100 EAknListBoxItemSpecificMenuDisabled */ ); |
|
101 iListboxItemArray = CGSListBoxItemTextArray::NewL( aResLbxId, |
|
102 *iListBox, |
|
103 *iCoeEnv ); |
|
104 iListBox->Model()->SetItemTextArray( iListboxItemArray ); |
|
105 iListBox->Model()->SetOwnershipType( ELbmDoesNotOwnItemArray ); |
|
106 CreateListBoxItemsL(); |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // CDRMSettingsPluginContainer::CreateListBoxItemsL() |
|
112 // |
|
113 // Create listbox items. |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 void CDRMSettingsPluginContainer::CreateListBoxItemsL() |
|
117 { |
|
118 #ifdef __DRM_OMA2 |
|
119 if( iOmadrm2Supported ) |
|
120 { |
|
121 MakeTransactionTrackingItemL(); |
|
122 |
|
123 #ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION |
|
124 MakeAutomaticActivationItemL(); |
|
125 #endif // RD_DRM_SILENT_RIGHTS_ACQUISITION |
|
126 |
|
127 #ifdef RD_DRM_METERING |
|
128 MakeUsageReportingItemL(); |
|
129 #endif // RD_DRM_METERING |
|
130 } |
|
131 #endif // __DRM_OMA2 |
|
132 |
|
133 |
|
134 MakeWMDRMLicenseDeletionItemL(); |
|
135 } |
|
136 |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CDRMSettingsPluginContainer::UpdateListBoxL() |
|
140 // |
|
141 // Update listbox item. |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 void CDRMSettingsPluginContainer::UpdateListBoxL( TInt aFeatureId ) |
|
145 { |
|
146 switch( aFeatureId ) |
|
147 { |
|
148 #ifdef __DRM_OMA2 |
|
149 case EDRMSettingsIdTransactionTracking: |
|
150 if( iOmadrm2Supported ) |
|
151 { |
|
152 MakeTransactionTrackingItemL(); |
|
153 } |
|
154 break; |
|
155 |
|
156 #ifdef RD_DRM_SILENT_RIGHTS_ACQUISITION |
|
157 case EDRMSettingsIdAutomaticActivation: |
|
158 if( iOmadrm2Supported ) |
|
159 { |
|
160 MakeAutomaticActivationItemL(); |
|
161 } |
|
162 break; |
|
163 #endif // RD_DRM_SILENT_RIGHTS_ACQUISITION |
|
164 |
|
165 #ifdef RD_DRM_METERING |
|
166 case EDRMSettingsIdUsageReporting: |
|
167 if( iOmadrm2Supported ) |
|
168 { |
|
169 MakeUsageReportingItemL(); |
|
170 } |
|
171 break; |
|
172 #endif // RD_DRM_METERING |
|
173 #endif // __DRM_OMA2 |
|
174 |
|
175 case EDRMSettingsIdWMDRMLicenseDeletion: |
|
176 |
|
177 MakeWMDRMLicenseDeletionItemL(); |
|
178 |
|
179 break; |
|
180 |
|
181 default: |
|
182 break; |
|
183 } |
|
184 |
|
185 iListBox->HandleItemAdditionL(); |
|
186 } |
|
187 |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CDRMSettingsPluginContainer::MakeTransactionTrackingItemL() |
|
191 // |
|
192 // Create Transaction tracking list item |
|
193 // --------------------------------------------------------------------------- |
|
194 // |
|
195 void CDRMSettingsPluginContainer::MakeTransactionTrackingItemL() |
|
196 { |
|
197 HBufC* dynamicText( NULL ); |
|
198 TInt trxTrState( iModel->TransactionTrackingStateL() ); |
|
199 |
|
200 switch ( trxTrState ) |
|
201 { |
|
202 case KDRMTransactionTrackingEnabled: |
|
203 dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_TTRACKING_ON ); |
|
204 break; |
|
205 default: |
|
206 dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_TTRACKING_OFF ); |
|
207 break; |
|
208 } |
|
209 |
|
210 TPtr ptrBuffer ( dynamicText->Des() ); |
|
211 |
|
212 |
|
213 // Finally, set the dynamic text |
|
214 iListboxItemArray->SetDynamicTextL( EDRMSettingsIdTransactionTracking, ptrBuffer ); |
|
215 |
|
216 CleanupStack::PopAndDestroy( dynamicText ); |
|
217 |
|
218 // And add to listbox |
|
219 iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdTransactionTracking, |
|
220 CGSListBoxItemTextArray::EVisible ); |
|
221 } |
|
222 |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CDRMSettingsPluginContainer::MakeAutomaticActivationItemL() |
|
226 // |
|
227 // Create Automatic activation list item |
|
228 // --------------------------------------------------------------------------- |
|
229 // |
|
230 void CDRMSettingsPluginContainer::MakeAutomaticActivationItemL() |
|
231 { |
|
232 TInt automActivState( iModel->AutomaticActivationStateL() ); |
|
233 |
|
234 HBufC* dynamicText( NULL ); |
|
235 |
|
236 switch ( automActivState ) |
|
237 { |
|
238 case KDRMTransactionTrackingEnabled: |
|
239 dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_AUTOM_ACTIV_ON ); |
|
240 break; |
|
241 default: |
|
242 dynamicText = StringLoader::LoadLC( R_DRM_SETTINGS_AUTOM_ACTIV_OFF ); |
|
243 break; |
|
244 } |
|
245 |
|
246 TPtr ptrBuffer ( dynamicText->Des() ); |
|
247 |
|
248 // Finally, set the dynamic text |
|
249 iListboxItemArray->SetDynamicTextL( EDRMSettingsIdAutomaticActivation, |
|
250 ptrBuffer ); |
|
251 |
|
252 CleanupStack::PopAndDestroy( dynamicText ); |
|
253 |
|
254 // And add to listbox |
|
255 iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdAutomaticActivation, |
|
256 CGSListBoxItemTextArray::EVisible ); |
|
257 } |
|
258 |
|
259 // --------------------------------------------------------------------------- |
|
260 // CDRMSettingsPluginContainer::MakeUsageReportingItemL() |
|
261 // |
|
262 // Create Usage reporting list item |
|
263 // --------------------------------------------------------------------------- |
|
264 // |
|
265 void CDRMSettingsPluginContainer::MakeUsageReportingItemL() |
|
266 { |
|
267 TInt count( iModel->UsageReportingCount() ); |
|
268 |
|
269 HBufC* dynamicText( NULL ); |
|
270 |
|
271 switch ( count ) |
|
272 { |
|
273 case 0: |
|
274 dynamicText = StringLoader::LoadL( R_DRM_SET_USAGE_REPORT_NONE ); |
|
275 break; |
|
276 case 1: |
|
277 dynamicText = iModel->GetFirstAllowedMeteringRIAliasL(); |
|
278 break; |
|
279 default: |
|
280 dynamicText = StringLoader::LoadL( R_DRM_SET_SEVERAL_SERVICES ); |
|
281 break; |
|
282 } |
|
283 CleanupStack::PushL( dynamicText ); |
|
284 |
|
285 TPtr ptrBuffer ( dynamicText->Des() ); |
|
286 |
|
287 // Finally, set the dynamic text |
|
288 iListboxItemArray->SetDynamicTextL( EDRMSettingsIdUsageReporting, |
|
289 ptrBuffer ); |
|
290 |
|
291 CleanupStack::PopAndDestroy( dynamicText ); |
|
292 |
|
293 // And add to listbox |
|
294 iListboxItemArray->SetItemVisibilityL( EDRMSettingsIdUsageReporting, |
|
295 CGSListBoxItemTextArray::EVisible ); |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------- |
|
299 // CDRMSettingsPluginContainer::MakeWMDRMLicenseDeletionItemL() |
|
300 // |
|
301 // Create WMDRM license deletion list item |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 void CDRMSettingsPluginContainer::MakeWMDRMLicenseDeletionItemL() |
|
305 { |
|
306 if ( iWmdrmSupported ) |
|
307 { |
|
308 // Add to listbox |
|
309 iListboxItemArray-> |
|
310 SetItemVisibilityL( EDRMSettingsIdWMDRMLicenseDeletion, |
|
311 CGSListBoxItemTextArray::EVisible ); |
|
312 } |
|
313 else |
|
314 { |
|
315 // Add to listbox |
|
316 iListboxItemArray-> |
|
317 SetItemVisibilityL( EDRMSettingsIdWMDRMLicenseDeletion, |
|
318 CGSListBoxItemTextArray::EInvisible ); |
|
319 |
|
320 } |
|
321 } |
|
322 |
|
323 // --------------------------------------------------------------------------- |
|
324 // CDRMSettingsPluginContainer::GetHelpContext() const |
|
325 // |
|
326 // Gets Help |
|
327 // --------------------------------------------------------------------------- |
|
328 // |
|
329 void CDRMSettingsPluginContainer::GetHelpContext( |
|
330 TCoeHelpContext& aContext ) const |
|
331 { |
|
332 aContext.iMajor = KUidRightsManager; |
|
333 aContext.iContext = KSET_HLP_PROTECTED_CONTENT; |
|
334 } |
|
335 |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // CDRMSettingsPluginContainer::CurrentFeatureId() |
|
339 // |
|
340 // Return the feature id of selected listitem |
|
341 // --------------------------------------------------------------------------- |
|
342 // |
|
343 TInt CDRMSettingsPluginContainer::CurrentFeatureId( ) const |
|
344 { |
|
345 return iListboxItemArray->CurrentFeature(); |
|
346 } |
|
347 |
|
348 |
|
349 // ----------------------------------------------------------------------------- |
|
350 // CDRMSettingsPluginContainer::Model() |
|
351 // |
|
352 // |
|
353 // ----------------------------------------------------------------------------- |
|
354 // |
|
355 CDRMSettingsModel* CDRMSettingsPluginContainer::Model() |
|
356 { |
|
357 return iModel; |
|
358 } |
|
359 |
|
360 // End of File |