|
1 /* |
|
2 * Copyright (c) 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: CheckBox class for Usage Reporting settings |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include <StringLoader.h> |
|
21 #include <AknQueryDialog.h> |
|
22 #include <AknInfoPopupNoteController.h> |
|
23 #include <drmsettingspluginrsc.rsg> |
|
24 |
|
25 #include "drmsettingsusagecheckbox.h" |
|
26 #include "drmsettingsusagelist.h" |
|
27 #include "drmsettingsmodel.h" |
|
28 #include "drmsettingsplugin.h" |
|
29 |
|
30 // ================= MEMBER FUNCTIONS ======================= |
|
31 |
|
32 // ----------------------------------------------------------------------------- |
|
33 // CDrmSettingUsageCheckBox::CDrmSettingUsageCheckBox |
|
34 // Default constructor. |
|
35 // ----------------------------------------------------------------------------- |
|
36 // |
|
37 CDrmSettingUsageCheckBox::CDrmSettingUsageCheckBox( |
|
38 TInt aResourceId, |
|
39 CDRMSettingUsageList* aList, |
|
40 CDRMSettingsModel* aModel, |
|
41 CDRMSettingsPlugin* aPlugin ) : CAknCheckBoxSettingPage( aResourceId, aList ), |
|
42 iList( aList ), |
|
43 iModel( aModel ), |
|
44 iDrmSettingsPlugin( aPlugin ) |
|
45 { |
|
46 } |
|
47 |
|
48 // ---------------------------------------------------------------------------- |
|
49 // CDrmSettingUsageCheckBox::~CDrmSettingUsageCheckBox |
|
50 // |
|
51 // Destructor |
|
52 // ---------------------------------------------------------------------------- |
|
53 // |
|
54 CDrmSettingUsageCheckBox::~CDrmSettingUsageCheckBox() |
|
55 { |
|
56 delete iPopupController; |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CDrmSettingUsageCheckBox::OfferKeyEventL |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 TKeyResponse CDrmSettingUsageCheckBox::OfferKeyEventL( |
|
64 const TKeyEvent& aKeyEvent, |
|
65 TEventCode aType ) |
|
66 { |
|
67 TKeyResponse response( EKeyWasNotConsumed ); |
|
68 if ( aKeyEvent.iCode != EKeyApplicationF ) |
|
69 { |
|
70 response = this->ListBoxControl()->OfferKeyEventL( aKeyEvent, aType ); |
|
71 } |
|
72 |
|
73 if ( aType == EEventKeyUp ) |
|
74 { |
|
75 ShowInfoPopupL(); |
|
76 } |
|
77 |
|
78 if ( ( aType == EEventKey ) && ( aKeyEvent.iCode == EKeyEscape ) ) |
|
79 { |
|
80 iDrmSettingsPlugin->HandleCommandL( EEikCmdExit ); |
|
81 } |
|
82 |
|
83 return response; |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CDrmSettingUsageCheckBox::DynamicInitL |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 void CDrmSettingUsageCheckBox::DynamicInitL() |
|
91 { |
|
92 HBufC* emptyText( StringLoader::LoadLC( R_USAGE_REPORTING_LIST_EMPTY, |
|
93 iEikonEnv ) ); |
|
94 this->ListBoxControl()->View()->SetListEmptyTextL( *emptyText ); |
|
95 CleanupStack::PopAndDestroy( emptyText ); |
|
96 } |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // CDrmSettingUsageCheckBox::OkToExitL |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 TBool CDrmSettingUsageCheckBox::OkToExitL( TBool aAccept ) |
|
103 { |
|
104 TBool exit( ETrue ); |
|
105 |
|
106 if ( aAccept ) |
|
107 { |
|
108 iList->UpdateContexts(); |
|
109 |
|
110 if ( !iModel->IsMeteringAllowedForAll() ) |
|
111 { |
|
112 HBufC* query( StringLoader::LoadLC( R_DRM_CONF_QUERY_METERING, |
|
113 iEikonEnv ) ); |
|
114 |
|
115 CAknQueryDialog* queryDialog( CAknQueryDialog::NewL() ); |
|
116 |
|
117 TBool retVal( queryDialog->ExecuteLD( R_DRM_CONFIRMATION_QUERY_METERING, |
|
118 *query ) ); |
|
119 CleanupStack::PopAndDestroy( query ); |
|
120 |
|
121 if ( !retVal ) |
|
122 { |
|
123 exit = EFalse; |
|
124 } |
|
125 } |
|
126 } |
|
127 |
|
128 return exit; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CDrmSettingUsageCheckBox::AcceptSettingL |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 void CDrmSettingUsageCheckBox::AcceptSettingL() |
|
136 { |
|
137 iModel->SaveMeteringChanges(); |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // CDrmSettingUsageCheckBox::ShowInfoPopupL |
|
142 // ----------------------------------------------------------------------------- |
|
143 // |
|
144 void CDrmSettingUsageCheckBox::ShowInfoPopupL() |
|
145 { |
|
146 if ( !iPopupController ) |
|
147 { |
|
148 iPopupController = CAknInfoPopupNoteController::NewL(); |
|
149 } |
|
150 TInt index( this->ListBoxControl()->View()->CurrentItemIndex() ); |
|
151 if ( index != -1 ) |
|
152 { |
|
153 iPopupController->SetTextL( iList->At(index)->ItemText() ); |
|
154 iPopupController->ShowInfoPopupNote(); |
|
155 } |
|
156 } |
|
157 |
|
158 // End of File |