|
1 /* |
|
2 * Copyright (c) 2004 - 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: Implementation of CDRMHelperGlobalNoteWrapper class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "DRMHelperGlobalNoteWrapper.h" |
|
22 #include "DRMHelperInfoNoteWrapper.h" |
|
23 |
|
24 #include <stringloader.h> |
|
25 #include <AknGlobalConfirmationQuery.h> |
|
26 #include <avkon.hrh> // EAknSoftkeyNo |
|
27 |
|
28 #include <SecondaryDisplay/DRMHelperSecondaryDisplay.h> |
|
29 #include <aknmediatorfacade.h> |
|
30 #include <aknsddata.h> |
|
31 #include <featmgr.h> |
|
32 |
|
33 // EXTERNAL DATA STRUCTURES |
|
34 |
|
35 // EXTERNAL FUNCTION PROTOTYPES |
|
36 |
|
37 // CONSTANTS |
|
38 |
|
39 // MACROS |
|
40 |
|
41 // LOCAL CONSTANTS AND MACROS |
|
42 |
|
43 // MODULE DATA STRUCTURES |
|
44 |
|
45 // LOCAL FUNCTION PROTOTYPES |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 |
|
49 // ============================= LOCAL FUNCTIONS =============================== |
|
50 |
|
51 // ============================ MEMBER FUNCTIONS =============================== |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CDRMHelperGlobalNoteWrapper::CDRMHelperGlobalNoteWrapper |
|
55 // C++ default constructor can NOT contain any code, that |
|
56 // might leave. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CDRMHelperGlobalNoteWrapper::CDRMHelperGlobalNoteWrapper() : CActive( EPriorityStandard ) |
|
60 { |
|
61 CActiveScheduler::Add( this ); |
|
62 } |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // CDRMHelperGlobalNoteWrapper::ConstructL |
|
66 // Symbian 2nd phase constructor can leave. |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void CDRMHelperGlobalNoteWrapper::ConstructL( |
|
70 CStringResourceReader* aResourceReader ) |
|
71 { |
|
72 iResourceReader = aResourceReader; |
|
73 iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES; |
|
74 } |
|
75 |
|
76 // ----------------------------------------------------------------------------- |
|
77 // CDRMHelperGlobalNoteWrapper::NewL |
|
78 // Two-phased constructor. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CDRMHelperGlobalNoteWrapper* CDRMHelperGlobalNoteWrapper::NewLC( |
|
82 CStringResourceReader* aResourceReader ) |
|
83 { |
|
84 CDRMHelperGlobalNoteWrapper* self = new (ELeave) CDRMHelperGlobalNoteWrapper(); |
|
85 CleanupStack::PushL( self ); |
|
86 self->ConstructL( aResourceReader ); |
|
87 return self; |
|
88 } |
|
89 |
|
90 CDRMHelperGlobalNoteWrapper* CDRMHelperGlobalNoteWrapper::NewL( |
|
91 CStringResourceReader* aResourceReader ) |
|
92 { |
|
93 CDRMHelperGlobalNoteWrapper* self = NewLC( aResourceReader ); |
|
94 CleanupStack::Pop( self ); |
|
95 return self; |
|
96 } |
|
97 |
|
98 |
|
99 // Destructor |
|
100 CDRMHelperGlobalNoteWrapper::~CDRMHelperGlobalNoteWrapper() |
|
101 { |
|
102 Cancel(); // Cancel active object |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CDRMHelperGlobalNoteWrapper::ShowNoteL |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TInt CDRMHelperGlobalNoteWrapper::ShowNoteWithButtonsL( |
|
110 TInt aResourceId, |
|
111 TInt aButtonsId ) |
|
112 { |
|
113 TInt ret; |
|
114 |
|
115 iTextBuffer = iResourceReader->ReadResourceString( aResourceId ); |
|
116 |
|
117 iButtonsId = aButtonsId; |
|
118 ret = DoShowNoteL( aResourceId ); |
|
119 iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES; |
|
120 return ret; |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CDRMHelperGlobalNoteWrapper::ShowNoteWithButtonsL |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CDRMHelperGlobalNoteWrapper::ShowNoteWithButtonsL( |
|
128 TInt aResourceId, |
|
129 TInt aButtonsId, |
|
130 const TDesC& aString ) |
|
131 { |
|
132 TInt ret; |
|
133 |
|
134 TBuf<KDRMNoteBufferMaxSize> srcBuffer = |
|
135 iResourceReader->ReadResourceString( aResourceId ); |
|
136 |
|
137 StringLoader::Format( iTextBuffer, srcBuffer, -1, aString ); |
|
138 |
|
139 iButtonsId = aButtonsId; |
|
140 ret = DoShowNoteL( aResourceId, aString ); |
|
141 iButtonsId = R_AVKON_SOFTKEYS_YES_NO__YES; |
|
142 return ret; |
|
143 } |
|
144 |
|
145 // ----------------------------------------------------------------------------- |
|
146 // CDRMHelperGlobalNoteWrapper::ShowNoteL |
|
147 // ----------------------------------------------------------------------------- |
|
148 // |
|
149 TInt CDRMHelperGlobalNoteWrapper::ShowNoteL( TInt aResourceId, TInt aValue ) |
|
150 { |
|
151 TBuf<KDRMNoteBufferMaxSize> srcBuffer = |
|
152 iResourceReader->ReadResourceString( aResourceId ); |
|
153 |
|
154 StringLoader::Format( iTextBuffer, srcBuffer, -1, aValue ); |
|
155 return DoShowNoteL( aResourceId, KNullDesC, aValue ); |
|
156 } |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // CDRMHelperGlobalNoteWrapper::ShowNoteL |
|
160 // ----------------------------------------------------------------------------- |
|
161 // |
|
162 TInt CDRMHelperGlobalNoteWrapper::ShowNoteL( |
|
163 TInt aResourceId, |
|
164 const TDesC& aString ) |
|
165 { |
|
166 TBuf<KDRMNoteBufferMaxSize> srcBuffer = |
|
167 iResourceReader->ReadResourceString( aResourceId ); |
|
168 |
|
169 StringLoader::Format( iTextBuffer, srcBuffer, -1, aString ); |
|
170 return DoShowNoteL( aResourceId, aString ); |
|
171 } |
|
172 |
|
173 // ----------------------------------------------------------------------------- |
|
174 // CDRMHelperGlobalNoteWrapper::ShowNoteL |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 TInt CDRMHelperGlobalNoteWrapper::ShowNoteL( |
|
178 TInt aResourceId, |
|
179 const TDesC& aString, |
|
180 TInt aValue, |
|
181 TInt aStringPos, |
|
182 TInt aValuePos) |
|
183 { |
|
184 TBuf<KDRMNoteBufferMaxSize> srcBuffer = |
|
185 iResourceReader->ReadResourceString( aResourceId ); |
|
186 |
|
187 StringLoader::Format( iTextBuffer, srcBuffer, aValuePos, aValue ); |
|
188 srcBuffer = iTextBuffer; |
|
189 StringLoader::Format( iTextBuffer, srcBuffer, aStringPos, aString ); |
|
190 return DoShowNoteL( aResourceId, aString, aValue ); |
|
191 } |
|
192 |
|
193 // ----------------------------------------------------------------------------- |
|
194 // CDRMHelperGlobalNoteWrapper::DoCancel |
|
195 // ----------------------------------------------------------------------------- |
|
196 // |
|
197 void CDRMHelperGlobalNoteWrapper::DoCancel() |
|
198 { |
|
199 } |
|
200 |
|
201 // ----------------------------------------------------------------------------- |
|
202 // CDRMHelperGlobalNoteWrapper::RunL |
|
203 // ----------------------------------------------------------------------------- |
|
204 // |
|
205 void CDRMHelperGlobalNoteWrapper::RunL() |
|
206 { |
|
207 iWait.AsyncStop(); |
|
208 } |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CDRMHelperGlobalNoteWrapper::DoShowNoteL |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CDRMHelperGlobalNoteWrapper::DoShowNoteL( TInt aResourceId, |
|
215 const TDesC& aString, TInt aValue) |
|
216 { |
|
217 TPtr bufPtr( 0,0 ); |
|
218 |
|
219 RProcess myProcess; |
|
220 TUid myProcessUid( KNullUid ); |
|
221 |
|
222 TInt animation = |
|
223 iButtonsId == R_AVKON_SOFTKEYS_YES_NO__YES ? 0 : R_QGN_NOTE_INFO_ANIM; |
|
224 CAknGlobalConfirmationQuery* globalNote = |
|
225 CAknGlobalConfirmationQuery::NewLC(); |
|
226 |
|
227 bufPtr.Set( const_cast <TUint16*>( iTextBuffer.Ptr() ), iTextBuffer.Length(), |
|
228 iTextBuffer.Length() ); |
|
229 AknTextUtils::LanguageSpecificNumberConversion( bufPtr ); |
|
230 |
|
231 if( FeatureManager::FeatureSupported( KFeatureIdCoverDisplay ) && |
|
232 CDRMHelperInfoNoteWrapper::EvaluateCoverResourceId( aResourceId ) ) |
|
233 { |
|
234 RThread().Process( myProcess ); |
|
235 myProcessUid = myProcess.Identity(); |
|
236 |
|
237 THelperSDData helperData; |
|
238 helperData.iHelperUid = KUidCoverUiCategoryDRMHelper; // First field is DRMHelper's Uid |
|
239 helperData.iHandlerProcessId = myProcessUid; // ProcessId which uses DRMHelper |
|
240 if( aString.Compare( KNullDesC ) ) |
|
241 { |
|
242 // If there is filename given, it's always in the PrimaryString |
|
243 helperData.iStringParam.Append( aString ); |
|
244 } |
|
245 if( aValue >= 0 ) |
|
246 { |
|
247 // If there is no other than numeric data, put it as SecondaryString |
|
248 helperData.iNumParam.AppendNum( aValue ); |
|
249 } |
|
250 |
|
251 THelperSDDataPckg pckg( helperData ); |
|
252 CAknSDData* sd = CAknSDData::NewL( KUidCoverUiCategoryDRMHelper, aResourceId, pckg ); |
|
253 globalNote->SetSecondaryDisplayData( sd ); // ownership to notifier client |
|
254 } |
|
255 |
|
256 iStatus = KRequestPending; |
|
257 globalNote->ShowConfirmationQueryL( iStatus, iTextBuffer, iButtonsId, |
|
258 animation ); |
|
259 SetActive(); |
|
260 iWait.Start(); |
|
261 CleanupStack::PopAndDestroy( globalNote ); |
|
262 return MappedButtonId( iStatus.Int() ); |
|
263 } |
|
264 |
|
265 // ----------------------------------------------------------------------------- |
|
266 // CDRMHelperGlobalNoteWrapper::MappedButtonId |
|
267 // ----------------------------------------------------------------------------- |
|
268 // |
|
269 TInt CDRMHelperGlobalNoteWrapper::MappedButtonId( TInt aButtonId ) const |
|
270 { |
|
271 switch ( aButtonId ) |
|
272 { |
|
273 // Do not test for case EEikBidCancel; |
|
274 // it is defined to be the same as EAknSoftkeyCancel |
|
275 |
|
276 case EAknSoftkeyCancel: |
|
277 case EAknSoftkeyBack: |
|
278 case EAknSoftkeyNo: |
|
279 return 0; |
|
280 |
|
281 default: |
|
282 break; |
|
283 } |
|
284 |
|
285 // Also process user range: |
|
286 |
|
287 if ( aButtonId >= EAknSoftkeyLowestUserRejectId |
|
288 && aButtonId < EAknSoftkeyLowestUserAcceptId ) |
|
289 return 0; |
|
290 |
|
291 return aButtonId; |
|
292 } |
|
293 |
|
294 |
|
295 // ========================== OTHER EXPORTED FUNCTIONS ========================= |
|
296 |
|
297 // End of File |