|
1 /* |
|
2 * Copyright (c) 2003 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: COperatorMenuAppUi implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "OperatorMenuAppUi.h" |
|
21 |
|
22 #include <featmgr.h> |
|
23 #include <bldvariant.hrh> |
|
24 #include <FeatMgr.h> |
|
25 |
|
26 #include <centralrepository.h> |
|
27 #include <menu2internalCRkeys.h> |
|
28 // CONSTANTS |
|
29 _LIT(KUrlLaunchParameter, "4 "); |
|
30 _LIT(KLongZeroLaunchParameter, "5"); |
|
31 const TInt KUrlLaunchParamLength = 2; |
|
32 |
|
33 const TInt KCenRepBufferSize = 255; |
|
34 const TText KStrComma = ','; |
|
35 #define KOperatorMenuUID 0x10008D5E |
|
36 |
|
37 // ================= LOCAL FUNCTIONS ======================== |
|
38 |
|
39 // ---------------------------------------------------------------------------- |
|
40 // OperatorMenuUIDText |
|
41 // |
|
42 // @param aOperatorMenuUid buffer to set OperatorMenu UID as text |
|
43 // ---------------------------------------------------------------------------- |
|
44 // |
|
45 void OperatorMenuUIDText( TDes& aOperatorMenuUid ) |
|
46 { |
|
47 // TUid method name return UID in format [UID], but we need only UID part. |
|
48 TUidName uidName( TUid::Uid( KOperatorMenuUID ).Name() ); |
|
49 aOperatorMenuUid.Copy( uidName.Mid( 1, KMaxUidName - 2 ) ); |
|
50 aOperatorMenuUid.UpperCase(); |
|
51 } |
|
52 |
|
53 // ---------------------------------------------------------------------------- |
|
54 // SetOperatorMenuHiddenInAppShellL |
|
55 // |
|
56 // @param aHidden Whether OperatorMenu should be hidden |
|
57 // ---------------------------------------------------------------------------- |
|
58 // |
|
59 void SetOperatorMenuHiddenInAppShellL( TBool aHidden ) |
|
60 { |
|
61 CRepository* appShellRepository = CRepository::NewL( KCRUidMenu ); |
|
62 CleanupStack::PushL( appShellRepository ); |
|
63 |
|
64 // Read current value of the app shell hidden apps key |
|
65 TBuf<KCenRepBufferSize> keyContent; |
|
66 TInt err = appShellRepository->Get( KMenuHideApplication, keyContent ); |
|
67 if ( err != KErrNone ) |
|
68 { |
|
69 User::Leave( err ); |
|
70 } |
|
71 |
|
72 TBool updated( EFalse ); |
|
73 |
|
74 TBuf<8> OperatorMenuUid; |
|
75 OperatorMenuUIDText( OperatorMenuUid ); |
|
76 |
|
77 // Search for PoC uid in the content (ignore case) |
|
78 TInt offset = keyContent.FindC( OperatorMenuUid ); |
|
79 if ( offset == KErrNotFound && aHidden ) |
|
80 { |
|
81 // PoC is not in the list but should be |
|
82 // |
|
83 __ASSERT_ALWAYS( keyContent.Length() + 9 < KCenRepBufferSize, |
|
84 User::Leave( KErrOverflow ) ); |
|
85 if ( keyContent.Length() > 0 ) |
|
86 { |
|
87 keyContent.Append( KStrComma ); |
|
88 } |
|
89 keyContent.Append( OperatorMenuUid ); |
|
90 updated = ETrue; |
|
91 } |
|
92 else if ( offset != KErrNotFound && !aHidden ) |
|
93 { |
|
94 // PoC is in the list but shouldn't be |
|
95 // |
|
96 if ( offset == 0 ) |
|
97 { |
|
98 // Delete PoC uid and following comma (if any) |
|
99 keyContent.Delete( 0, Min( 9, keyContent.Length() ) ); |
|
100 updated = ETrue; |
|
101 } |
|
102 else if ( keyContent[offset - 1] == ',' ) |
|
103 { |
|
104 // Delete PoC uid and preceding comma |
|
105 keyContent.Delete( offset - 1, 9 ); |
|
106 updated = ETrue; |
|
107 } |
|
108 else |
|
109 { |
|
110 User::Leave( KErrCorrupt ); |
|
111 } |
|
112 } |
|
113 |
|
114 if ( updated ) |
|
115 { |
|
116 err = appShellRepository->Set( KMenuHideApplication, keyContent ); |
|
117 if ( err != KErrNone ) |
|
118 { |
|
119 User::Leave( err ); |
|
120 } |
|
121 } |
|
122 |
|
123 CleanupStack::PopAndDestroy( appShellRepository ); |
|
124 } |
|
125 |
|
126 // ---------------------------------------------------------- |
|
127 // COperatorDelayedStarter::COperatorDelayedStarter(COperatorMenuAppUi* aOperatorMenuAppUi) |
|
128 // ---------------------------------------------------------- |
|
129 // |
|
130 COperatorDelayedStarter::COperatorDelayedStarter(COperatorMenuAppUi* aOperatorMenuAppUi) |
|
131 : CActive( EPriorityLow ) |
|
132 { |
|
133 CActiveScheduler::Add( this ); |
|
134 iOperatorMenuAppUi = aOperatorMenuAppUi; |
|
135 } |
|
136 |
|
137 // ---------------------------------------------------------- |
|
138 // COperatorDelayedStarter::~COperatorDelayedStarter() |
|
139 // ---------------------------------------------------------- |
|
140 // |
|
141 COperatorDelayedStarter::~COperatorDelayedStarter() |
|
142 { |
|
143 Cancel(); |
|
144 Deque(); |
|
145 } |
|
146 |
|
147 // ---------------------------------------------------------- |
|
148 // COperatorDelayedStarter::Start() |
|
149 // ---------------------------------------------------------- |
|
150 // |
|
151 void COperatorDelayedStarter::Start() |
|
152 { |
|
153 SetActive(); |
|
154 TRequestStatus* reqStat= &iStatus; |
|
155 User::RequestComplete( reqStat, KErrNone ); |
|
156 } |
|
157 |
|
158 // ---------------------------------------------------------- |
|
159 // COperatorDelayedStarter::RunL() |
|
160 // ---------------------------------------------------------- |
|
161 // |
|
162 void COperatorDelayedStarter::RunL() |
|
163 { |
|
164 iOperatorMenuAppUi->LaunchBrowserL(); |
|
165 } |
|
166 |
|
167 // ---------------------------------------------------------- |
|
168 // COperatorDelayedStarter:: |
|
169 // ---------------------------------------------------------- |
|
170 // |
|
171 void COperatorDelayedStarter::DoCancel() |
|
172 { |
|
173 } |
|
174 |
|
175 // ================= MEMBER FUNCTIONS ======================= |
|
176 // |
|
177 |
|
178 // ---------------------------------------------------------- |
|
179 // COperatorMenuAppUi::COperatorMenuAppUi() |
|
180 // ---------------------------------------------------------- |
|
181 // |
|
182 COperatorMenuAppUi::COperatorMenuAppUi() |
|
183 { |
|
184 } |
|
185 |
|
186 // ---------------------------------------------------------- |
|
187 // COperatorMenuAppUi::ConstructL() |
|
188 // ---------------------------------------------------------- |
|
189 // |
|
190 void COperatorMenuAppUi::ConstructL() |
|
191 { |
|
192 BaseConstructL(/* ENoScreenFurniture |*/ ENonStandardResourceFile /*| ENoAppResourceFile | EAknEnableSkin*/ ); |
|
193 |
|
194 // Connect to HttpCacheManager central repository |
|
195 iRepository = CRepository::NewL( KCRUidCacheManager ); |
|
196 // Connect to OperatorMenu central repository |
|
197 iRepositoryOp = CRepository::NewL( KCrUidOperatorMenu ); |
|
198 |
|
199 //Launch the browser with the Operator specific Url |
|
200 //or with default AP's homepage if Operator domain url not available |
|
201 //LaunchBrowserL(); |
|
202 iLaunched = EFalse; |
|
203 |
|
204 TBool OperatorMenuSupport = FeatureManager::FeatureSupported( KFeatureIdOperatorMenu ); |
|
205 if ( OperatorMenuSupport ) |
|
206 { |
|
207 iDelayedStarter = new (ELeave) COperatorDelayedStarter( this ); |
|
208 iDelayedStarter->Start(); |
|
209 } |
|
210 else |
|
211 { |
|
212 SetOperatorMenuHiddenInAppShellL( ETrue ); |
|
213 Exit(); |
|
214 } |
|
215 } |
|
216 // ---------------------------------------------------- |
|
217 // COperatorMenuAppUi::~COperatorMenuAppUi() |
|
218 // ---------------------------------------------------- |
|
219 // |
|
220 COperatorMenuAppUi::~COperatorMenuAppUi() |
|
221 { |
|
222 delete iRepository; |
|
223 delete iRepositoryOp; |
|
224 |
|
225 if( iOverriddenSettings ) |
|
226 { |
|
227 delete iOverriddenSettings; |
|
228 iOverriddenSettings = NULL; |
|
229 } |
|
230 if( iDelayedStarter ) |
|
231 { |
|
232 delete iDelayedStarter; |
|
233 iDelayedStarter = NULL; |
|
234 } |
|
235 } |
|
236 |
|
237 |
|
238 // ---------------------------------------------------- |
|
239 // COperatorMenuAppUi::HandleKeyEventL( |
|
240 // ---------------------------------------------------- |
|
241 // |
|
242 TKeyResponse COperatorMenuAppUi::HandleKeyEventL( |
|
243 const TKeyEvent& /*aKeyEvent*/,TEventCode /*aType*/ ) |
|
244 { |
|
245 return EKeyWasNotConsumed; |
|
246 } |
|
247 |
|
248 // ---------------------------------------------------- |
|
249 // COperatorMenuAppUi::HandleCommandL(TInt aCommand) |
|
250 // ---------------------------------------------------- |
|
251 // |
|
252 void COperatorMenuAppUi::HandleCommandL( TInt aCommand ) |
|
253 { |
|
254 switch ( aCommand ) |
|
255 { |
|
256 case EAknSoftkeyBack: |
|
257 case EAknSoftkeyExit: |
|
258 case EEikCmdExit: |
|
259 case EAknCmdExit: |
|
260 { |
|
261 Exit(); |
|
262 break; |
|
263 } |
|
264 default: |
|
265 break; |
|
266 } |
|
267 } |
|
268 |
|
269 // ---------------------------------------------------- |
|
270 // COperatorMenuAppUi::HandleContentL |
|
271 // Handles the content coming from the embedded browser. |
|
272 // Returns EFalse: content will be passed on to framework |
|
273 // ---------------------------------------------------- |
|
274 // |
|
275 TBool COperatorMenuAppUi::HandleContentL( const TDesC& /*aFileName*/, const CAiwGenericParamList& /*aParamList*/, TBool& aContinue ) |
|
276 { |
|
277 aContinue = EFalse; |
|
278 return EFalse; |
|
279 } |
|
280 |
|
281 // ---------------------------------------------------- |
|
282 // COperatorMenuAppUi::DownloadedContentHandlerReserved1 |
|
283 // ( Reserved for future use ) |
|
284 // ---------------------------------------------------- |
|
285 // |
|
286 TAny* COperatorMenuAppUi::DownloadedContentHandlerReserved1( TAny* /*aAnyParam*/ ) |
|
287 { |
|
288 // Empty implementation. |
|
289 return NULL; |
|
290 } |
|
291 |
|
292 // ---------------------------------------------------- |
|
293 // COperatorMenuAppUi::LaunchBrowserL() |
|
294 // ---------------------------------------------------- |
|
295 // |
|
296 void COperatorMenuAppUi::LaunchBrowserL() |
|
297 { |
|
298 TBool LaunchWithUrl( EFalse ); |
|
299 TInt value; |
|
300 |
|
301 if( !iLaunched ) |
|
302 { |
|
303 iLaunched = ETrue; |
|
304 |
|
305 //If centralrepository of HttpCahemanager is available... |
|
306 if ( iRepository ) |
|
307 { |
|
308 // Read the URL from CacheManager central repository |
|
309 if ( KErrNone == iRepository->Get( KOperatorDomainUrl, iUrl ) ) |
|
310 { |
|
311 LaunchWithUrl = ETrue; |
|
312 } |
|
313 } |
|
314 |
|
315 //If centralrepository of OperatorMenu is available... |
|
316 if ( iRepositoryOp ) |
|
317 { |
|
318 delete iOverriddenSettings; |
|
319 iOverriddenSettings = NULL; |
|
320 |
|
321 iOverriddenSettings = new (ELeave) TBrowserOverriddenSettings; |
|
322 |
|
323 //Read the values to override |
|
324 if ( KErrNone == iRepositoryOp->Get( KOpMenuVerticalLayoutEnabled, value ) ) |
|
325 { |
|
326 iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsSmallScreen, (TUint) value); |
|
327 } |
|
328 if ( KErrNone == iRepositoryOp->Get( KOpMenuAutoLoadImages, value ) ) |
|
329 { |
|
330 iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsAutoLoadImages, (TUint) value); |
|
331 } |
|
332 if ( KErrNone == iRepositoryOp->Get( KOpMenuFontSize, value ) ) |
|
333 { |
|
334 iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsFontSize, (TUint) value); |
|
335 } |
|
336 if ( KErrNone == iRepositoryOp->Get( KOpMenuFullScreen, value ) ) |
|
337 { |
|
338 iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsFullScreen, (TUint) value); |
|
339 } |
|
340 if ( KErrNone == iRepositoryOp->Get( KOpMenuDefAp, value ) ) |
|
341 { |
|
342 iOverriddenSettings->SetBrowserSetting( EBrowserOverSettingsCustomAp, (TUint) value); |
|
343 } |
|
344 } |
|
345 } |
|
346 |
|
347 // Launch browser according to the given launch type |
|
348 if( LaunchWithUrl && iUrl.Length() ) |
|
349 { |
|
350 LaunchBrowserEmbeddedWithOperatorUrlL(); |
|
351 } |
|
352 else |
|
353 { |
|
354 LaunchBrowserEmbeddedWithDefaultAPHomepageL(); |
|
355 } |
|
356 Exit(); |
|
357 } |
|
358 |
|
359 // ---------------------------------------------------- |
|
360 // COperatorMenuAppUi::LaunchBrowserEmbeddedWithUrlL |
|
361 // ---------------------------------------------------- |
|
362 // |
|
363 void COperatorMenuAppUi::LaunchBrowserEmbeddedWithOperatorUrlL() |
|
364 { |
|
365 //Pass the operator specific url to browser |
|
366 //(read from cachemanager ini file in LaunchBrowserL) |
|
367 HBufC* url = NULL; |
|
368 url = HBufC::NewLC( iUrl.Length() + KUrlLaunchParamLength ); |
|
369 url->Des().Append( KUrlLaunchParameter ); |
|
370 url->Des().Append( iUrl ); |
|
371 |
|
372 CBrowserLauncher* launcher = CBrowserLauncher::NewLC(); |
|
373 |
|
374 launcher->LaunchBrowserSyncEmbeddedL( url->Des(), this, iOverriddenSettings ); |
|
375 |
|
376 CleanupStack::PopAndDestroy(); //Launcher |
|
377 CleanupStack::PopAndDestroy(); // url HBufC |
|
378 } |
|
379 |
|
380 // ---------------------------------------------------- |
|
381 // COperatorMenuAppUi::NotifyExit |
|
382 // ---------------------------------------------------- |
|
383 // |
|
384 void COperatorMenuAppUi::NotifyExit(TExitMode /*aMode*/) |
|
385 { |
|
386 } |
|
387 |
|
388 void COperatorMenuAppUi::LaunchBrowserEmbeddedWithDefaultAPHomepageL() |
|
389 { |
|
390 //Start the browser with parameter "5" to launch to default AP homepage |
|
391 CBrowserLauncher* launcher = CBrowserLauncher::NewLC(); |
|
392 |
|
393 launcher->LaunchBrowserSyncEmbeddedL( KLongZeroLaunchParameter, this, iOverriddenSettings ); |
|
394 |
|
395 CleanupStack::PopAndDestroy(); |
|
396 } |
|
397 |
|
398 // ---------------------------------------------------- |
|
399 // COperatorMenuAppUi::HandleStatusPaneSizeChange |
|
400 // ---------------------------------------------------- |
|
401 // |
|
402 void COperatorMenuAppUi::HandleStatusPaneSizeChange() |
|
403 { |
|
404 } |
|
405 // End of File |
|
406 |