|
1 // Copyright (c) 1997-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // mm: |
|
15 // Areas of improvement: |
|
16 // * Move the CEikErrorResolver to EikSrv as it is only used there |
|
17 // * Fix ineffective deprecation tags on KeyPressLabel(), Version(), and SetVerboseInfoReporting() |
|
18 // * Review CCoeDataStorage |
|
19 // * Make ControlStackReadyL() @internalTechnology (and rename it) |
|
20 // * Check documentatoin of SetAutoForwarding() |
|
21 // |
|
22 // |
|
23 |
|
24 |
|
25 #include <e32uid.h> |
|
26 #include <e32hal.h> |
|
27 #include <basched.h> |
|
28 #include <barsread.h> |
|
29 #include <bautils.h> |
|
30 #include "baerror.h" |
|
31 #include <bassnd.h> |
|
32 #include <txtrich.h> |
|
33 #include <txtfmlyr.h> |
|
34 #include <txtfrmat.h> |
|
35 #include <mparser.h> |
|
36 #include <savenotf.h> |
|
37 #include <apparc.h> |
|
38 #include <apgdoor.h> |
|
39 #include <apgicnfl.h> |
|
40 #include <apgcli.h> |
|
41 #include <apgwgnam.h> |
|
42 #include <prnsetup.h> |
|
43 #include <gulbordr.h> |
|
44 #include <gulcolor.h> |
|
45 #include <gulfont.h> |
|
46 #include <gulicon.h> |
|
47 #include <fepbase.h> |
|
48 #include <coecntrl.h> |
|
49 #include <coeerror.h> |
|
50 #include <coesndpy.h> |
|
51 #include "coedatastorage.h" |
|
52 #include <eikenv.h> |
|
53 #include <eikappui.h> |
|
54 #include <eikdoc.h> |
|
55 #include <eikapp.h> |
|
56 #include <eikmsg.h> |
|
57 #include <eikdebug.h> |
|
58 |
|
59 #include <eikproc.h> |
|
60 #include <eikrutil.h> |
|
61 #include <eiksfont.h> |
|
62 #include <eikdll.h> |
|
63 #include <eiksvdef.h> |
|
64 #include <eikpanic.h> |
|
65 #include <uiklafgt/eikcore.rsg> |
|
66 #include <uiklafgt/eikpriv.rsg> |
|
67 #include <eikvcurs.h> |
|
68 #include <eiksrvs.h> |
|
69 #include "eikerror.h" |
|
70 #include <uiklaf/private/lafshut.h> |
|
71 #include <ecom/ecom.h> |
|
72 #include <eikserverapp.h> |
|
73 #include "eiksrvc.h" |
|
74 |
|
75 #include "eikdebugprefs.h" |
|
76 #include "eikprivate.h" |
|
77 #include "eikenvextra.h" |
|
78 #include "eikautomenutitlearray.h" |
|
79 #include "eikenvinterface.h" |
|
80 #include <graphics/cone/coeerrorconsts.h> |
|
81 #include "eikdefconst.h" |
|
82 #include "eikdefconstinternal.h" |
|
83 #include "eiklibry.h" |
|
84 #include "eikdgfty.h" |
|
85 |
|
86 GLDEF_C void Panic(TEikPanic aPanic) |
|
87 { |
|
88 _LIT(KPanicCat,"EIKON"); |
|
89 User::Panic(KPanicCat,aPanic); |
|
90 } |
|
91 |
|
92 /** |
|
93 @internalComponent |
|
94 */ |
|
95 const TUid KUikonLibraryUid = {KUidUikonLibraryValue}; |
|
96 |
|
97 |
|
98 /** |
|
99 @internalComponent |
|
100 */ |
|
101 NONSHARABLE_CLASS(CEikErrorIdler) : public CIdle |
|
102 { |
|
103 public: |
|
104 static CEikErrorIdler* NewL(); |
|
105 private: |
|
106 CEikErrorIdler() : CIdle(EPriorityLow) { } |
|
107 public: |
|
108 TTime iTime; |
|
109 TInt iError; |
|
110 TInt iContext; |
|
111 }; |
|
112 |
|
113 CEikErrorIdler* CEikErrorIdler::NewL() |
|
114 { |
|
115 CEikErrorIdler* self=new(ELeave) CEikErrorIdler; |
|
116 CActiveScheduler::Add(self); |
|
117 return(self); |
|
118 } |
|
119 |
|
120 |
|
121 // |
|
122 // class CEikStartUpViewActivator |
|
123 // |
|
124 /** |
|
125 This is a high-priority async view activator, used by the CEikonEnv to activate the application's |
|
126 default view on application startup in the foreground, as the view server won't do it. |
|
127 |
|
128 @internalComponent |
|
129 @see CActive |
|
130 */ |
|
131 NONSHARABLE_CLASS(CEikStartUpViewActivator) : public CActive |
|
132 { |
|
133 public: |
|
134 static CEikStartUpViewActivator* NewL(CEikAppUi& aAppUi, CEikonEnv& aEikonEnv, CEikStartUpViewActivator*& aOwner); |
|
135 virtual ~CEikStartUpViewActivator(); |
|
136 private: |
|
137 CEikStartUpViewActivator(CEikAppUi& aAppUi, CEikonEnv& aEikonEnv, CEikStartUpViewActivator*& aOwner); |
|
138 private: // from CActive |
|
139 void DoCancel(); |
|
140 void RunL(); |
|
141 TInt RunError(TInt aError); |
|
142 private: |
|
143 CEikAppUi& iAppUi; |
|
144 CEikonEnv& iEnv; |
|
145 CEikStartUpViewActivator*& iOwner; |
|
146 }; |
|
147 |
|
148 const TInt KStartUpViewActivatorPriority = EActivePriorityFepLoader+10; |
|
149 |
|
150 CEikStartUpViewActivator* CEikStartUpViewActivator::NewL(CEikAppUi& aAppUi, CEikonEnv& aEikonEnv, CEikStartUpViewActivator*& aOwner) |
|
151 { |
|
152 return new(ELeave) CEikStartUpViewActivator(aAppUi, aEikonEnv, aOwner); |
|
153 } |
|
154 |
|
155 CEikStartUpViewActivator::~CEikStartUpViewActivator() |
|
156 { |
|
157 Cancel(); |
|
158 iOwner = NULL; |
|
159 } |
|
160 |
|
161 CEikStartUpViewActivator::CEikStartUpViewActivator(CEikAppUi& aAppUi, CEikonEnv& aEikonEnv, CEikStartUpViewActivator*& aOwner) |
|
162 : CActive(KStartUpViewActivatorPriority), iAppUi(aAppUi), iEnv(aEikonEnv), iOwner(aOwner) |
|
163 { |
|
164 CActiveScheduler::Add(this); |
|
165 TRequestStatus* status = &iStatus; |
|
166 User::RequestComplete(status, KErrNone); |
|
167 SetActive(); |
|
168 } |
|
169 |
|
170 void CEikStartUpViewActivator::DoCancel() |
|
171 { |
|
172 } |
|
173 |
|
174 void CEikStartUpViewActivator::RunL() |
|
175 { |
|
176 RWsSession& ws = iEnv.WsSession(); |
|
177 const TInt numWgs = ws.NumWindowGroups(0); |
|
178 CArrayFixFlat<TInt>* windowList = new(ELeave) CArrayFixFlat<TInt>(numWgs); |
|
179 CleanupStack::PushL(windowList); |
|
180 ws.WindowGroupList(0, windowList); |
|
181 const TInt wgId = iEnv.RootWin().Identifier(); |
|
182 if ((ws.GetFocusWindowGroup() == wgId || (windowList->Count() > 0 && windowList->At(0) == wgId)) |
|
183 && (iEnv.IsSchedulerRunning())) |
|
184 { |
|
185 iAppUi.ActivateTopViewL(); |
|
186 } |
|
187 CleanupStack::PopAndDestroy(windowList); |
|
188 delete this; |
|
189 } |
|
190 |
|
191 TInt CEikStartUpViewActivator::RunError(TInt aError) |
|
192 { |
|
193 delete this; |
|
194 return aError; |
|
195 } |
|
196 |
|
197 |
|
198 // |
|
199 // class CEikonEnv |
|
200 // |
|
201 |
|
202 enum TEikEnvFlags |
|
203 { |
|
204 EAutoForwarding, |
|
205 EVerboseInfoReporting, |
|
206 EStartedAsServerApp |
|
207 }; |
|
208 |
|
209 // @deprecated |
|
210 EXPORT_C TVersion CEikonEnv::Version() |
|
211 /** Gets the Uikon version that is currently running. |
|
212 |
|
213 @return The Uikon version. */ |
|
214 { // static |
|
215 const TInt KEikMajorVersionNumber=1; |
|
216 const TInt KEikMinorVersionNumber=0; |
|
217 const TInt KEikBuildVersionNumber=106; |
|
218 return(TVersion(KEikMajorVersionNumber,KEikMinorVersionNumber,KEikBuildVersionNumber)); |
|
219 } |
|
220 |
|
221 EXPORT_C const CFont* CEikonEnv::AnnotationFont() const |
|
222 /** Gets the standard annotation font for this environment. |
|
223 |
|
224 It is highly recommended to use CCoeControl::ScreenFont() instead of |
|
225 this function. |
|
226 |
|
227 @see CCoeControl::ScreenFont() |
|
228 @see CCoeFontProvider |
|
229 |
|
230 @return Pointer to the annotation font. */ |
|
231 { |
|
232 const TLogicalFont lf( TUid::Uid(KLafUidAnnotationFontVal) ); |
|
233 return LafEnv::MatchFont(*iFontArray, lf); |
|
234 } |
|
235 |
|
236 EXPORT_C const CFont* CEikonEnv::TitleFont() const |
|
237 /** Gets the standard title font for this environment. |
|
238 |
|
239 It is highly recommended to use CCoeControl::ScreenFont() instead of |
|
240 this function. |
|
241 |
|
242 @see CCoeControl::ScreenFont() |
|
243 @see CCoeFontProvider |
|
244 |
|
245 @return Pointer to the title font. */ |
|
246 { |
|
247 const TLogicalFont lf( TUid::Uid(KLafUidTitleFontVal) ); |
|
248 return LafEnv::MatchFont(*iFontArray,lf); |
|
249 } |
|
250 |
|
251 EXPORT_C const CFont* CEikonEnv::LegendFont() const |
|
252 /** Gets the standard legend font for this environment. |
|
253 |
|
254 It is highly recommended to use CCoeControl::ScreenFont() instead of |
|
255 this function. |
|
256 |
|
257 @see CCoeControl::ScreenFont() |
|
258 @see CCoeFontProvider |
|
259 |
|
260 @return Pointer to the legend font. */ |
|
261 { |
|
262 const TLogicalFont lf( TUid::Uid(KLafUidLegendFontVal) ); |
|
263 return LafEnv::MatchFont(*iFontArray, lf); |
|
264 } |
|
265 |
|
266 EXPORT_C const CFont* CEikonEnv::SymbolFont() const |
|
267 /** Gets the standard symbol font for this environment. |
|
268 |
|
269 It is highly recommended to use CCoeControl::ScreenFont() instead of |
|
270 this function. |
|
271 |
|
272 @see CCoeControl::ScreenFont() |
|
273 @see CCoeFontProvider |
|
274 |
|
275 @return Pointer to the symbol font. */ |
|
276 { |
|
277 const TLogicalFont lf( TUid::Uid(KLafUidSymbolFontVal) ); |
|
278 return LafEnv::MatchFont(*iFontArray, lf); |
|
279 } |
|
280 |
|
281 EXPORT_C const CFont* CEikonEnv::DenseFont() const |
|
282 /** Gets the standard dense font for this environment. |
|
283 |
|
284 It is highly recommended to use CCoeControl::ScreenFont() instead of |
|
285 this function. |
|
286 |
|
287 @see CCoeControl::ScreenFont() |
|
288 @see CCoeFontProvider |
|
289 |
|
290 @return Pointer to the dense font. */ |
|
291 { |
|
292 const TLogicalFont lf( TUid::Uid(KLafUidDenseFontVal) ); |
|
293 return LafEnv::MatchFont(*iFontArray, lf); |
|
294 } |
|
295 |
|
296 EXPORT_C const CFont* CEikonEnv::Font(const TLogicalFont& aLogicalFont) const |
|
297 /** Gets the nearest match to the specified font. |
|
298 |
|
299 It is highly recommended to use CCoeControl::ScreenFont() instead of |
|
300 this function. |
|
301 |
|
302 @see CCoeControl::ScreenFont() |
|
303 @see CCoeFontProvider |
|
304 |
|
305 The return value is never NULL. |
|
306 |
|
307 @param aLogicalFont The font for which a match is sought. |
|
308 @return Pointer to the font that most closely matches aLogicalFont. */ |
|
309 { |
|
310 return LafEnv::MatchFont(*iFontArray,aLogicalFont); |
|
311 } |
|
312 |
|
313 |
|
314 /** |
|
315 Framework function. |
|
316 Creates array of system fonts. |
|
317 */ |
|
318 EXPORT_C void CEikonEnv::InitSystemFontsL() |
|
319 { |
|
320 InitSystemResourceFileL(); |
|
321 InitPrivateResourceFileL(); |
|
322 |
|
323 ASSERT(!iFontArray); |
|
324 iFontArray = new(ELeave) CArrayPtrFlat<CLafSystemFont>(2); |
|
325 LafEnv::CreateSystemFontsL(*this,*iFontArray); |
|
326 |
|
327 const TLogicalFont lf( TUid::Uid(KLafUidNormalFontVal) ); |
|
328 iNormalFont = LafEnv::MatchFont(*iFontArray, lf); |
|
329 } |
|
330 |
|
331 /** |
|
332 Creates and populates array of bitmaps. |
|
333 @internalComponent |
|
334 */ |
|
335 void CEikonEnv::InitSystemBitmapsL() |
|
336 { |
|
337 ASSERT(!iBitmapArray); |
|
338 iBitmapArray = new(ELeave) CArrayPtrFlat<CFbsBitmap>(2); |
|
339 LafEnv::CreateSystemBitmapsL(*this, *iBitmapArray); |
|
340 } |
|
341 |
|
342 EXPORT_C CEikonEnv::CEikonEnv() |
|
343 /** Default C++ constructor. |
|
344 |
|
345 Allocates memory for the new CEikonEnv object; invoke using new(ELeave). |
|
346 The second phase constructor should be called after the constructor |
|
347 for the environment to be correctly initialised. */ |
|
348 { |
|
349 } |
|
350 |
|
351 EXPORT_C CEikonEnv::~CEikonEnv() |
|
352 /** Destructor |
|
353 |
|
354 Frees any resources allocated by this CEikonEnv during construction. */ |
|
355 { |
|
356 delete iExtension; |
|
357 BaflUtils::ReleaseIdealLanguage(); |
|
358 |
|
359 DeleteResourceFile(iPrivateResourceFileOffset); |
|
360 delete iAppUiFactoryArray; |
|
361 delete iAutoMenuTitleArray; |
|
362 delete iSingleLineParaFormatLayer; |
|
363 delete iParaFormatLayer; |
|
364 delete iCharFormatLayer; |
|
365 delete iColorList; |
|
366 delete iLogicalBorderProxy; |
|
367 delete iLafEnv; |
|
368 CRichText::DeactivateParserDefaults(); |
|
369 delete iOOMErrorText; |
|
370 if (iClockDll) |
|
371 iClockDll->Destroy(); |
|
372 RApaLsSession::ClearFsSession(); |
|
373 } |
|
374 |
|
375 /** |
|
376 Framework function |
|
377 */ |
|
378 EXPORT_C void CEikonEnv::DestroyEnvironment() |
|
379 { |
|
380 // CRichText::DeactivateParserDefaults must be called in DestroyEnvironment |
|
381 // rather than in the destructor as internally it calls virtual functions |
|
382 // that may (indirectly) use certain features of the CCoeEnv/CEIkonEnv |
|
383 // object (e.g. its focus-observers) |
|
384 CRichText::DeactivateParserDefaults(); |
|
385 |
|
386 User::Free(iKeyPressLabels); |
|
387 |
|
388 if (iAlertWin) |
|
389 iAlertWin->Release(); |
|
390 |
|
391 iAlertWin = NULL; |
|
392 iAlertWinInitialized = EFalse; |
|
393 |
|
394 if (iDebugKeys) |
|
395 { |
|
396 iDebugKeys->Release(); |
|
397 iDebugKeys = NULL; |
|
398 } |
|
399 |
|
400 delete iErrorIdler; |
|
401 iErrorIdler = NULL; |
|
402 |
|
403 if (iBitmapArray) |
|
404 { |
|
405 iBitmapArray->ResetAndDestroy(); |
|
406 delete iBitmapArray; |
|
407 iBitmapArray = NULL; |
|
408 } |
|
409 |
|
410 if (iInfoMsgWin) |
|
411 { |
|
412 iInfoMsgWin->Release(); |
|
413 iInfoMsgWin = NULL; // CEikonEnv::HandleError uses "!iInfoMsgWin" to test whether we are fully constructed or not, and thus whether the infra-structure is in place so that it can actually handle the error |
|
414 } |
|
415 |
|
416 BusyMsgCancel(); |
|
417 if (!LafEnv::PolicyItem(LafEnv::ELAfEnvPolicyDeferredEnvironmentDeletion)) |
|
418 { |
|
419 delete iExtension; |
|
420 iExtension = NULL; // NULL it here to prevent double-deletion of this member in ~CEikonEnv. |
|
421 } |
|
422 |
|
423 DeleteResourceFile(iSystemResourceFileOffset); |
|
424 // The order of destruction is important but doesn't really follow a clear logic |
|
425 // Some of the CCoeStatic are deleted before the libraries are closed because they may depend on them |
|
426 // On the other hand another set of CCoeStatic must be closed after the libraries are closed because the libraries depend on them |
|
427 // This was changed to fix a defect (DEF068403), hopefully there will be no cases where this fails, we may have to give up on trying to close |
|
428 // everything ourselves and just let the kernel do it |
|
429 CCoeEnv::DestroyEnvironmentStatic(); |
|
430 |
|
431 if (iFontArray) |
|
432 { |
|
433 LafEnv::ReleaseSystemFonts(*iFontArray); |
|
434 delete iFontArray; |
|
435 iFontArray = NULL; |
|
436 iNormalFont = NULL; // to prevent CCoeEnv also trying to release it |
|
437 } |
|
438 |
|
439 if (LafEnv::PolicyItem(LafEnv::ELAfEnvPolicyDeferredEnvironmentDeletion)) |
|
440 { |
|
441 if(!iAppUi) // Ensure libraries are deleted if we get a leave before the AppUi is set |
|
442 CloseLibraries(); |
|
443 } |
|
444 else |
|
445 CloseLibraries(); |
|
446 |
|
447 CCoeEnv::DestroyEnvironmentEnd(); |
|
448 delete this; |
|
449 } |
|
450 |
|
451 const TInt KUidBaflDllValue16 = 0x10003A0F; // !!! should be in BAERROR.H |
|
452 |
|
453 /** |
|
454 Handler for extended error codes. Passes aError to AppUi for handling first. |
|
455 @internalComponent |
|
456 @param aError - standard error code passed in |
|
457 @return - enumerated value (internalComponent - see baerrhand.h) |
|
458 */ |
|
459 TErrorHandlerResponse CEikonEnv::PrepareToHandleError(TInt aError) |
|
460 { |
|
461 // Note that ErrorText() and ErrorContextText() used below returns TDes reference, |
|
462 // that is used to set the texts in CCoeEnv. |
|
463 |
|
464 if (aError != KErrExtendedWithText) |
|
465 ErrorContextText().Zero(); |
|
466 |
|
467 const SExtendedError& extErr = CBaActiveScheduler::ExtendedError(); |
|
468 |
|
469 // Itterate over all AppUis (there may be nested embedded ones) |
|
470 // to allow one to override the error handling below. |
|
471 CEikAppUi* appUi = EikAppUi(); |
|
472 while (appUi) |
|
473 { |
|
474 TErrorHandlerResponse ret = appUi->HandleError(aError, extErr, ErrorText(), ErrorContextText()); |
|
475 if (ret != EErrorNotHandled) // Abort of the error was handled |
|
476 return ret; |
|
477 |
|
478 appUi = appUi->ContainerAppUi(); |
|
479 } |
|
480 |
|
481 TErrorHandlerResponse ret = EAlertDisplay; |
|
482 if (aError == KErrExtendedWithText) // Ignore the deprecated KErrExtendedWithText message |
|
483 return ret; |
|
484 |
|
485 // If the error was not explicitly handed by any AppUi |
|
486 |
|
487 TInt resourceId = iSystemResourceFileOffset+1-aError; |
|
488 if (aError==KErrExtended) // Handle legacy supprt for "KErrExtended" emitted by BAFL CBaActiveScheduler |
|
489 { |
|
490 if (extErr.iInformation) |
|
491 ret = EInfoDisplay; |
|
492 |
|
493 resourceId = extErr.iErrorNumber; |
|
494 switch (extErr.iComponent.iUid) |
|
495 { |
|
496 case 0: |
|
497 break; |
|
498 case KUidBaflDllValue16: |
|
499 resourceId += R_EIK_BAFL_ERROR_OFFSET; |
|
500 break; |
|
501 case KUidConeDllValue16: |
|
502 resourceId += R_EIK_CONE_ERROR_OFFSET; |
|
503 break; |
|
504 case KUidBaflErrorHandlerValue: |
|
505 ret = CBaErrorHandler::CallBack(extErr.iErrorNumber, ErrorText(), ErrorContextText()); |
|
506 if (ret != EErrorNotHandled) |
|
507 return ret; |
|
508 ret = EAlertDisplay; |
|
509 //fall through |
|
510 default: |
|
511 resourceId = iSystemResourceFileOffset+1-KErrUnknown; |
|
512 } |
|
513 |
|
514 ReadResource(ErrorText(),resourceId); // Read the error text from resource and set it as the error text |
|
515 } |
|
516 else if (aError == KErrNoMemory || extErr.iErrorNumber == KErrNoMemory) |
|
517 ErrorText() = *iOOMErrorText; // use pre-allocated text, as ReadResource may try to allocate memory |
|
518 else |
|
519 GetErrorText(ErrorText(), aError); |
|
520 |
|
521 return ret; |
|
522 } |
|
523 |
|
524 /** Handles an error that has occurred in the application. |
|
525 |
|
526 It first offers the error to the app UI's HandleError() function. If that |
|
527 does not handle it, this function displays an alert window or an info |
|
528 message containing some appropriate text, read from a system resource file. |
|
529 |
|
530 @param aError One of the standard system error codes. |
|
531 @publishedAll |
|
532 @released */ |
|
533 EXPORT_C void CEikonEnv::HandleError(TInt aError) |
|
534 { |
|
535 BusyMsgCancel(); |
|
536 if (aError == KLeaveWithoutAlert) |
|
537 return; |
|
538 |
|
539 if (!iInfoMsgWin) // not finished initializing |
|
540 { |
|
541 if (LafEnv::PolicyItem(LafEnv::ELafEnvPolicyExitIfErrorDuringStartup)) |
|
542 User::Exit(aError); // not finished initialising |
|
543 else |
|
544 return; |
|
545 } |
|
546 |
|
547 const TErrorHandlerResponse type = PrepareToHandleError(aError); |
|
548 DoHandleError(type); |
|
549 } |
|
550 |
|
551 /** Handles the specified error. |
|
552 |
|
553 This function reads the error context text from the resource identified by |
|
554 aContextResourceId. |
|
555 |
|
556 @param aError ID of the error to handle. |
|
557 @param aContextResourceId ID of the resource from which the context is read. */ |
|
558 EXPORT_C void CEikonEnv::HandleErrorWithContext(TInt aError, TInt aContextResourceId) |
|
559 { |
|
560 const TErrorHandlerResponse type = PrepareToHandleError(aError); |
|
561 if (!ErrorContextText().Length()) |
|
562 ReadResource(ErrorContextText(),aContextResourceId); |
|
563 |
|
564 DoHandleError(type); |
|
565 } |
|
566 |
|
567 |
|
568 void CEikonEnv::DoHandleError(TErrorHandlerResponse aType) |
|
569 { |
|
570 if (aType==EInfoDisplay) |
|
571 InfoMsg(ErrorText()); |
|
572 else if (aType==EAlertDisplay) |
|
573 { |
|
574 if (ErrorContextText().Length()) |
|
575 AlertWin(ErrorContextText(), ErrorText()); |
|
576 else |
|
577 AlertWin(ErrorText(), ErrorContextText()); |
|
578 } |
|
579 } |
|
580 |
|
581 /** Notifies this environment that an idle error occurred while redrawing was in |
|
582 progress. |
|
583 |
|
584 @param aError ID of the idle error. */ |
|
585 EXPORT_C void CEikonEnv::NotifyIdleErrorWhileRedrawing(TInt aError) |
|
586 { |
|
587 NotifyIdleError(aError,R_EIK_TBUF_ERROR_WHILE_REDRAWING); |
|
588 } |
|
589 |
|
590 /** Notifies this environment of an idle error. |
|
591 |
|
592 This function reads the error context text from the resource identified by aContextResourceId. |
|
593 Calling this method will only trigger one error dialog per minute. Calling it any more frequent |
|
594 will result in no action. |
|
595 |
|
596 @param aError ID of the idle error. |
|
597 @param aContextResourceId ID of the resource from which the context text is read. */ |
|
598 EXPORT_C void CEikonEnv::NotifyIdleError(TInt aError,TInt aContextResourceId) |
|
599 { |
|
600 TTime time; |
|
601 time.UniversalTime(); |
|
602 TTimeIntervalSeconds gap; |
|
603 const TInt err = time.SecondsFrom(iErrorIdler->iTime,gap); |
|
604 if (!err && gap < TTimeIntervalSeconds(60)) |
|
605 return; // less than one minute since previous notification |
|
606 |
|
607 iErrorIdler->iError = aError; |
|
608 iErrorIdler->iContext = aContextResourceId; |
|
609 iErrorIdler->iTime = time; |
|
610 iErrorIdler->Cancel(); |
|
611 iErrorIdler->Start(TCallBack(IdleErrorCallBack,this)); |
|
612 } |
|
613 |
|
614 |
|
615 /** |
|
616 Static callback function for use with Idle Object (iErrorIdler). |
|
617 Standard Symbian OS callback paradigm. |
|
618 @internalComponent |
|
619 @param aThis Pointer to self, requires casting to call non-static function |
|
620 @return always EFalse |
|
621 */ |
|
622 TInt CEikonEnv::IdleErrorCallBack(TAny* aThis) |
|
623 { // static |
|
624 CEikonEnv* self = (CEikonEnv*)aThis; |
|
625 self->HandleErrorWithContext(self->iErrorIdler->iError, self->iErrorIdler->iContext); |
|
626 return EFalse; // single shot callback |
|
627 } |
|
628 |
|
629 /** |
|
630 @publishedAll |
|
631 @deprecated |
|
632 */ |
|
633 EXPORT_C void CEikonEnv::LeaveWithErrorContext(TInt aError,const TDesC& aContextText) |
|
634 { |
|
635 GetErrorText(ErrorText(),aError); |
|
636 BaflUtils::CopyWithTruncation(ErrorContextText(),aContextText); |
|
637 User::Leave(KErrExtendedWithText); // Leave with a code of KErrExtendedWithText |
|
638 } |
|
639 |
|
640 |
|
641 /** Displays an error message appropriate to the error code aError in an alert window. |
|
642 The message is read from a resource file and has a maximum of 256 characters. |
|
643 |
|
644 @param aError Error code. |
|
645 @param aAppUid Application UID. By default, this is KNullUid. If a non null UID is |
|
646 specified and the error code is not known to UIKON, then the UID enables an |
|
647 application-specific error resource file to be scanned (if one exists) to try to |
|
648 resolve the error. */ |
|
649 EXPORT_C void CEikonEnv::ResolveError(TInt aError,TUid aAppUid) const |
|
650 { |
|
651 TBuf<KEikErrorResolverMaxTextLength> errText; |
|
652 GetErrorText(errText,aError,aAppUid); |
|
653 const_cast<CEikonEnv*>(this)->AlertWin(errText); |
|
654 } |
|
655 |
|
656 /** Gets the text for a standard error code. |
|
657 |
|
658 @param aDes On return, contains the error text. |
|
659 @param aError Error code. |
|
660 |
|
661 @publishedAll |
|
662 @released */ |
|
663 EXPORT_C void CEikonEnv::GetErrorText(TDes& aDes,TInt aError) const |
|
664 { |
|
665 GetErrorText(aDes,aError,KNullUid); |
|
666 } |
|
667 |
|
668 |
|
669 /** Gets the text for an error code, in the specified application. |
|
670 |
|
671 It returns whether the error code is valid or not. |
|
672 |
|
673 @param aDes On return, contains the error text. |
|
674 @param aError Error number. |
|
675 @param aAppUid Application UID. |
|
676 @return EErrorNumValid if the error code is valid, EErrorNumInvalid if the error code is invalid. |
|
677 |
|
678 @publishedAll |
|
679 @released */ |
|
680 EXPORT_C CEikonEnv::TErrorValidity CEikonEnv::GetErrorText(TDes& aDes,TInt aError,TUid aAppUid) const |
|
681 { |
|
682 CEikonEnv::TErrorValidity ret = CEikonEnv::EErrorNumValid; |
|
683 |
|
684 if (IsEiksrvThread()) // If this is the EikSrv, get the text directly from the error resolver... |
|
685 ret = const_cast<CEikonEnv*>(this)->iEikEnvExtra->iErrorResolver->ResolveError(aDes,aError,aAppUid); |
|
686 else // ... else connect to EikSrv and get the error text from it. |
|
687 { |
|
688 REikAppUiSession eiksrv; |
|
689 if (eiksrv.Connect()==KErrNone) |
|
690 { |
|
691 ret = eiksrv.ResolveError(aDes,aError,aAppUid); // This calls into EikSrv's copy of this method, see above. |
|
692 eiksrv.Close(); |
|
693 } |
|
694 else |
|
695 DoGetErrorText(aDes,aError); |
|
696 } |
|
697 return ret; |
|
698 } |
|
699 |
|
700 /** Gets the text for an error code, in the specified application. |
|
701 |
|
702 It returns whether the error code is valid or not. |
|
703 |
|
704 @param aErrorText On return, contains the error text. |
|
705 @param aError Error number. |
|
706 @param aTitleText On return, contains the title text of the error. |
|
707 @return EErrorNumValid if the error code is valid, EErrorNumInvalid if the error code is invalid. |
|
708 |
|
709 @publishedAll |
|
710 @released */ |
|
711 EXPORT_C CEikonEnv::TErrorValidity CEikonEnv::GetErrorTextAndTitle(TDes& aErrorText, TInt aError, TDes& aTitleText) const |
|
712 { |
|
713 TInt resId = 0; |
|
714 TUint flags = 0; |
|
715 return DoGetErrorTextAndTitle(aErrorText, aError, resId, flags, aTitleText); |
|
716 } |
|
717 |
|
718 |
|
719 /** |
|
720 N.B. This method is also called from the CTextResolver::DoResolveErrorStringL() |
|
721 in the textresolver.cpp, located in the tools/s60_header_compat component, part |
|
722 of the CoreOS agreement. |
|
723 |
|
724 @param aErrorText On return, contains the error text. |
|
725 @param aError Error number. |
|
726 @param aFlags Output parameter - Error Resource Flag. |
|
727 @param aTextId Output parameter - Error Text Resource Id. |
|
728 @param aTitleText On return, contains the title text of the error. |
|
729 |
|
730 @param aIsMemoryAllocatedByErrResolver is mainly used by the CTextResolver::DoResolveErrorStringL() to indicate that |
|
731 memory for error text is unlimited, ie., the memory for the error text is allocated by the text resolver. |
|
732 By default it is EFalse. |
|
733 @return EErrorNumValid if the error code is valid, EErrorNumInvalid if the error code is invalid. |
|
734 |
|
735 @internalTechnology */ |
|
736 EXPORT_C CEikonEnv::TErrorValidity CEikonEnv::DoGetErrorTextAndTitle(TDes& aErrorText, TInt aError, TInt& aTextId, TUint& aFlags, TDes& aTitleText, TBool aIsMemoryAllocatedByErrResolver) const |
|
737 { |
|
738 CEikonEnv::TErrorValidity errValidity = CEikonEnv::EErrorNumValid; |
|
739 |
|
740 if (IsEiksrvThread()) // If this is the EikSrv, get the text directly from the error resolver... |
|
741 errValidity = iEikEnvExtra->iErrorResolver->ResolveErrorWithTitle(aErrorText, aTitleText, aError, aTextId, aFlags, aIsMemoryAllocatedByErrResolver); |
|
742 else |
|
743 { |
|
744 // ... else connect to EikSrv and get the error text from it. |
|
745 REikAppUiSession eiksrv; |
|
746 TInt err = eiksrv.Connect(); |
|
747 if (!err) |
|
748 { |
|
749 TRAP(err, errValidity = eiksrv.ResolveErrorWithTitleL(aErrorText, aError, aTextId, aFlags, aTitleText, aIsMemoryAllocatedByErrResolver)); // This calls into EikSrv's copy if this method, see above. |
|
750 eiksrv.Close(); |
|
751 } |
|
752 } |
|
753 return errValidity; |
|
754 } |
|
755 |
|
756 EXPORT_C void CEikonEnv::DoGetErrorText(TDes& aDes, TInt aError) const |
|
757 /** Exported for testing only. |
|
758 @internalTechnology */ |
|
759 { |
|
760 const TInt error = ((aError > KErrNotFound || aError < KLastSystemWideErrCode) ? KErrUnknown : aError); |
|
761 ReadResource(aDes, iSystemResourceFileOffset+1-error); |
|
762 } |
|
763 |
|
764 EXPORT_C void CEikonEnv::SetAlertWin(MEikAlertWin* aAlertWin) |
|
765 /** Sets the enviroment's alert window. |
|
766 |
|
767 @param aAlertWin A custom alert window. |
|
768 |
|
769 @publishedPartner |
|
770 @released */ |
|
771 { |
|
772 if (iAlertWin) |
|
773 iAlertWin->Release(); |
|
774 |
|
775 iAlertWin = aAlertWin; |
|
776 } |
|
777 |
|
778 EXPORT_C void CEikonEnv::AlertWin(const TDesC& aMsg) |
|
779 /** Displays the environment's alert window containing a single line message. |
|
780 |
|
781 @param aMsg Message to be displayed in the alert window. */ |
|
782 { |
|
783 AlertWin(aMsg, TPtrC()); |
|
784 } |
|
785 |
|
786 EXPORT_C void CEikonEnv::AlertWin(const TDesC& aMsg1,const TDesC& aMsg2) |
|
787 /** Displays an alert window with a brief message. |
|
788 |
|
789 @param aMsg1 First line of the message. |
|
790 @param aMsg2 Second line of the message. */ |
|
791 { |
|
792 if (iAlertWinInitialized) |
|
793 iAlertWin->RunAlert(aMsg1, aMsg2); |
|
794 else |
|
795 LafEnv::DisplayAlertAsNotifier(aMsg1, aMsg2); |
|
796 } |
|
797 |
|
798 /** |
|
799 Framework function |
|
800 */ |
|
801 EXPORT_C void CEikonEnv::DestroyScreen() |
|
802 { |
|
803 if (iEikEnvExtra) |
|
804 { |
|
805 delete iEikEnvExtra->iAppServer; |
|
806 delete iEikEnvExtra->iViewActivator; |
|
807 delete iEikEnvExtra->iErrorResolver; |
|
808 delete iEikEnvExtra; |
|
809 iEikEnvExtra = NULL; |
|
810 } |
|
811 |
|
812 delete iProcess; // not before screen is destroyed, in case there are bitmap pictures in the document |
|
813 delete iWgName; // may be accessed during destruction of AppUi |
|
814 CCoeEnv::DestroyScreen(); |
|
815 } |
|
816 |
|
817 EXPORT_C void CEikonEnv::LeaveWithInfoMsg(TInt aResourceId,...) |
|
818 /** Displays a formatted information message and then leaves. |
|
819 |
|
820 @param aResourceId ID of a TBUF resource used to hold the string. |
|
821 @param ... List of items to be formatted. */ |
|
822 { |
|
823 if (aResourceId) |
|
824 { |
|
825 VA_LIST list; |
|
826 VA_START(list,aResourceId); |
|
827 InfoMsg(aResourceId,list); |
|
828 } |
|
829 CBaActiveScheduler::LeaveNoAlert(); |
|
830 } |
|
831 |
|
832 EXPORT_C void CEikonEnv::VerboseInfoMsg(const TDesC& aDes) |
|
833 /** Displays an information message if verbose information reporting has been set. |
|
834 |
|
835 The message is not displayed if verbose information reporting has not been |
|
836 set. |
|
837 |
|
838 @param aDes Message to display. */ |
|
839 { |
|
840 if (iEikonEnvFlags[EVerboseInfoReporting]) |
|
841 InfoMsg(aDes); |
|
842 } |
|
843 |
|
844 EXPORT_C void CEikonEnv::InfoMsg(const TDesC& aDes) |
|
845 /** Displays a message in the system default corner of the screen. |
|
846 |
|
847 The message disappears after a few seconds. |
|
848 |
|
849 @param aDes The message to display. */ |
|
850 { |
|
851 iInfoMsgWin->StartDisplay(aDes,EHRightVTop); |
|
852 } |
|
853 |
|
854 EXPORT_C void CEikonEnv::InfoMsgWithAlignment(TGulAlignment aCorner,const TDesC& aDes) |
|
855 /** Displays a message in the specified corner of the screen. |
|
856 |
|
857 The message disappears after a few seconds. |
|
858 |
|
859 @param aCorner The screen corner the message is displayed in. |
|
860 @param aDes The message to display. */ |
|
861 { |
|
862 iInfoMsgWin->StartDisplay(aDes,aCorner); |
|
863 } |
|
864 |
|
865 EXPORT_C void CEikonEnv::InfoMsg(TInt aResourceId,VA_LIST aList) |
|
866 /** Displays a message in the system default corner of the screen. |
|
867 |
|
868 A TBUF resource string is used to build the message at run-time from arbitrary |
|
869 data in a similar way to C's printf(). The message disappears after a few seconds. |
|
870 |
|
871 @param aResourceId ID of a TBUF resource used to hold the string. |
|
872 @param aList List of values to be formatted. */ |
|
873 { |
|
874 TEikInfoMsgBuf formatString; |
|
875 ReadResource(formatString,aResourceId); |
|
876 |
|
877 TEikInfoMsgBuf messageString; |
|
878 messageString.FormatList(formatString,aList); |
|
879 |
|
880 InfoMsg(messageString); |
|
881 } |
|
882 |
|
883 EXPORT_C void CEikonEnv::InfoMsg(TInt aResourceId,...) |
|
884 /** Displays a message in the system default corner of the screen. |
|
885 |
|
886 A TBUF resource string is used to build the message at run-time from arbitrary |
|
887 data in a similar way to C's printf(). The message disappears after a few seconds. |
|
888 |
|
889 @param aResourceId ID of a TBUF resource used to hold the string. |
|
890 @param ... List of items to be formatted. */ |
|
891 { |
|
892 VA_LIST list; |
|
893 VA_START(list,aResourceId); |
|
894 InfoMsg(aResourceId,list); |
|
895 } |
|
896 |
|
897 EXPORT_C void CEikonEnv::InfoMsgWithAlignment(TGulAlignment aCorner,TInt aResourceId,VA_LIST aList) |
|
898 /** Displays a message in the specified corner of the screen. |
|
899 |
|
900 The information message is built at run-time from a formatting string |
|
901 defined as a TBUF resource and a list of arbitrary data. |
|
902 |
|
903 @param aCorner The corner of the screen the message is displayed in. |
|
904 @param aResourceId ID of a TBUF resource used to hold the string. |
|
905 @param aList List of values to be formatted. */ |
|
906 { |
|
907 TEikInfoMsgBuf formatString; |
|
908 ReadResource(formatString,aResourceId); |
|
909 |
|
910 TEikInfoMsgBuf messageString; |
|
911 messageString.FormatList(formatString,aList); |
|
912 |
|
913 InfoMsgWithAlignment(aCorner,messageString); |
|
914 } |
|
915 |
|
916 EXPORT_C void CEikonEnv::InfoMsgWithAlignment(TGulAlignment aCorner,TInt aResourceId,...) |
|
917 /** Displays a message in the specified corner of the screen. |
|
918 |
|
919 The information message is built at run-time from a formatting string |
|
920 defined as a TBUF resource and a list of arbitrary data. |
|
921 |
|
922 @param aCorner The corner of the screen the message is displayed in. |
|
923 @param aResourceId ID of a TBUF resource used to hold the string. |
|
924 @param ... List of items to be formatted. */ |
|
925 { |
|
926 VA_LIST list; |
|
927 VA_START(list,aResourceId); |
|
928 InfoMsgWithAlignment(aCorner,aResourceId,list); |
|
929 } |
|
930 |
|
931 EXPORT_C void CEikonEnv::InfoMsgWithDuration(const TDesC& aDes, TTimeIntervalMicroSeconds32 aDuration) |
|
932 /** Displays an info message for a specified period. |
|
933 |
|
934 @param aDes Message to display. |
|
935 @param aDuration Duration of message. */ |
|
936 { |
|
937 iInfoMsgWin->StartDisplaySpecifyingDuration(aDes,EHRightVTop,aDuration); |
|
938 } |
|
939 |
|
940 EXPORT_C void CEikonEnv::InfoMsgWithDuration(TInt aResourceId, TTimeIntervalMicroSeconds32 aDuration,...) |
|
941 /** Displays an info message for a specified period. |
|
942 |
|
943 The text displayed is supplied in a resource file, as a string with some formatting |
|
944 information for extra arguments. These extra arguments are supplied through the |
|
945 variable argument list which is also passed into this function. |
|
946 |
|
947 @param aResourceId ID of a TBUF resource used to hold the string. |
|
948 @param aDuration Duration of the message. |
|
949 @param ... List of values to be formatted. */ |
|
950 { |
|
951 VA_LIST list; |
|
952 VA_START(list,aDuration); |
|
953 InfoMsgWithDuration(aResourceId,aDuration,list); |
|
954 } |
|
955 |
|
956 EXPORT_C void CEikonEnv::InfoMsgWithDuration(TInt aResourceId, TTimeIntervalMicroSeconds32 aDuration, VA_LIST aList) |
|
957 /** Displays an info message for a specified period. |
|
958 |
|
959 The text displayed is supplied in a resource file, as a string with some formatting |
|
960 information. Values for the formatting information are supplied as extra arguments. |
|
961 These extra arguments are packaged in a VA_LIST object which is also passed |
|
962 into this function. |
|
963 |
|
964 @param aResourceId ID of a TBUF resource used to hold the string. |
|
965 @param aDuration Duration of message. |
|
966 @param aList List of values. */ |
|
967 { |
|
968 TEikInfoMsgBuf formatString; |
|
969 ReadResource(formatString,aResourceId); |
|
970 |
|
971 TEikInfoMsgBuf messageString; |
|
972 messageString.FormatList(formatString,aList); |
|
973 |
|
974 InfoMsgWithDuration(messageString,aDuration); |
|
975 } |
|
976 |
|
977 EXPORT_C void CEikonEnv::InfoMsgWithAlignmentAndDuration(TGulAlignment aCorner,const TDesC& aDes, TTimeIntervalMicroSeconds32 aDuration) |
|
978 /** Displays an info message with a specified alignment for a specified period. |
|
979 |
|
980 The text displayed is supplied in a descriptor argument, and aligned using |
|
981 the aCorner parameter. |
|
982 |
|
983 @param aCorner The screen corner the message is displayed in. |
|
984 @param aDes Message to display. |
|
985 @param aDuration Duration of message. */ |
|
986 { |
|
987 iInfoMsgWin->StartDisplaySpecifyingDuration(aDes,aCorner,aDuration); |
|
988 } |
|
989 |
|
990 EXPORT_C void CEikonEnv::InfoMsgWithAlignmentAndDuration(TGulAlignment aCorner,TInt aResourceId, TTimeIntervalMicroSeconds32 aDuration,...) |
|
991 /** Displays an info message with a specified alignment for a specified period. |
|
992 |
|
993 The text displayed is supplied in a resource file, as a string with some formatting |
|
994 information for extra arguments. These extra arguments are supplied through the |
|
995 variable argument list which is also passed into this function. The text is aligned |
|
996 using the aCorner parameter. |
|
997 |
|
998 @param aCorner The screen corner the message is displayed in. |
|
999 @param aResourceId ID of a TBUF resource used to contain the string. |
|
1000 @param aDuration Duration of message. |
|
1001 @param ... List of values to be formatted. */ |
|
1002 { |
|
1003 VA_LIST list; |
|
1004 VA_START(list,aDuration); |
|
1005 InfoMsgWithAlignmentAndDuration(aCorner,aResourceId,aDuration,list); |
|
1006 } |
|
1007 |
|
1008 EXPORT_C void CEikonEnv::InfoMsgWithAlignmentAndDuration(TGulAlignment aCorner,TInt aResourceId, TTimeIntervalMicroSeconds32 aDuration,VA_LIST aList) |
|
1009 /** Displays an info message with a specified alignment for a specified period. |
|
1010 |
|
1011 The text displayed is supplied in a resource file, as a string with some formatting |
|
1012 information. Values for the formatting information are supplied as extra arguments. |
|
1013 These extra arguments are packaged in a VA_LIST object which is also passed |
|
1014 into this function. The text is aligned using the aCorner parameter. |
|
1015 |
|
1016 @param aCorner The screen corner the message is displayed in. |
|
1017 @param aResourceId ID of a TBUF resource used to contain the string. |
|
1018 @param aDuration Duration of message. |
|
1019 @param aList List of values. */ |
|
1020 { |
|
1021 TEikInfoMsgBuf formatString; |
|
1022 ReadResource(formatString,aResourceId); |
|
1023 |
|
1024 TEikInfoMsgBuf messageString; |
|
1025 messageString.FormatList(formatString,aList); |
|
1026 |
|
1027 InfoMsgWithAlignmentAndDuration(aCorner,messageString,aDuration); |
|
1028 } |
|
1029 |
|
1030 EXPORT_C void CEikonEnv::InfoMsgCancel() |
|
1031 /** Cancels the currently displaying information message. */ |
|
1032 { |
|
1033 if (iInfoMsgWin) |
|
1034 iInfoMsgWin->CancelDisplay(); |
|
1035 } |
|
1036 |
|
1037 |
|
1038 /** |
|
1039 @internalComponent |
|
1040 Sets up iBusyMsgWin (pointer to non-owned interface) |
|
1041 */ |
|
1042 void CEikonEnv::PrepareBusyMsgL() |
|
1043 { |
|
1044 if(!iBusyMsgWin) |
|
1045 iBusyMsgWin = LafEnv::NewBusyMsgWinL(*this); |
|
1046 } |
|
1047 |
|
1048 EXPORT_C void CEikonEnv::BusyMsgL(const TDesC& aDes) |
|
1049 /** Displays a flashing busy message in the system default corner of the screen. |
|
1050 |
|
1051 @param aDes Message to display. */ |
|
1052 { |
|
1053 PrepareBusyMsgL(); |
|
1054 iBusyMsgWin->StartDisplay(aDes,LafEnv::DefaultBusyMsgCorner()); |
|
1055 } |
|
1056 |
|
1057 EXPORT_C void CEikonEnv::BusyMsgL(const TDesC& aDes,TGulAlignment aCorner) |
|
1058 /** Displays a flashing busy message in the specified corner of the screen. |
|
1059 |
|
1060 @param aDes Message to display. |
|
1061 @param aCorner Corner of the screen in which to display the message. */ |
|
1062 { |
|
1063 PrepareBusyMsgL(); |
|
1064 iBusyMsgWin->StartDisplay(aDes,aCorner); |
|
1065 } |
|
1066 |
|
1067 EXPORT_C void CEikonEnv::BusyMsgL(TInt aResourceId) |
|
1068 /** Displays a flashing busy message in the system default corner of the screen. |
|
1069 |
|
1070 The message's text is read from resource. |
|
1071 |
|
1072 @param aResourceId ID of the resource that specifies the text to display. */ |
|
1073 { |
|
1074 TEikBusyMsgBuf msg; |
|
1075 ReadResource(msg,aResourceId); |
|
1076 BusyMsgL(msg); |
|
1077 } |
|
1078 |
|
1079 EXPORT_C void CEikonEnv::BusyMsgL(const TDesC& aDes,TTimeIntervalMicroSeconds32 aInitialDelay) |
|
1080 /** Displays a flashing busy message in the system default corner of the screen for a specific amount of time. |
|
1081 |
|
1082 @param aDes Message to display. |
|
1083 @param aInitialDelay Delay in microseconds before the message is first shown. */ |
|
1084 { |
|
1085 BusyMsgL(aDes,LafEnv::DefaultBusyMsgCorner(),aInitialDelay); |
|
1086 } |
|
1087 |
|
1088 EXPORT_C void CEikonEnv::BusyMsgL(const TDesC& aDes,TGulAlignment aCorner,TTimeIntervalMicroSeconds32 aInitialDelay) |
|
1089 /** Displays a flashing busy message for a specific amount of time in the corner of the screen indicated by aCorner. |
|
1090 |
|
1091 @param aDes Message to display. |
|
1092 @param aCorner Corner of the screen in which to display the message. |
|
1093 @param aInitialDelay Delay in microseconds before the message is first shown. */ |
|
1094 { |
|
1095 PrepareBusyMsgL(); |
|
1096 iBusyMsgWin->StartDisplaySpecifyingInitialDelay(aDes,aCorner,aInitialDelay); |
|
1097 } |
|
1098 |
|
1099 EXPORT_C void CEikonEnv::BusyMsgL(TInt aResourceId,TTimeIntervalMicroSeconds32 aInitialDelay) |
|
1100 /** Displays a flashing busy message in the system default corner of the screen for a specific amount of time. |
|
1101 |
|
1102 The message's text is read from resource. |
|
1103 |
|
1104 @param aInitialDelay Delay in microseconds before the message is first shown. |
|
1105 @param aResourceId The ID of a text resource specifying the message text. */ |
|
1106 { |
|
1107 TEikBusyMsgBuf msg; |
|
1108 ReadResource(msg,aResourceId); |
|
1109 BusyMsgL(msg,aInitialDelay); |
|
1110 } |
|
1111 |
|
1112 EXPORT_C void CEikonEnv::BusyMsgCancel() |
|
1113 /** Cancels any existing busy message. */ |
|
1114 { |
|
1115 if(iBusyMsgWin) |
|
1116 iBusyMsgWin->Release(); |
|
1117 |
|
1118 iBusyMsgWin = NULL; |
|
1119 } |
|
1120 |
|
1121 EXPORT_C void CEikonEnv::AddAutoMenuTitleL(CEikAutoMenuTitle* aTitle) |
|
1122 /** Adds a menu title to the menu bar for all applications. |
|
1123 |
|
1124 Takes ownership of aTitle at the end of the function. Push the |
|
1125 CEikAutoMenuTitle object on the cleanup stack before calling this method, |
|
1126 and pop it after. |
|
1127 |
|
1128 @param aTitle Menu title to add to all applications' menu bars. |
|
1129 @publishedPartner |
|
1130 @released */ |
|
1131 { |
|
1132 if (!iAutoMenuTitleArray) |
|
1133 iAutoMenuTitleArray = new(ELeave) CEikAutoMenuTitleArray(); |
|
1134 |
|
1135 iAutoMenuTitleArray->AppendL(aTitle); |
|
1136 } |
|
1137 |
|
1138 EXPORT_C TEikVirtualCursor& CEikonEnv::VirtualCursor() |
|
1139 /** Gets the virtual cursor. |
|
1140 |
|
1141 @return Virtual cursor. */ |
|
1142 { |
|
1143 return iVirtualCursor; |
|
1144 } |
|
1145 |
|
1146 |
|
1147 /** |
|
1148 @internalTechnology |
|
1149 */ |
|
1150 void CEikonEnv::UpdateColorListL() |
|
1151 { |
|
1152 if (!iColorList) |
|
1153 User::Leave(KErrNotFound); |
|
1154 |
|
1155 LafEnv::UpdateColorListL( iColorList ); |
|
1156 LafEnv::UpdateSystemBitmapsL(*this, *iBitmapArray, *iColorList); |
|
1157 } |
|
1158 |
|
1159 /** |
|
1160 Calls Laf implementation of UpdateSystemFontsL() to update local array of system fonts |
|
1161 */ |
|
1162 EXPORT_C void CEikonEnv::UpdateSystemFontsL() |
|
1163 { |
|
1164 LafEnv::UpdateSystemFontsL( this, *iFontArray ); |
|
1165 } |
|
1166 |
|
1167 /** Emits a beep. |
|
1168 |
|
1169 This method is deprecated. |
|
1170 |
|
1171 @deprecated */ |
|
1172 EXPORT_C void CEikonEnv::Beep() |
|
1173 { // static |
|
1174 LafEnv::Beep(); |
|
1175 } |
|
1176 |
|
1177 /** |
|
1178 Framework function |
|
1179 */ |
|
1180 EXPORT_C TInt CEikonEnv::ResourceFileVersionNumber() const |
|
1181 { |
|
1182 return EEikResourceSignatureValue; |
|
1183 } |
|
1184 |
|
1185 EXPORT_C void CEikonEnv::AddWindowShadow(CCoeControl* aWinArea) |
|
1186 /** Adds a window shadow of the standard height to a control. */ |
|
1187 { |
|
1188 aWinArea->DrawableWindow()->SetShadowHeight(LafEnv::ShadowHeight()); |
|
1189 } |
|
1190 |
|
1191 |
|
1192 EXPORT_C void CEikonEnv::SetDebugKeys(MEikDebugKeys* aDebugKeys) |
|
1193 /** Sets a debug keys object. This function enables the default debug |
|
1194 keys to be overridden with custom ones. The debug keys object only receives |
|
1195 key events in debug builds or, in release builds, if the |
|
1196 CEikDebugPreferences::EFlagDebugKeysOn flag has been set. |
|
1197 |
|
1198 Must be called before the environment object has been fully constructed, e.g. |
|
1199 from a control (widget) library initialisation function, or it will have no effect. |
|
1200 Must be called only once. |
|
1201 |
|
1202 @param aDebugKeys A custom debug keys object. |
|
1203 @publishedPartner |
|
1204 @released */ |
|
1205 { |
|
1206 // Prevent malicious code from resetting the debug keys |
|
1207 __ASSERT_ALWAYS(!iDebugKeys && aDebugKeys, Panic(EEikPanicDebugKeysAlreadySet)); |
|
1208 iDebugKeys = aDebugKeys; |
|
1209 } |
|
1210 |
|
1211 /** Called by the framework to finish environment construction once the control stack |
|
1212 has been created and is ready. |
|
1213 */ |
|
1214 EXPORT_C void CEikonEnv::ControlStackReadyL() |
|
1215 { |
|
1216 InitDebugKeysL(); |
|
1217 InitAlertWinL(); |
|
1218 ASSERT(!iErrorIdler); // Assert called only once |
|
1219 iErrorIdler = CEikErrorIdler::NewL(); |
|
1220 } |
|
1221 |
|
1222 /** |
|
1223 @internalTechnology |
|
1224 */ |
|
1225 void CEikonEnv::InitDebugKeysL() |
|
1226 { |
|
1227 if (IsEiksrvThread()) |
|
1228 { |
|
1229 //create CEikDebugPreferences object locally for eiksrv thread |
|
1230 CEikDebugPreferences* const debugPreferences = CEikDebugPreferences::NewLC(); |
|
1231 TRAPD(err, debugPreferences->RestoreL(FsSession())); |
|
1232 if (err == KErrNoMemory) // ignore other errors |
|
1233 User::Leave(err); |
|
1234 |
|
1235 const TUint flags = debugPreferences->Flags(); |
|
1236 #ifndef _DEBUG |
|
1237 if (flags & CEikDebugPreferences::EFlagDebugKeysOn) |
|
1238 #endif |
|
1239 { |
|
1240 ASSERT(iDebugKeys); |
|
1241 iDebugKeys->ConstructL(); // after control stack initialized |
|
1242 } |
|
1243 CleanupStack::PopAndDestroy(debugPreferences); |
|
1244 } |
|
1245 else |
|
1246 { |
|
1247 REikAppUiSession uiSession; |
|
1248 User::LeaveIfError(uiSession.Connect()); |
|
1249 CleanupClosePushL(uiSession); |
|
1250 |
|
1251 //Get debug preferences object from uikon server. |
|
1252 CEikDebugPreferences* const debugPreferences = uiSession.GetDebugPreferencesL(); |
|
1253 CleanupStack::PushL(debugPreferences); |
|
1254 |
|
1255 if (debugPreferences->Flags() & CEikDebugPreferences::EFlagDebugKeysOn) |
|
1256 { |
|
1257 ASSERT(iDebugKeys); |
|
1258 iDebugKeys->ConstructL(); // after control stack initialized |
|
1259 } |
|
1260 CleanupStack::PopAndDestroy(2); //debugPreferences & uiSession |
|
1261 } |
|
1262 } |
|
1263 |
|
1264 |
|
1265 EXPORT_C void CEikonEnv::ConstructL() |
|
1266 /** Second-phase constructor. |
|
1267 |
|
1268 This calls the next overload with ETrue as the parameter. */ |
|
1269 { |
|
1270 ConstructL(ETrue); |
|
1271 } |
|
1272 |
|
1273 EXPORT_C void CEikonEnv::ConstructL(TBool aInitialFocusState) |
|
1274 /** Second-phase constructor. |
|
1275 |
|
1276 Calls the next overload with a default window group ID which will be ignored. |
|
1277 |
|
1278 @param aInitialFocusState The window group's initial focus state. If ETrue, keyboard |
|
1279 focus is enabled, if EFalse, keyboard focus is disabled. */ |
|
1280 { |
|
1281 ConstructL(aInitialFocusState, 0); // 0 is not a valid window group ID and will be ignored |
|
1282 } |
|
1283 |
|
1284 /** Second-phase constructor. |
|
1285 |
|
1286 @param aInitialFocusState The window group's initial focus state. If ETrue, keyboard |
|
1287 focus is enabled, if EFalse, keyboard focus is disabled. |
|
1288 @param aWindowGroupID The window group ID of the parent window */ |
|
1289 EXPORT_C void CEikonEnv::ConstructL(TBool aInitialFocusState, TInt aWindowGroupID) |
|
1290 { |
|
1291 // iEikEnvExtra might have been created in ConstructAppFromCommandLineL() so check for |
|
1292 // existence before allocating it. |
|
1293 if(!iEikEnvExtra) |
|
1294 iEikEnvExtra = CEikEnvExtra::NewL(*this); |
|
1295 |
|
1296 LafEnv::HandleExtensionEventL(*this, LafEnv::ELafEnvPreCoeEnvConstructL ); |
|
1297 CCoeEnv::ConstructL(aInitialFocusState, iEikEnvExtra->iDefaultScreenNumber, aWindowGroupID); // Added May 04 - support for Multiple screens. |
|
1298 RApaLsSession::SetFsSessionL(FsSession()); |
|
1299 LafEnv::HandleExtensionEventL(*this, LafEnv::ELafEnvPostCoeEnvConstructL ); |
|
1300 const TBool isEiksrv = IsEiksrvThread(); |
|
1301 // Enable wserv priority control on apps. |
|
1302 if(!isEiksrv) |
|
1303 User::SetPriorityControl(ETrue); |
|
1304 |
|
1305 if (isEiksrv) |
|
1306 { |
|
1307 iEikEnvExtra->iErrorResolver=CEikErrorResolver::NewL(*this); |
|
1308 iEikEnvExtra->iAppLanguage = User::Language(); |
|
1309 if (iEikEnvExtra->iAppLanguage != ELangNone) |
|
1310 { |
|
1311 // set the app language in baflutils, this is used in order to load the correct language |
|
1312 // resource files |
|
1313 BaflUtils::SetIdealLanguage(iEikEnvExtra->iAppLanguage); |
|
1314 } |
|
1315 } |
|
1316 |
|
1317 InitColorSchemeL(); |
|
1318 LoadParserListL(); |
|
1319 iLafEnv = new(ELeave) CEikLafEnv(); |
|
1320 iEditableControlStandardHeight = LafEnv::EditableControlStandardHeight(*iLafEnv); |
|
1321 InitSystemBitmapsL(); |
|
1322 iWgName = CApaWindowGroupName::NewL(iWsSession); |
|
1323 ReadResourceL(iNudgeChars,R_EIK_TBUF_NUDGE_CHARS); |
|
1324 iVirtualCursor.SetCursorStateL(TEikVirtualCursor::EOff, *this); |
|
1325 LoadLibrariesL(); |
|
1326 |
|
1327 // Create a CEikLogicalBorder that implements the MGulLogicalBorder interface and forward |
|
1328 // the calls to the LafEnv object that actually implementing the functionality |
|
1329 iLogicalBorderProxy = new(ELeave) CEikLogicalBorderProxy(); |
|
1330 GulTls::SetLogicalBorder(iLogicalBorderProxy); |
|
1331 |
|
1332 iOOMErrorText = AllocReadResourceL(iSystemResourceFileOffset+1-KErrNoMemory); |
|
1333 InitInfoMsgL(); // CEikonEnv::HandleError relies on this being the last thing to be constructed (it uses it to test whether it has been fully constructed or not, and thus whether the infra-structure is in place so that it can actually handle the error) |
|
1334 } |
|
1335 |
|
1336 |
|
1337 /** |
|
1338 @internalComponent |
|
1339 */ |
|
1340 LOCAL_C void DeletePointerToPointer(TAny* aPointerToPointer) |
|
1341 { |
|
1342 delete *STATIC_CAST(CBase**, aPointerToPointer); |
|
1343 } |
|
1344 |
|
1345 /** |
|
1346 @internalComponent |
|
1347 */ |
|
1348 LOCAL_C void RemoveResourceFile(TAny* aResourceFile) |
|
1349 { |
|
1350 CCoeEnv::Static()->DeleteResourceFile(REINTERPRET_CAST(TInt, aResourceFile)); |
|
1351 } |
|
1352 |
|
1353 /** |
|
1354 @internalComponent |
|
1355 */ |
|
1356 LOCAL_C void DeleteArrayOfResourceFilesRemovingEach(CCoeEnv& aCoeEnv, CArrayFix<TInt>* aArrayOfResourceFiles) |
|
1357 { |
|
1358 for (TInt i=aArrayOfResourceFiles->Count()-1; i>=0; --i) |
|
1359 { |
|
1360 aCoeEnv.DeleteResourceFile((*aArrayOfResourceFiles)[i]); |
|
1361 } |
|
1362 delete aArrayOfResourceFiles; |
|
1363 } |
|
1364 |
|
1365 /** |
|
1366 @internalComponent |
|
1367 */ |
|
1368 LOCAL_C void DeleteArrayOfResourceFilesRemovingEach(TAny* aArrayOfResourceFiles) |
|
1369 { |
|
1370 DeleteArrayOfResourceFilesRemovingEach(*CCoeEnv::Static(), STATIC_CAST(CArrayFix<TInt>*, aArrayOfResourceFiles)); |
|
1371 } |
|
1372 |
|
1373 /** |
|
1374 @internalComponent |
|
1375 */ |
|
1376 LOCAL_C void CleanupEComImplInfoArray(TAny* aObject) |
|
1377 // |
|
1378 // Used for cleanup of objects on stack if a function leaves. |
|
1379 // |
|
1380 { |
|
1381 reinterpret_cast<RImplInfoPtrArray*>(aObject)->ResetAndDestroy(); |
|
1382 } |
|
1383 |
|
1384 |
|
1385 /** |
|
1386 This function forms part of the construction process (called by ConstructL) |
|
1387 Creates and populates array of libaries. |
|
1388 Loads ECOM plugins with interface UID KUikonLibraryUid |
|
1389 Adds control factories to control factory array. |
|
1390 Adds resource file offsets to resource file offset array |
|
1391 |
|
1392 @internalComponent |
|
1393 */ |
|
1394 void CEikonEnv::LoadLibrariesL() |
|
1395 { |
|
1396 // Create array to store CEikLibrary classes |
|
1397 iLibraries = new(ELeave) CArrayPtrFlat<CEikLibrary>(1); |
|
1398 |
|
1399 // Create the array for holding control (widget) factories. |
|
1400 ASSERT(!iControlFactoryFuncArray); |
|
1401 CArrayFix<TCreateByTypeFunction>* controlFactoryFuncArray = new(ELeave) CArrayFixFlat<TCreateByTypeFunction>(2); |
|
1402 CleanupStack::PushL(TCleanupItem(DeletePointerToPointer, &controlFactoryFuncArray)); |
|
1403 |
|
1404 // Create the array for holding resource file offsets |
|
1405 ASSERT(!iResourceFileOffsetArray); |
|
1406 CArrayFix<TInt>* resourceFileOffsetArray=new(ELeave) CArrayFixFlat<TInt>(2); |
|
1407 CleanupStack::PushL(TCleanupItem(DeleteArrayOfResourceFilesRemovingEach, resourceFileOffsetArray)); |
|
1408 |
|
1409 // Get the list of all ECOM control factory plug-ins |
|
1410 RImplInfoPtrArray plugInArray; |
|
1411 REComSession::ListImplementationsL(KUikonLibraryUid,plugInArray); |
|
1412 |
|
1413 // Push the plugin array on the stack |
|
1414 CleanupStack::PushL(TCleanupItem(CleanupEComImplInfoArray, &plugInArray)); |
|
1415 const TInt numLibsToLoad = plugInArray.Count(); |
|
1416 // if the plugin count is zero dont load any thing |
|
1417 for(TInt i = 0; i < numLibsToLoad; i++) |
|
1418 { |
|
1419 TUid implementationUid = plugInArray[i]->ImplementationUid(); |
|
1420 CEikLibrary2* eikLibrary = CEikLibrary2::LoadLibraryL(implementationUid); |
|
1421 __ASSERT_ALWAYS(eikLibrary, Panic(EEikPanicNoLibraryEntryPoint)); |
|
1422 |
|
1423 CleanupStack::PushL(eikLibrary); |
|
1424 iLibraries->AppendL(eikLibrary); |
|
1425 CleanupStack::Pop(eikLibrary); |
|
1426 |
|
1427 eikLibrary->InitializeL(); |
|
1428 |
|
1429 // Append each of the plug-in's control factories to the common list of factories |
|
1430 CArrayFix<TCreateByTypeFunction>* ctrlFactories = eikLibrary->ControlFactoryArrayL(); |
|
1431 if (ctrlFactories) |
|
1432 { |
|
1433 // we already have a control factory array so add any new factories to this |
|
1434 CleanupStack::PushL(ctrlFactories); |
|
1435 |
|
1436 TInt count = ctrlFactories->Count(); |
|
1437 for (TInt jj = 0; jj < count; jj++) |
|
1438 controlFactoryFuncArray->AppendL((*ctrlFactories)[jj]); |
|
1439 |
|
1440 CleanupStack::PopAndDestroy(ctrlFactories); |
|
1441 ctrlFactories = NULL; // don't use below |
|
1442 } |
|
1443 |
|
1444 // Load the resource files associated with the control factories |
|
1445 CArrayFix<TFileName>* resFiles = eikLibrary->ResourceFileArrayL(); |
|
1446 if(resFiles) |
|
1447 { |
|
1448 CleanupStack::PushL(resFiles); |
|
1449 const TInt count = resFiles->Count(); |
|
1450 for(TInt ii = 0; ii < count; ii++) |
|
1451 { |
|
1452 TFileName& name = (*resFiles)[ii]; |
|
1453 if(name.Length()) |
|
1454 { |
|
1455 BaflUtils::NearestLanguageFile(FsSession(),name); |
|
1456 const TInt offset = AddResourceFileL(name); |
|
1457 CleanupStack::PushL(TCleanupItem(RemoveResourceFile, reinterpret_cast<TAny*>(offset))); |
|
1458 resourceFileOffsetArray->AppendL(offset); |
|
1459 CleanupStack::Pop(reinterpret_cast<TAny*>(offset)); |
|
1460 } |
|
1461 } |
|
1462 CleanupStack::PopAndDestroy(resFiles); |
|
1463 resFiles = NULL; // don't use below |
|
1464 } |
|
1465 } |
|
1466 |
|
1467 CleanupStack::Pop(&plugInArray); |
|
1468 plugInArray.ResetAndDestroy(); |
|
1469 plugInArray.Close(); |
|
1470 |
|
1471 iControlFactoryFuncArray = controlFactoryFuncArray; |
|
1472 iResourceFileOffsetArray = resourceFileOffsetArray; |
|
1473 CleanupStack::Pop(2, &controlFactoryFuncArray); |
|
1474 iAutoLoadedResourceFiles = resourceFileOffsetArray->Count(); // use this count to check that additional libraries have been removed on close |
|
1475 iAutoLoadedControlFactories = controlFactoryFuncArray->Count(); // use this count to check that additional libraries have been removed on close |
|
1476 } |
|
1477 |
|
1478 /** |
|
1479 Returns control factory function array (pointer) |
|
1480 @internalTechnology |
|
1481 */ |
|
1482 CArrayFix<TCreateByTypeFunction>* CEikonEnv::ControlFactoryFuncArray() const |
|
1483 { |
|
1484 return iControlFactoryFuncArray; |
|
1485 } |
|
1486 |
|
1487 |
|
1488 /** |
|
1489 Deletes arrays of resource file offsets, Control Factory functions and libraries. |
|
1490 @internalComponent |
|
1491 */ |
|
1492 void CEikonEnv::CloseLibraries() |
|
1493 { |
|
1494 // Delete the dynamic DLL-owned resource files |
|
1495 if(iResourceFileOffsetArray) |
|
1496 { |
|
1497 __ASSERT_DEBUG(iResourceFileOffsetArray->Count() <= iAutoLoadedResourceFiles, Panic(EEikPanicResourceFileNotRemoved)); |
|
1498 DeleteArrayOfResourceFilesRemovingEach(iResourceFileOffsetArray); |
|
1499 } |
|
1500 |
|
1501 // Assert all libraries loaded by the application developer has be closed |
|
1502 __ASSERT_DEBUG((!iControlFactoryFuncArray) || (iControlFactoryFuncArray->Count() <= iAutoLoadedControlFactories), Panic(EEikPanicControlFactoryNotRemoved)); |
|
1503 delete iControlFactoryFuncArray; |
|
1504 |
|
1505 // Delete all DLL-owned data |
|
1506 if(iLibraries) |
|
1507 { |
|
1508 const TInt count = iLibraries->Count(); |
|
1509 for(TInt ii = 0; ii < count; ii++) |
|
1510 delete (*iLibraries)[ii]; |
|
1511 delete iLibraries; |
|
1512 } |
|
1513 } |
|
1514 |
|
1515 |
|
1516 /** |
|
1517 Calls (virtual) PostAppUiInitializeL on all loaded libraries. |
|
1518 |
|
1519 @internalTechnology |
|
1520 @see CEikLibrary::PostAppUiInitializeL |
|
1521 */ |
|
1522 void CEikonEnv::PostAppUiInitializeL() |
|
1523 { |
|
1524 if(iLibraries) |
|
1525 { |
|
1526 const TInt count = iLibraries->Count(); |
|
1527 for(TInt ii = 0; ii < count; ii++) |
|
1528 { |
|
1529 TRAP_IGNORE((*iLibraries)[ii]->PostAppUiInitializeL()); |
|
1530 } |
|
1531 } |
|
1532 } |
|
1533 |
|
1534 |
|
1535 EXPORT_C TInt CEikonEnv::AddLibraryL(TCreateByTypeFunction aControlFactory, TFileName* aResourceFile) |
|
1536 /** Adds the control factory and resource file to the Eikon Environment. |
|
1537 This function does not add the control factory if it is NULL. |
|
1538 |
|
1539 @param aControlFactory Control factory that has to be added to the Eikon Environment. |
|
1540 @param aResourceFile Resource file that has to be added to the Eikon Environment. |
|
1541 @return Zero, if the resource file is NULL otherwise the offset value defined for this resource file. |
|
1542 |
|
1543 @publishedPartner |
|
1544 @released |
|
1545 */ |
|
1546 { |
|
1547 TInt resourceFileOffset=0; |
|
1548 // Add control factory function |
|
1549 if(aControlFactory) |
|
1550 { |
|
1551 ASSERT(iControlFactoryFuncArray); |
|
1552 iControlFactoryFuncArray->AppendL(aControlFactory); |
|
1553 iAutoLoadedControlFactories++; |
|
1554 } |
|
1555 |
|
1556 // Add resource file |
|
1557 if(aResourceFile && aResourceFile->Length()) |
|
1558 { |
|
1559 ASSERT(iResourceFileOffsetArray); |
|
1560 BaflUtils::NearestLanguageFile(FsSession(),*aResourceFile); |
|
1561 resourceFileOffset = AddResourceFileL(*aResourceFile); |
|
1562 iResourceFileOffsetArray->AppendL(resourceFileOffset); |
|
1563 iAutoLoadedResourceFiles++; |
|
1564 } |
|
1565 |
|
1566 // Must be stored by calling application |
|
1567 // and used when calling RemoveLibrary |
|
1568 return resourceFileOffset; |
|
1569 } |
|
1570 |
|
1571 EXPORT_C void CEikonEnv::RemoveLibrary(TCreateByTypeFunction aControlFactory, TInt aResourceFileOffset) |
|
1572 /** |
|
1573 @internalTechnology |
|
1574 */ |
|
1575 { |
|
1576 if(aControlFactory) |
|
1577 { |
|
1578 ASSERT(iControlFactoryFuncArray); |
|
1579 const TInt count = iControlFactoryFuncArray->Count() - 1; |
|
1580 for(TInt ii = count; ii > 0; ii--) |
|
1581 { |
|
1582 if((*iControlFactoryFuncArray)[ii] == aControlFactory) |
|
1583 { |
|
1584 iControlFactoryFuncArray->Delete(ii); |
|
1585 break; |
|
1586 } |
|
1587 } |
|
1588 } |
|
1589 |
|
1590 if(aResourceFileOffset) |
|
1591 { |
|
1592 ASSERT(iResourceFileOffsetArray); |
|
1593 const TInt count = iResourceFileOffsetArray->Count() - 1; |
|
1594 for(TInt jj = count; jj > 0; jj--) |
|
1595 { |
|
1596 if((*iResourceFileOffsetArray)[jj] == aResourceFileOffset) |
|
1597 { |
|
1598 DeleteResourceFile(aResourceFileOffset); |
|
1599 iResourceFileOffsetArray->Delete(jj); |
|
1600 break; |
|
1601 } |
|
1602 } |
|
1603 } |
|
1604 } |
|
1605 |
|
1606 |
|
1607 /** |
|
1608 @internalComponent |
|
1609 */ |
|
1610 void CEikonEnv::InitSystemResourceFileL() |
|
1611 { |
|
1612 iSystemResourceFileOffset = LafEnv::LoadCoreResFileL(*this); |
|
1613 iKeyPressLabels = AllocReadResourceAsDes8L(R_EIK_KEYPRESS_LABELS); |
|
1614 } |
|
1615 |
|
1616 /** |
|
1617 @internalComponent |
|
1618 */ |
|
1619 void CEikonEnv::InitPrivateResourceFileL() |
|
1620 { |
|
1621 iPrivateResourceFileOffset = LafEnv::LoadPrivResFileL(*this); |
|
1622 } |
|
1623 |
|
1624 /** |
|
1625 @internalComponent |
|
1626 */ |
|
1627 void CEikonEnv::InitInfoMsgL() |
|
1628 { |
|
1629 MEikInfoMsgWin* newInfoMsgWin = LafEnv::NewInfoMsgWinL(*this, this->RootWin()); |
|
1630 if (iInfoMsgWin) |
|
1631 iInfoMsgWin->Release(); |
|
1632 iInfoMsgWin = newInfoMsgWin; |
|
1633 } |
|
1634 |
|
1635 /** |
|
1636 @internalComponent |
|
1637 */ |
|
1638 void CEikonEnv::InitAlertWinL() |
|
1639 { |
|
1640 TRAPD(err,iAlertWin->ConstructL()); |
|
1641 if (err) |
|
1642 { |
|
1643 iAlertWin->Release(); |
|
1644 iAlertWin=NULL; |
|
1645 User::Leave(err); |
|
1646 } |
|
1647 |
|
1648 iAlertWinInitialized = ETrue; |
|
1649 } |
|
1650 |
|
1651 EXPORT_C void CEikonEnv::AllocInfoMsg() |
|
1652 /** Constructs an allocation information message. |
|
1653 |
|
1654 The message includes the total number of cells allocated on the |
|
1655 current thread's heap and the total space allocated to them. */ |
|
1656 { |
|
1657 TInt allocSize = 0; |
|
1658 TInt allocCount = User::Heap().AllocSize(allocSize); |
|
1659 LafEnv::InfoNote(R_EIK_DBG_TBUF_ALLOC_INFO, allocCount, allocSize); |
|
1660 } |
|
1661 |
|
1662 EXPORT_C void CEikonEnv::WservAllocInfoMsg() |
|
1663 /** Creates a window server allocation information message from resource. |
|
1664 |
|
1665 The message indicates the number of resources currently open for the window |
|
1666 server session. */ |
|
1667 { |
|
1668 LafEnv::InfoNote(R_EIK_DBG_TBUF_WSERV_COUNT, iWsSession.ResourceCount()); |
|
1669 } |
|
1670 |
|
1671 EXPORT_C void CEikonEnv::FservAllocInfoMsg() |
|
1672 /** Creates a file server allocation information message from resource. |
|
1673 |
|
1674 The message indicates the number of resources currently open for the file |
|
1675 server session. */ |
|
1676 { |
|
1677 LafEnv::InfoNote(R_EIK_DBG_TBUF_FSERV_COUNT, iFsSession.ResourceCount()); |
|
1678 } |
|
1679 |
|
1680 EXPORT_C RAnimDll& CEikonEnv::ClockDllL() |
|
1681 /** Gets the animated DLL that is used to animate the toolbar clock of the |
|
1682 application using this CEikonEnv. |
|
1683 |
|
1684 @return Reference to the RAnimDll. */ |
|
1685 { |
|
1686 if (!iClockDll) |
|
1687 { |
|
1688 iClockDll=new(ELeave) RAnimDll(iWsSession); |
|
1689 const TDesC& clockDllName = LafEnv::ClockDllName(); |
|
1690 TInt err=iClockDll->Load(clockDllName); |
|
1691 if (err) |
|
1692 { |
|
1693 iClockDll->Destroy(); |
|
1694 iClockDll=NULL; |
|
1695 User::Leave(err); |
|
1696 } |
|
1697 } |
|
1698 return(*iClockDll); |
|
1699 } |
|
1700 |
|
1701 EXPORT_C CWsBitmap* CEikonEnv::CreateBitmapL(const TDesC& aFileName,TInt aId) |
|
1702 /** Loads, allocates and returns a pointer to a bitmap loaded from a multi-bitmap |
|
1703 file (.mbm). |
|
1704 |
|
1705 If aFileName is an empty TDesC, then a default value of |
|
1706 z:\resource\uiklaf\eikon.mbm is used. If the default can't be found the alternative |
|
1707 default location z:\Resource\Apps\eikon.mbm will be used. |
|
1708 If a wildcard character ("*") is specified as the file name, the default application |
|
1709 resource file will be used. |
|
1710 |
|
1711 If the function leaves it will also display an error dialog to the user. |
|
1712 |
|
1713 @param aFileName File name specifying the bitmap file to load. |
|
1714 @param aId Number of the bitmap in the file. |
|
1715 @return Pointer to the loaded bitmap. Ownership is transferred to the caller.*/ |
|
1716 { |
|
1717 return CreateBitmapL(aFileName, aId, ETrue); |
|
1718 } |
|
1719 |
|
1720 EXPORT_C CWsBitmap* CEikonEnv::CreateBitmapL(const TDesC& aFileName,TInt aId, TBool aShowDlgIfErr) |
|
1721 /** Loads, allocates and returns a pointer to a bitmap loaded from a multi-bitmap |
|
1722 file (.mbm). |
|
1723 |
|
1724 If aFileName is an empty TDesC, then a default value of |
|
1725 z:\resource\uiklaf\eikon.mbm is used. If the default can't be found the alternative |
|
1726 default location z:\Resource\Apps\eikon.mbm will be used. |
|
1727 If a wildcard character ("*") is specified as the file name, the default application |
|
1728 resource file will be used. |
|
1729 |
|
1730 @param aFileName File name specifying the bitmap file to load. |
|
1731 @param aId Number of the bitmap in the file. |
|
1732 @param aShowDlgIfErr If true then the function will also display an error dialog if it leaves. |
|
1733 @return Pointer to the loaded bitmap. Ownership is transferred to the caller.*/ |
|
1734 { |
|
1735 _LIT(KDefaultBitmapPath,"z:\\Resource\\Uiklaf\\eikon.mbm"); |
|
1736 _LIT(KAlternativeDefaultBitmapPath,"z:\\Resource\\Apps\\eikon.mbm"); |
|
1737 TPtrC cacheKey; // this is a "key" used to search for associated files in iEikEnvExtra->iLocalizedFilenameCache |
|
1738 TBuf<20> cacheKeyForDefaultBitmap; |
|
1739 TFileName localizedFileName; |
|
1740 // check if we are dealing with the application's default bitmap file |
|
1741 const TBool isDefaultBitmap = (aFileName==KEikDefaultAppBitmapStore); |
|
1742 TBool isDefaultBitmapPath = EFalse; |
|
1743 if (isDefaultBitmap) |
|
1744 { |
|
1745 _LIT(KLitFormat,"::%08x"); // the double colon is to make it an illegal file-name so that it can never be confused with an actual file-name |
|
1746 cacheKeyForDefaultBitmap.Format(KLitFormat, EikAppUi()); // using EikAppUi() for this works in the case of embedded applications in the local process, i.e. where there are multiple CCoeAppUi objects in the same process, each will need to refer to a different default bitmap-file |
|
1747 cacheKey.Set(cacheKeyForDefaultBitmap); |
|
1748 } |
|
1749 else if (aFileName.Length()==0) |
|
1750 { |
|
1751 cacheKey.Set(KDefaultBitmapPath); |
|
1752 isDefaultBitmapPath = ETrue; |
|
1753 } |
|
1754 else |
|
1755 cacheKey.Set(aFileName); |
|
1756 |
|
1757 if (!iEikEnvExtra->FindLocalizedBitmapFilenameInCache(cacheKey, localizedFileName)) |
|
1758 { |
|
1759 if (isDefaultBitmap) |
|
1760 { // use default application specific mbm file. The full path of the file is needed |
|
1761 // to deal correctly with embedded documents. |
|
1762 CEikApplication* eikapp = EikAppUi()->Application(); |
|
1763 if (eikapp) |
|
1764 localizedFileName = eikapp->BitmapStoreName(); |
|
1765 else |
|
1766 User::LeaveNoMemory(); |
|
1767 } |
|
1768 else |
|
1769 { // all other things, eg. ui specific mbm files, Eikon.mbm - here "cacheKey" is the unlocalized file-name |
|
1770 TParsePtrC parse(cacheKey); |
|
1771 if (parse.DrivePresent()) |
|
1772 localizedFileName=cacheKey; |
|
1773 else |
|
1774 { |
|
1775 TFindFile findFile(iFsSession); |
|
1776 CDir* dir=NULL; |
|
1777 TInt error = findFile.FindWildByDir(parse.NameAndExt(), parse.Path(), dir); |
|
1778 delete dir; |
|
1779 if (error) |
|
1780 { |
|
1781 if (aShowDlgIfErr) |
|
1782 { |
|
1783 ErrorContextL(error,localizedFileName); |
|
1784 } |
|
1785 else |
|
1786 User::Leave(error); |
|
1787 } |
|
1788 else |
|
1789 localizedFileName=findFile.File(); |
|
1790 } |
|
1791 |
|
1792 BaflUtils::NearestLanguageFile(iFsSession,localizedFileName); |
|
1793 } |
|
1794 |
|
1795 iEikEnvExtra->CacheLocalizedBitmapFilenameL(cacheKey,localizedFileName); |
|
1796 } |
|
1797 |
|
1798 CWsBitmap* tmp=new(ELeave) CWsBitmap(iWsSession); |
|
1799 TInt ret=tmp->Load(localizedFileName,aId); |
|
1800 if (ret) |
|
1801 { |
|
1802 delete(tmp); |
|
1803 if (isDefaultBitmapPath) |
|
1804 return CreateBitmapL(KAlternativeDefaultBitmapPath, aId, aShowDlgIfErr); |
|
1805 |
|
1806 if (aShowDlgIfErr) |
|
1807 { |
|
1808 ErrorContextL(ret,localizedFileName); |
|
1809 } |
|
1810 else |
|
1811 User::Leave(ret); |
|
1812 } |
|
1813 |
|
1814 tmp->SetSizeInTwips(iScreen); |
|
1815 return(tmp); |
|
1816 } |
|
1817 |
|
1818 /** |
|
1819 @internalComponent |
|
1820 */ |
|
1821 void CEikonEnv::ErrorContextL(TInt aError,const TDesC& aContextText) |
|
1822 { |
|
1823 GetErrorText(ErrorText(),aError); |
|
1824 BaflUtils::CopyWithTruncation(ErrorContextText(),aContextText); |
|
1825 User::Leave(KErrExtendedWithText); |
|
1826 } |
|
1827 |
|
1828 EXPORT_C CGulIcon* CEikonEnv::CreateIconL(const TDesC& aFileName,TInt aBitmapId,TInt aMaskId) |
|
1829 /** Creates an icon. |
|
1830 |
|
1831 The icon is created by loading the image bitmap identified by aBitmapId and the mask |
|
1832 identified by aMaskId from the resource file aFileName. It returns a pointer to the |
|
1833 icon and transfers ownership. |
|
1834 |
|
1835 @param aFileName The resource file name. If this is zero, the Uikon resource |
|
1836 file will be used. If the wildcard character ('*') is specified, the default |
|
1837 application resource file will be used. |
|
1838 @param aBitmapId The bitmap ID. |
|
1839 @param aMaskId The bitmap mask ID. |
|
1840 @return Pointer to the created icon. */ |
|
1841 { |
|
1842 CGulIcon* icon=CGulIcon::NewLC(); |
|
1843 CWsBitmap* bmp=CreateBitmapL(aFileName,aBitmapId); |
|
1844 icon->SetBitmap(bmp); |
|
1845 if(aMaskId!=-1) |
|
1846 { |
|
1847 bmp=CreateBitmapL(aFileName,aMaskId); |
|
1848 icon->SetMask(bmp); |
|
1849 } |
|
1850 CleanupStack::Pop(); // icon |
|
1851 return icon; |
|
1852 } |
|
1853 |
|
1854 EXPORT_C CGulIcon* CEikonEnv::CreateIconFromMaskedBitmapL(const CApaMaskedBitmap& aApaMaskedBitmap) |
|
1855 /** Creates an icon from a masked bitmap. |
|
1856 |
|
1857 The icon is created by copying the image bitmap and mask from the masked bitmap |
|
1858 aApaMaskedBitmap. It returns a pointer to the icon and transfers ownership to the |
|
1859 caller. |
|
1860 |
|
1861 @param aApaMaskedBitmap The masked bitmap from which the icon is created. |
|
1862 @return Pointer to the icon. */ |
|
1863 { // static |
|
1864 CGulIcon* icon=CGulIcon::NewLC(); |
|
1865 icon->SetBitmapsOwnedExternally(EFalse); |
|
1866 CFbsBitmap* bitmap=new(ELeave) CFbsBitmap; |
|
1867 CleanupStack::PushL(bitmap); |
|
1868 User::LeaveIfError(bitmap->Duplicate(aApaMaskedBitmap.Handle())); |
|
1869 CleanupStack::Pop(bitmap); |
|
1870 icon->SetBitmap(bitmap); |
|
1871 CFbsBitmap* mask=new(ELeave) CFbsBitmap; |
|
1872 CleanupStack::PushL(mask); |
|
1873 User::LeaveIfError(mask->Duplicate(aApaMaskedBitmap.Mask()->Handle())); |
|
1874 CleanupStack::Pop(mask); |
|
1875 icon->SetMask(mask); |
|
1876 CleanupStack::Pop(icon); |
|
1877 return icon; |
|
1878 } |
|
1879 |
|
1880 EXPORT_C CParaFormatLayer* CEikonEnv::SystemSingleLineParaFormatLayerL() |
|
1881 /** Gets the single line paragraph format layer if it exists. |
|
1882 |
|
1883 If one does not exist, it calls CEikonEnv::NewDefaultSingleLineParaFormatLayerL() |
|
1884 to create a new one. |
|
1885 |
|
1886 @return Single line paragraph format layer. */ |
|
1887 { |
|
1888 if (!iSingleLineParaFormatLayer) |
|
1889 iSingleLineParaFormatLayer=NewDefaultSingleLineParaFormatLayerL(); |
|
1890 return(iSingleLineParaFormatLayer); |
|
1891 } |
|
1892 |
|
1893 EXPORT_C CParaFormatLayer* CEikonEnv::SystemParaFormatLayerL() |
|
1894 /** Gets the paragraph format layer if it exists. |
|
1895 |
|
1896 If it does not exist, it calls CEikonEnv::NewDefaultParaFormatLayerL() |
|
1897 to create a new one. |
|
1898 |
|
1899 @return Paragraph format layer. */ |
|
1900 { |
|
1901 if (!iParaFormatLayer) |
|
1902 iParaFormatLayer=NewDefaultParaFormatLayerL(); |
|
1903 return(iParaFormatLayer); |
|
1904 } |
|
1905 |
|
1906 EXPORT_C CCharFormatLayer* CEikonEnv::SystemCharFormatLayerL() |
|
1907 /** Gets the character format layer, if it exists. |
|
1908 |
|
1909 If it does not exist, it calls CEikonEnv::NewDefaultCharFormatLayerL() |
|
1910 to create a new one. |
|
1911 |
|
1912 @return Character format layer. */ |
|
1913 { |
|
1914 if (!iCharFormatLayer) |
|
1915 iCharFormatLayer=NewDefaultCharFormatLayerL(); |
|
1916 return(iCharFormatLayer); |
|
1917 } |
|
1918 |
|
1919 EXPORT_C CParaFormatLayer* CEikonEnv::NewDefaultSingleLineParaFormatLayerL() |
|
1920 /** Creates a default paragraph format layer suitable for a single line of text. |
|
1921 |
|
1922 It has an inter line spacing of zero. |
|
1923 |
|
1924 @return A new CParaFormatLayer suitable for a single line of text. |
|
1925 The caller takes ownership.*/ |
|
1926 { // static |
|
1927 CParaFormat* format=CParaFormat::NewLC(); |
|
1928 format->iLineSpacingInTwips=0; |
|
1929 TParaFormatMask mask; |
|
1930 mask.SetAttrib(EAttLineSpacing); |
|
1931 CParaFormatLayer* layer=CParaFormatLayer::NewL(format,mask); |
|
1932 CleanupStack::PopAndDestroy(); // format |
|
1933 return layer; |
|
1934 } |
|
1935 |
|
1936 EXPORT_C CParaFormatLayer* CEikonEnv::NewDefaultParaFormatLayerL() |
|
1937 /** Creates a default paragraph format layer suitable for multiple lines of text. |
|
1938 |
|
1939 It uses the default inter line spacing, which is UI specific. |
|
1940 |
|
1941 @return A new CParaFormatLayer suitable for text that has more than one line. |
|
1942 The caller takes ownership. */ |
|
1943 { // static |
|
1944 CParaFormat* format=CParaFormat::NewLC(); |
|
1945 format->iLineSpacingInTwips=LafEnv::DefaultLineSpacingInTwips(); |
|
1946 TParaFormatMask mask; |
|
1947 mask.SetAttrib(EAttLineSpacing); |
|
1948 CParaFormatLayer* layer=CParaFormatLayer::NewL(format,mask); |
|
1949 CleanupStack::PopAndDestroy(); // format |
|
1950 return layer; |
|
1951 } |
|
1952 |
|
1953 #define KEikDefaultCharFormatColor KRgbBlack |
|
1954 |
|
1955 EXPORT_C CCharFormatLayer* CEikonEnv::NewDefaultCharFormatLayerL() |
|
1956 /** Creates a default character format layer. |
|
1957 |
|
1958 @return A new default CCharFormatLayer. The caller takes ownership. */ |
|
1959 { // static |
|
1960 TCharFormatMask defaultCharFormatMask; |
|
1961 TBuf<KMaxTypefaceNameLength> typeface; |
|
1962 CEikonEnv* self=CEikonEnv::Static(); |
|
1963 self->ReadResource(typeface,R_EIK_DEFAULT_CHAR_FORMAT_TYPEFACE); |
|
1964 |
|
1965 TResourceReader reader; |
|
1966 self->CreateResourceReaderLC(reader,R_EIK_DEFAULT_CHAR_FORMAT_HEIGHT); |
|
1967 TInt height=reader.ReadInt16(); |
|
1968 CleanupStack::PopAndDestroy(); // reader |
|
1969 |
|
1970 TCharFormat defaultCharFormat(typeface,height); |
|
1971 defaultCharFormatMask.SetAttrib(EAttFontTypeface); |
|
1972 defaultCharFormatMask.SetAttrib(EAttFontHeight); |
|
1973 LafEnv::PrepareCharFormatAndMask(defaultCharFormat,defaultCharFormatMask); |
|
1974 return CCharFormatLayer::NewL(defaultCharFormat,defaultCharFormatMask); |
|
1975 } |
|
1976 |
|
1977 EXPORT_C void CEikonEnv::GetPrinterNamesL(CPrinterModelList* aModelNameList,CDesCArray& aPrinterNameList) |
|
1978 /** Gets the printer names from a CPrinterModelList. |
|
1979 |
|
1980 The printer names are returned through aPrinterNameList. |
|
1981 |
|
1982 @param aModelNameList Input list of printer model information. |
|
1983 @param aPrinterNameList On return, contains all the printer names from aModelNameList. */ |
|
1984 {//static |
|
1985 aPrinterNameList.Reset(); |
|
1986 const TInt count=aModelNameList->ModelCount(); |
|
1987 for (TInt i=0;i<count;i++) |
|
1988 { |
|
1989 TPrinterModelName name=(*aModelNameList)[i].iModelName; |
|
1990 aPrinterNameList.AppendL(name); |
|
1991 } |
|
1992 } |
|
1993 |
|
1994 EXPORT_C void CEikonEnv::LaunchPopupMenuL(TInt aResourceId,const TPoint& aTargetPos,TPopupTargetPosType aTargetType,const CEikHotKeyTable* aHotKeyTable) |
|
1995 /** Allows an application to launch a popup menu, by calling the app UI's |
|
1996 LaunchPopupMenuL() function. |
|
1997 |
|
1998 @param aResourceId ID of the resource that defines the menu to be launched. |
|
1999 @param aTargetPos Position of the corner of the menu identified by aTargetType. |
|
2000 @param aTargetType The corner of the menu by which the menu will be positioned. |
|
2001 @param aHotKeyTable Optional menu hotkey table. |
|
2002 |
|
2003 @publishedAll |
|
2004 @released */ |
|
2005 { |
|
2006 EikAppUi()->LaunchPopupMenuL(aResourceId,aTargetPos,aTargetType,aHotKeyTable); |
|
2007 } |
|
2008 |
|
2009 EXPORT_C void CEikonEnv::AddDialogLikeControlToStackL(CCoeControl* aControl) |
|
2010 /** Adds a dialog-like control (with a control stack priority of ECoeStackPriorityDialog) |
|
2011 to the control stack. |
|
2012 |
|
2013 It leaves with no alert if a control with a priority between ECoeStackPriorityDialog and |
|
2014 ECoeStackPriorityFep is already being displayed by the appUi. |
|
2015 |
|
2016 @param aControl The control to add. */ |
|
2017 { |
|
2018 CEikAppUi* appUi=EikAppUi(); |
|
2019 if (appUi->IsDisplayingControlBetweenPriorities(ECoeStackPriorityDialog, ECoeStackPriorityCba) |
|
2020 || appUi->IsDisplayingControlBetweenPriorities(ECoeStackPriorityCba, ECoeStackPrioritySoftkey) |
|
2021 || appUi->IsDisplayingControlBetweenPriorities(ECoeStackPrioritySoftkey, ECoeStackPriorityFep)) |
|
2022 CBaActiveScheduler::LeaveNoAlert(); |
|
2023 aControl->SetPointerCapture(ETrue); |
|
2024 appUi->AddToStackL(aControl,ECoeStackPriorityDialog); |
|
2025 } |
|
2026 |
|
2027 EXPORT_C void CEikonEnv::AddAlertDialogLikeControlToStackL(CCoeControl* aControl) |
|
2028 /** Adds an alert dialog-like control (with a control stack priority of ECoeStackPriorityAlert) |
|
2029 to the control stack. |
|
2030 |
|
2031 Alert dialogs are used to indicate errors to the user. |
|
2032 |
|
2033 It leaves with no alert if a control with a priority between ECoeStackPriorityAlert |
|
2034 and ECoeStackPriorityFep is already being displayed by the appUi. |
|
2035 |
|
2036 @param aControl The control to add. */ |
|
2037 { |
|
2038 CEikAppUi* appUi=EikAppUi(); |
|
2039 if (appUi->IsDisplayingControlBetweenPriorities(ECoeStackPriorityAlert, ECoeStackPrioritySoftkey) |
|
2040 || appUi->IsDisplayingControlBetweenPriorities(ECoeStackPrioritySoftkey, ECoeStackPriorityFep)) |
|
2041 CBaActiveScheduler::LeaveNoAlert(); |
|
2042 aControl->SetPointerCapture(ETrue); |
|
2043 appUi->AddToStackL(aControl,ECoeStackPriorityAlert); |
|
2044 } |
|
2045 |
|
2046 EXPORT_C void CEikonEnv::AddSleepingDialogToStackL(CCoeControl* aControl) |
|
2047 /** Adds a sleeping dialog to the control stack, with a control stack priority |
|
2048 of ECoeStackPriorityDialog. |
|
2049 |
|
2050 Sleeping dialogs pre-allocate their resources - they are not initially visible. |
|
2051 |
|
2052 @param aControl The control to add. */ |
|
2053 { |
|
2054 aControl->SetPointerCapture(ETrue); |
|
2055 EikAppUi()->AddToStackL(aControl,ECoeStackPriorityDialog,ECoeStackFlagRefusesAllKeys|ECoeStackFlagRefusesFocus|ECoeStackFlagSharable); |
|
2056 } |
|
2057 |
|
2058 EXPORT_C void CEikonEnv::AddSleepingAlertDialogToStackL(CCoeControl* aControl) |
|
2059 /** Adds a sleeping dialog to the control stack, with a control stack priority |
|
2060 of ECoeStackPriorityAlert. |
|
2061 |
|
2062 Sleeping dialogs pre-allocate their resources - they are not initially visible. |
|
2063 |
|
2064 @param aControl The control to add. */ |
|
2065 { |
|
2066 aControl->SetPointerCapture(ETrue); |
|
2067 EikAppUi()->AddToStackL(aControl,ECoeStackPriorityAlert,ECoeStackFlagRefusesAllKeys|ECoeStackFlagRefusesFocus|ECoeStackFlagSharable); |
|
2068 } |
|
2069 |
|
2070 EXPORT_C void CEikonEnv::RemoveFromStack(CCoeControl* aControl) |
|
2071 /** Removes a control from the control stack. |
|
2072 |
|
2073 @param aControl The control to remove. */ |
|
2074 { |
|
2075 CCoeAppUi* const appUi=EikAppUi(); |
|
2076 if (appUi) |
|
2077 appUi->RemoveFromStack(aControl); |
|
2078 } |
|
2079 |
|
2080 EXPORT_C void CEikonEnv::RouseSleepingDialog(CCoeControl* aControl,TBool aRoused) |
|
2081 /** Sets a sleeping dialog's state. |
|
2082 |
|
2083 @param aControl The sleeping dialog to rouse or put to sleep. |
|
2084 @param aRoused ETrue to rouse aControl, EFalse to put it to sleep. */ |
|
2085 { |
|
2086 CEikAppUi* appUi=EikAppUi(); |
|
2087 appUi->UpdateStackedControlFlags(aControl,aRoused? 0: ECoeStackFlagRefusesAllKeys|ECoeStackFlagRefusesFocus,ECoeStackFlagRefusesAllKeys|ECoeStackFlagRefusesFocus); |
|
2088 appUi->HandleStackChanged(); |
|
2089 } |
|
2090 |
|
2091 EXPORT_C void CEikonEnv::DrawCursor(const CCoeControl* aControl,const TPoint& aPosition,TInt aWidth) |
|
2092 /** Calls the other overload of DrawCursor() using the environment's |
|
2093 standard screen font for the cursor's ascent and height. |
|
2094 |
|
2095 @param aControl Control to draw in. |
|
2096 @param aPosition Position of the cursor's baseline in the control's |
|
2097 co-ordinate space. |
|
2098 @param aWidth Cursor width. */ |
|
2099 { |
|
2100 DrawCursor(aControl,aPosition,aWidth,iNormalFont->AscentInPixels(),iNormalFont->HeightInPixels()); |
|
2101 } |
|
2102 |
|
2103 EXPORT_C void CEikonEnv::DrawCursor(const CCoeControl* aControl,const TPoint& aPosition,TInt aWidth,TInt aAscent,TInt aHeight) |
|
2104 /** Draws the text cursor into a control with the specified position and width. |
|
2105 |
|
2106 The cursor's height and ascent are by default suitable for this CEikonEnv's |
|
2107 normal font. If aControl is not focused when this function is called, a panic |
|
2108 is raised. |
|
2109 |
|
2110 @param aControl Control to draw into. |
|
2111 @param aPosition Position of the cursor's baseline in the control's co-ordinate |
|
2112 space. |
|
2113 @param aWidth Cursor width. |
|
2114 @param aAscent Cursor ascent. |
|
2115 @param aHeight Cursor height. */ |
|
2116 { |
|
2117 if (!aControl->IsFocused()) |
|
2118 Panic(EEikPanicCursorControlNotFocused); |
|
2119 TTextCursor cursor; |
|
2120 cursor.iType=TTextCursor::ETypeRectangle; |
|
2121 cursor.iHeight=aHeight; |
|
2122 cursor.iWidth=aWidth; |
|
2123 cursor.iAscent=aAscent; |
|
2124 cursor.iFlags=0; |
|
2125 cursor.iColor=KRgbWhite; |
|
2126 iRootWin.SetTextCursor(*aControl->DrawableWindow(),aPosition,cursor); |
|
2127 iCursorWindow=aControl; |
|
2128 } |
|
2129 |
|
2130 EXPORT_C void CEikonEnv::HideCursor(const CCoeControl* aControl) |
|
2131 /** Removes the text cursor from a control. |
|
2132 |
|
2133 In debug builds, a panic is raised when this function is called on |
|
2134 a control which is not the cursor owner. |
|
2135 |
|
2136 @param aControl Control owning the cursor. */ |
|
2137 { |
|
2138 if (aControl!=iCursorWindow) |
|
2139 #ifdef _DEBUG |
|
2140 Panic(EEikPanicControlNotCursorOwner); // would steal cursor |
|
2141 #else |
|
2142 return; |
|
2143 #endif |
|
2144 iCursorWindow=NULL; |
|
2145 iRootWin.CancelTextCursor(); |
|
2146 } |
|
2147 |
|
2148 EXPORT_C TPtrC CEikonEnv::KeyPressLabel(TInt aIndex) const |
|
2149 /** Returns the indexed keypress label. A keypress label is the text that |
|
2150 is displayed on some buttons to identify which key press activates them. |
|
2151 Examples might include Esc, Enter, Tab. Keypress labels are read from a |
|
2152 resource file and are UI-specific. |
|
2153 |
|
2154 @param aIndex The position of the element within the array of keypress labels. |
|
2155 @return The keypress label. |
|
2156 |
|
2157 @publishedPartner |
|
2158 @released |
|
2159 */ |
|
2160 { |
|
2161 TResourceReader reader; |
|
2162 return(reader.ReadTPtrC(aIndex, iKeyPressLabels)); |
|
2163 } |
|
2164 |
|
2165 EXPORT_C TBool CEikonEnv::ConfirmLossOfAllChangesL() const |
|
2166 /** Displays a dialog asking the user to confirm that all changes will be lost to the |
|
2167 current document, and returns the response. |
|
2168 |
|
2169 @return Whether the user wants to lose all changes. */ |
|
2170 { |
|
2171 return(QueryWinL(R_EIK_TBUF_CONFIRM_ALL_LOST,R_EIK_TBUF_Y_DISCARDS)); |
|
2172 } |
|
2173 |
|
2174 EXPORT_C TBool CEikonEnv::QueryWinL(TInt aFirstLineId,TInt aSecondLineId) const |
|
2175 /** Requests a yes or no response from the user using a modal query dialog. |
|
2176 |
|
2177 The query text is read from the passed resource IDs. |
|
2178 |
|
2179 User input cannot continue outside a modal dialog until the dialog is |
|
2180 dismissed, although applications can be switched. |
|
2181 |
|
2182 @param aFirstLineId ID of resource describing the first line. |
|
2183 @param aSecondLineId ID of resource describing the second line. |
|
2184 @return User's response to the question, either ETrue or EFalse. */ |
|
2185 { |
|
2186 return InfoWinOrQueryWinL(aFirstLineId,aSecondLineId, ETrue); |
|
2187 } |
|
2188 |
|
2189 EXPORT_C TBool CEikonEnv::QueryWinL(const TDesC& aFirstLine,const TDesC& aSecondLine) |
|
2190 /** Requests a yes or no response from the user using a modal query dialog. |
|
2191 |
|
2192 @param aFirstLine First line of query text. |
|
2193 @param aSecondLine Second line of query text. |
|
2194 @return User's response. */ |
|
2195 { |
|
2196 CEikonEnv *env = CEikonEnv::Static(); |
|
2197 ASSERT(env && env->RequestQueryDialogFunc()); |
|
2198 (*(env->RequestQueryDialogFunc()))(); // Call the RequestQueryDialogFunc that calls SetQueryDialog() |
|
2199 MEikInfoDialog* queryDialog = env->QueryDialog(); |
|
2200 User::LeaveIfNull(queryDialog); |
|
2201 return(queryDialog->RunDlgLD(KEikResIdQueryDialog, aFirstLine,aSecondLine)); |
|
2202 } |
|
2203 |
|
2204 EXPORT_C void CEikonEnv::InfoWinL(TInt aFirstLineId,TInt aSecondLineId) const |
|
2205 /** Displays a modal information dialog with a one or two-line info message read from the |
|
2206 passed resources. |
|
2207 |
|
2208 @param aFirstLineId ID of the resource describing the first line. |
|
2209 @param aSecondLineId ID of the resource describing the second line. */ |
|
2210 { |
|
2211 InfoWinOrQueryWinL(aFirstLineId,aSecondLineId); |
|
2212 } |
|
2213 |
|
2214 EXPORT_C void CEikonEnv::InfoWinL(const TDesC& aFirstLine,const TDesC& aSecondLine) |
|
2215 /** Displays a modal information dialog with the specified lines of text. |
|
2216 |
|
2217 @param aFirstLine First line of dialog text. |
|
2218 @param aSecondLine Second line of dialog text. */ |
|
2219 { |
|
2220 CEikonEnv *env = CEikonEnv::Static(); |
|
2221 ASSERT(env->RequestInfoDialogFunc()); |
|
2222 (*(env->RequestInfoDialogFunc()))(); // Call the RequestInfoDialogFunc that calls SetInfoDialog() |
|
2223 MEikInfoDialog* infoDialog = env->InfoDialog(); |
|
2224 User::LeaveIfNull(infoDialog); |
|
2225 infoDialog->RunDlgLD(KEikResIdInfoDialog, aFirstLine,aSecondLine); |
|
2226 } |
|
2227 |
|
2228 |
|
2229 /** |
|
2230 Sets up query or info box text using IDs to read from resource file. |
|
2231 Calls QueryWinL or InfoWinL according to final param |
|
2232 @param aFirstLineId Id of resource text |
|
2233 @param aSecondLineId Id of resource text |
|
2234 @param aIsQueryWin ETrue if response expected, EFalse if info win only |
|
2235 @return User's response from a QueryWin, ETrue from an InfoWin |
|
2236 @see CEikonEnv::QueryWinL(const TDesC& aFirstLine,const TDesC& aSecondLine) |
|
2237 @see CEikonEnv::InfoWinL(const TDesC& aFirstLine,const TDesC& aSecondLine) |
|
2238 @internalComponent |
|
2239 */ |
|
2240 TBool CEikonEnv::InfoWinOrQueryWinL(TInt aFirstLineId,TInt aSecondLineId,TBool aIsQueryWin) const |
|
2241 { |
|
2242 HBufC* const firstLine = AllocReadResourceLC(aFirstLineId); |
|
2243 const TDesC* secondLine = &KNullDesC; |
|
2244 TInt numberToPopAndDestroy=1; |
|
2245 if (aSecondLineId) |
|
2246 { |
|
2247 secondLine = AllocReadResourceLC(aSecondLineId); |
|
2248 ++numberToPopAndDestroy; |
|
2249 } |
|
2250 |
|
2251 TBool response = ETrue; |
|
2252 if (aIsQueryWin) |
|
2253 response = QueryWinL(*firstLine,*secondLine); |
|
2254 else |
|
2255 InfoWinL(*firstLine,*secondLine); |
|
2256 |
|
2257 CleanupStack::PopAndDestroy(numberToPopAndDestroy, firstLine); |
|
2258 return response; |
|
2259 } |
|
2260 |
|
2261 EXPORT_C void CEikonEnv::SetQueryDialog(MEikInfoDialog* aQueryDialog) |
|
2262 /** Sets the query dialog. |
|
2263 |
|
2264 @param aQueryDialog The query dialog. */ |
|
2265 { |
|
2266 iQueryDialog = aQueryDialog; |
|
2267 } |
|
2268 |
|
2269 EXPORT_C void CEikonEnv::SetInfoDialog(MEikInfoDialog* aInfoDialog) |
|
2270 /** Sets the dialog. |
|
2271 |
|
2272 @param aInfoDialog The information dialog. */ |
|
2273 { |
|
2274 iInfoDialog = aInfoDialog; |
|
2275 } |
|
2276 |
|
2277 EXPORT_C MEikInfoDialog* CEikonEnv::QueryDialog() const |
|
2278 /** Gets the query dialog for this environment. |
|
2279 |
|
2280 @return The query dialog. */ |
|
2281 { |
|
2282 return iQueryDialog; |
|
2283 } |
|
2284 |
|
2285 EXPORT_C MEikInfoDialog* CEikonEnv::InfoDialog() const |
|
2286 /** Gets the info dialog for this environment. |
|
2287 |
|
2288 @return The info dialog. */ |
|
2289 { |
|
2290 return iInfoDialog; |
|
2291 } |
|
2292 |
|
2293 EXPORT_C void CEikonEnv::SetRequestQueryDialogFunc(TRequestDialogFunc aQueryDialogFunc) |
|
2294 /** Sets the request query dialog. |
|
2295 |
|
2296 @param aQueryDialogFunc Request query dialog. */ |
|
2297 { |
|
2298 iQueryDialogFunc = aQueryDialogFunc; |
|
2299 } |
|
2300 |
|
2301 EXPORT_C void CEikonEnv::SetRequestInfoDialogFunc(TRequestDialogFunc aInfoDialogFunc) |
|
2302 /** Sets the request information dialog. |
|
2303 |
|
2304 @param aInfoDialogFunc The request information dialog. */ |
|
2305 { |
|
2306 iInfoDialogFunc = aInfoDialogFunc; |
|
2307 } |
|
2308 |
|
2309 /** |
|
2310 @internalComponent |
|
2311 @return Request query dialog |
|
2312 */ |
|
2313 TRequestDialogFunc CEikonEnv::RequestQueryDialogFunc() |
|
2314 { |
|
2315 return iQueryDialogFunc; |
|
2316 } |
|
2317 |
|
2318 /** |
|
2319 @internalComponent |
|
2320 @return Request information dialog |
|
2321 */ |
|
2322 TRequestDialogFunc CEikonEnv::RequestInfoDialogFunc() |
|
2323 { |
|
2324 return iInfoDialogFunc; |
|
2325 } |
|
2326 |
|
2327 /** |
|
2328 @internalComponent |
|
2329 @return ETrue if threadname is EIKAPPUI_SERVER_THREAD_NAME |
|
2330 */ |
|
2331 TBool CEikonEnv::IsEiksrvThread() const |
|
2332 { |
|
2333 TName threadName=RThread().Name(); |
|
2334 return (threadName.CompareC(EIKAPPUI_SERVER_THREAD_NAME)==KErrNone); |
|
2335 } |
|
2336 |
|
2337 //internalise printer port flag |
|
2338 EXPORT_C void InternalizeL(TEikPortFlag& aThing,RReadStream& aStream) |
|
2339 /** Internalises the printer port flag. |
|
2340 |
|
2341 This function is provided so that print dialogs can restore the |
|
2342 printer port setting from the app's ini file. |
|
2343 |
|
2344 @param aThing On return, contains the printer port setting read |
|
2345 from the specified stream. |
|
2346 @param aStream Stream to read from. |
|
2347 @leave KErrCorrupt The printer port flag read from the stream is |
|
2348 invalid.*/ |
|
2349 { |
|
2350 TInt thing = aStream.ReadUint8L(); |
|
2351 if (thing > EFilePort) // or whatever the range check is |
|
2352 User::Leave(KErrCorrupt); |
|
2353 |
|
2354 aThing = TEikPortFlag(thing); |
|
2355 } |
|
2356 |
|
2357 EXPORT_C CPrintSetup* CEikonEnv::NewDefaultPrintSetupL() |
|
2358 /** Creates and returns a pointer to a new default printer setup object. |
|
2359 |
|
2360 @return A default printer setup object. */ |
|
2361 { |
|
2362 if(!iPrintDialogFactory) |
|
2363 User::Leave(KErrNotSupported); // We used to panic here, but it's valid for this to be NULL if printing is not supported |
|
2364 |
|
2365 return iPrintDialogFactory->NewDefaultPrintSetupL(); |
|
2366 } |
|
2367 |
|
2368 EXPORT_C void CEikonEnv::SetVerboseInfoReporting(TBool aVerbose) |
|
2369 /** Sets the Verbose Information Reporting state. |
|
2370 |
|
2371 @param aVerbose ETrue to set Verbose Information Reporting, EFalse otherwise. |
|
2372 @publishedPartner |
|
2373 @released |
|
2374 */ |
|
2375 //@publishedAll @deprecated |
|
2376 { |
|
2377 iEikonEnvFlags.Assign(EVerboseInfoReporting, aVerbose); |
|
2378 } |
|
2379 |
|
2380 /** Use this method to set whether the application's window group shall be automatically |
|
2381 brought to the foreground when the user taps on it. |
|
2382 |
|
2383 @param aForwarding ETrue to set autoforwarding on, EFalse otherwise. */ |
|
2384 EXPORT_C void CEikonEnv::SetAutoForwarding(TBool aAutoBringToForeground) |
|
2385 { |
|
2386 iEikonEnvFlags.Assign(EAutoForwarding, aAutoBringToForeground); |
|
2387 if (aAutoBringToForeground && iForwardsCount <= 0) |
|
2388 iRootWin.SetOrdinalPosition(0, ECoeWinPriorityNeverAtFront); |
|
2389 } |
|
2390 |
|
2391 #pragma warning( disable : 4706 ) |
|
2392 |
|
2393 EXPORT_C void CEikonEnv::BringForwards(TBool aForwards, TInt aPriority) |
|
2394 /** Repositions the root window group in the stacking hierarchy, or pushes it to |
|
2395 the back. |
|
2396 |
|
2397 Calls to this function are ignored if the autoforward flag is set to ETrue. |
|
2398 |
|
2399 @param aForwards ETrue to reposition the root window group at aPriority. EFalse |
|
2400 to push the root window group to the back. |
|
2401 @param aPriority If aForwards is ETrue then this argument determines where |
|
2402 the root window group is placed in the stacking hierarchy. */ |
|
2403 { |
|
2404 if (aForwards) |
|
2405 { |
|
2406 if((!iForwardsCount++) && (iEikonEnvFlags[EAutoForwarding])) |
|
2407 iRootWin.SetOrdinalPosition(0,aPriority); |
|
2408 } |
|
2409 else if (!--iForwardsCount) |
|
2410 { |
|
2411 if (iEikonEnvFlags[EAutoForwarding]) |
|
2412 { |
|
2413 iRootWin.SetOrdinalPosition(0,ECoeWinPriorityNeverAtFront); |
|
2414 } |
|
2415 } |
|
2416 } |
|
2417 |
|
2418 #pragma warning( default : 4706 ) |
|
2419 |
|
2420 EXPORT_C MPictureFactory* CEikonEnv::PictureFactory() const |
|
2421 /** Gets the picture factory for this environment. |
|
2422 |
|
2423 @return The picture factory. */ |
|
2424 { |
|
2425 return const_cast<MPictureFactory*>(&iEikEnvExtra->PictureFactory()); // this method should have returned const |
|
2426 } |
|
2427 |
|
2428 /** Gets a picture factory object in the environment which supports the specified |
|
2429 picture type. |
|
2430 |
|
2431 If none exists, then the function returns NULL. |
|
2432 |
|
2433 @param aPictureType The picture type. |
|
2434 @return A picture factory which supports the picture type aPictureType. NULL |
|
2435 if no such factory exists in this environment. */ |
|
2436 EXPORT_C MEikPictureFactory* CEikonEnv::ExtendedPictureFactory(TUid aPictureType) const |
|
2437 { |
|
2438 if (aPictureType != KUidPictureTypeDoor) |
|
2439 { |
|
2440 const TInt count=iEikEnvExtra->PictureFactories().Count(); |
|
2441 for (TInt ii=0; ii < count; ii++) |
|
2442 { |
|
2443 const MEikPictureFactory& factory = iEikEnvExtra->PictureFactory(ii); |
|
2444 if (factory.SupportsPictureType(aPictureType)) |
|
2445 return const_cast<MEikPictureFactory*>(&factory); // this method should have returned const |
|
2446 } |
|
2447 } |
|
2448 |
|
2449 return NULL; |
|
2450 } |
|
2451 |
|
2452 EXPORT_C void CEikonEnv::AddPictureFactoryL(MEikPictureFactory& aFactory) |
|
2453 /** Adds the picture factory to the set of factories maintained by the Uikon environment. |
|
2454 |
|
2455 @param aFactory The picture factory to add. */ |
|
2456 { |
|
2457 iEikEnvExtra->AppendPictureFactoryL(&aFactory); |
|
2458 } |
|
2459 |
|
2460 EXPORT_C void CEikonEnv::RemovePictureFactory(TUid aFactoryId) |
|
2461 /** Removes the specified picture factory, if it exists, from the set of picture |
|
2462 factories owned by the Uikon environment. |
|
2463 |
|
2464 @param aFactoryId The Id of the picture factory to be removed. */ |
|
2465 { |
|
2466 TInt ii = iEikEnvExtra->PictureFactories().Count(); |
|
2467 while (ii > 0) |
|
2468 { |
|
2469 ii--; |
|
2470 const MEikPictureFactory& factory = iEikEnvExtra->PictureFactory(ii); |
|
2471 if (factory.Id() == aFactoryId) |
|
2472 { |
|
2473 iEikEnvExtra->DeletePictureFactory(ii); |
|
2474 // Should really return here, but BR was not approved (see BR2081) |
|
2475 } |
|
2476 } |
|
2477 } |
|
2478 |
|
2479 // duplicated in EIKPROC.CPP |
|
2480 const TUid KUidEikLastOpenFile={0x100000fb}; |
|
2481 |
|
2482 |
|
2483 /** |
|
2484 For debugging purposes only. Set __UHEAP_SETFAIL using command line parameter |
|
2485 @internalComponent |
|
2486 @param command line |
|
2487 */ |
|
2488 void CEikonEnv::SetCommandLineDebugMemFailL(const CApaCommandLine& aCommandLine) |
|
2489 { |
|
2490 #if !defined(_DEBUG) |
|
2491 (void)aCommandLine; |
|
2492 #else |
|
2493 const TInt debugMemFail=aCommandLine.DebugMemFail(); |
|
2494 if (debugMemFail!=0) |
|
2495 { |
|
2496 __UHEAP_SETFAIL(RHeap::EFailNext, debugMemFail); |
|
2497 } |
|
2498 #endif |
|
2499 } |
|
2500 |
|
2501 EXPORT_C void CEikonEnv::ConstructAppFromCommandLineL(const TApaApplicationFactory& aApplicationFactory,const CApaCommandLine& aCommandLine) |
|
2502 /** Initialises an application |
|
2503 |
|
2504 Constructs a new application consisting of a CEikAppUi, a CEikApplication, |
|
2505 and a CEikDocument. The new application starts with a new controlling |
|
2506 process and runs in this Uikon environment. The new application is passed |
|
2507 any command line file using the function CEikAppUi::ProcessCommandParametersL(). |
|
2508 |
|
2509 @param aApplicationFactory The factory to use to create the application |
|
2510 @param aCommandLine The command line used to initialise the new application. |
|
2511 @see TApaApplicationFactory */ |
|
2512 { |
|
2513 // Check if there was an error in CCoeEnv's c'tor. Leave if there was. |
|
2514 const TInt coeEnvConstructionError = CoeEnvConstructorError(); |
|
2515 User::LeaveIfError(coeEnvConstructionError); |
|
2516 |
|
2517 // Construct iEikEnvExtra here so that the app language can be stored in it |
|
2518 if (!iEikEnvExtra) |
|
2519 iEikEnvExtra = CEikEnvExtra::NewL(*this); |
|
2520 |
|
2521 TApaCommand command = aCommandLine.Command(); |
|
2522 |
|
2523 // Connect to the AppArc server |
|
2524 RApaLsSession apparcServer; |
|
2525 CleanupClosePushL(apparcServer); |
|
2526 TInt err = apparcServer.Connect(); |
|
2527 |
|
2528 // Store application language for later use |
|
2529 StoreAppLanguageL(apparcServer); |
|
2530 |
|
2531 // Set default screen |
|
2532 if (aCommandLine.IsDefaultScreenSet()) // Either use the command line parameter if set |
|
2533 iEikEnvExtra->iDefaultScreenNumber = aCommandLine.DefaultScreen(); |
|
2534 else |
|
2535 { // Or use the default screen for the application, kept by AppArc |
|
2536 if (!err) |
|
2537 err = apparcServer.GetDefaultScreenNumber(iEikEnvExtra->iDefaultScreenNumber, RProcess().Type()[2]); |
|
2538 |
|
2539 if (err) |
|
2540 iEikEnvExtra->iDefaultScreenNumber = 0; |
|
2541 } |
|
2542 // Close AppArc server session |
|
2543 CleanupStack::PopAndDestroy(&apparcServer); |
|
2544 |
|
2545 // Construct application environment |
|
2546 const TBool startAppInForeground = (command!=EApaCommandBackground && command!=EApaCommandBackgroundAndWithoutViews); |
|
2547 ConstructL(startAppInForeground, aCommandLine.ParentWindowGroupID()); |
|
2548 |
|
2549 // Init instrumentation (i.e. profiling) of application startup |
|
2550 SetAppStartupInstrumentationEventIdBaseL(aCommandLine.AppStartupInstrumentationEventIdBase()); |
|
2551 |
|
2552 // Create the application process |
|
2553 iProcess = CEikProcess::NewL(iFsSession, aCommandLine.ParentProcessId()); |
|
2554 |
|
2555 // Start application as "application server"? |
|
2556 const TUint serverDifferentiator = aCommandLine.ServerRequired(); |
|
2557 if (serverDifferentiator) |
|
2558 iEikonEnvFlags.Set(EStartedAsServerApp); |
|
2559 |
|
2560 #ifdef _DEBUG |
|
2561 SetCommandLineDebugMemFailL(aCommandLine); |
|
2562 #endif // _DEBUG |
|
2563 |
|
2564 // Push the application to the background? |
|
2565 if (!startAppInForeground) |
|
2566 { |
|
2567 iRootWin.SetOrdinalPosition(-1000); |
|
2568 iRootWin.EnableReceiptOfFocus(ETrue); |
|
2569 if (RProcess().Priority() <= EPriorityForeground) |
|
2570 RThread().SetProcessPriority(EPriorityBackground); |
|
2571 } |
|
2572 |
|
2573 // Create the document object using the application factory |
|
2574 CEikDocument& doc = *static_cast<CEikDocument*>(iProcess->AddNewDocumentL(aApplicationFactory)); |
|
2575 iProcess->SetMainDocument(&doc); |
|
2576 UpdateTaskNameL(); |
|
2577 |
|
2578 // Create app server if requested |
|
2579 if(serverDifferentiator) |
|
2580 { |
|
2581 CApaAppServer* server = NULL; |
|
2582 CApaApplication* app = doc.Application(); |
|
2583 app->NewAppServerL(server); |
|
2584 iEikEnvExtra->iAppServer = static_cast<CEikAppServer*>(server); |
|
2585 iEikEnvExtra->iAppServer->ConstructUniqueL(serverDifferentiator, app->AppDllUid()); |
|
2586 } |
|
2587 |
|
2588 // Prepare the document for editing, this includes creating the AppUi object |
|
2589 doc.PrepareToEditL(); // creates AppUi |
|
2590 CEikAppUi& appUi = *EikAppUi(); |
|
2591 |
|
2592 // Unless we are running the application without views, initialize the view manager |
|
2593 const TBool runAppWithoutViews = (command==EApaCommandRunWithoutViews || command==EApaCommandBackgroundAndWithoutViews); |
|
2594 if (!runAppWithoutViews) |
|
2595 appUi.CheckInitializeViewsL(appUi.Application()->AppDllUid()); |
|
2596 |
|
2597 // If the application is starting in the foreground, create a high-priority async view activator, |
|
2598 // as the ViewSrv won't activate the top view automatically |
|
2599 if (startAppInForeground && command!=EApaCommandViewActivate ) |
|
2600 iEikEnvExtra->iViewActivator = CEikStartUpViewActivator::NewL(appUi, *this, iEikEnvExtra->iViewActivator); |
|
2601 |
|
2602 // Get the file name associated with the document, and set it on the process CApaProcess object |
|
2603 const TBool doOpen = appUi.ProcessCommandParametersL(const_cast<CApaCommandLine&>(aCommandLine)); |
|
2604 TUnlimitedFileName* const modifiedDocumentName = TUnlimitedFileName::NewLC(aCommandLine.DocumentName()); |
|
2605 iProcess->SetMainDocFileNameL(*modifiedDocumentName); |
|
2606 UpdateTaskNameL(); |
|
2607 |
|
2608 |
|
2609 TBool openByFileName = (modifiedDocumentName->Length()); |
|
2610 CFileStore* docStore = NULL; |
|
2611 CleanupStack::PushL(TCleanupItem(DeletePointerToPointer, &docStore)); |
|
2612 |
|
2613 RFile file; |
|
2614 CleanupClosePushL(file); |
|
2615 aCommandLine.GetFileByHandleL(file); |
|
2616 TBool receivedFileHandle=EFalse; |
|
2617 if (file.SubSessionHandle() != KNullHandle) |
|
2618 { |
|
2619 receivedFileHandle = ETrue; |
|
2620 CFileStore* const KIllegalPointer=(CFileStore*)0x1; |
|
2621 docStore = KIllegalPointer; |
|
2622 TRAP(err, doc.OpenFileL(docStore, file)); |
|
2623 |
|
2624 if ((err) || (docStore != KIllegalPointer)) // if the OpenFileL call in the statement above sets docStore either to a real object or to NULL, then we don't want to open the file by name (i.e. we don't want to call the 3-parameter overload of OpenFileL below) as we've already opened the file by file-handle here) |
|
2625 openByFileName = EFalse; |
|
2626 if (docStore == KIllegalPointer) |
|
2627 docStore = NULL; |
|
2628 else |
|
2629 receivedFileHandle = EFalse; |
|
2630 } |
|
2631 |
|
2632 CleanupStack::PopAndDestroy(&file); |
|
2633 if (openByFileName) |
|
2634 { |
|
2635 TRAP(err, docStore = doc.OpenFileL(doOpen, *modifiedDocumentName, FsSession())); |
|
2636 } |
|
2637 |
|
2638 if (err==KErrCorrupt || err==KErrEof) |
|
2639 { |
|
2640 if (LafEnv::PolicyItem( LafEnv::ELafEnvPolicyDeleteCorruptDocumentAndContinue)) |
|
2641 { |
|
2642 // The document is bust, so throw it away. |
|
2643 User::LeaveIfError(FsSession().Delete(*modifiedDocumentName)); |
|
2644 if (doOpen) |
|
2645 { |
|
2646 // Create new file. |
|
2647 docStore = doc.OpenFileL(EFalse, *modifiedDocumentName, FsSession()); |
|
2648 // Alert the user that we've thrown away their data, but don't leave. |
|
2649 HandleError(err); |
|
2650 err = KErrNone; |
|
2651 } |
|
2652 } |
|
2653 } |
|
2654 |
|
2655 if (err==KErrCorrupt || err==KErrEof) |
|
2656 { // remove "last used file" stream from app ini file |
|
2657 CDictionaryStore* iniFile=appUi.Application()->OpenIniFileLC(FsSession()); |
|
2658 if (iniFile!=NULL) |
|
2659 { |
|
2660 iniFile->RemoveL(KUidEikLastOpenFile); |
|
2661 iniFile->CommitL(); |
|
2662 CleanupStack::PopAndDestroy(iniFile); |
|
2663 } |
|
2664 } |
|
2665 User::LeaveIfError(err); |
|
2666 if (docStore) |
|
2667 { |
|
2668 doc.SetEditStoreWithoutAppUiNotificationL(docStore); |
|
2669 iProcess->SetMainStore(docStore); // takes ownership of docStore |
|
2670 } |
|
2671 CleanupStack::Pop(&docStore); |
|
2672 |
|
2673 if ((modifiedDocumentName->Length()>0) || receivedFileHandle) |
|
2674 appUi.HandleModelChangeL(); |
|
2675 |
|
2676 CleanupStack::PopAndDestroy(modifiedDocumentName); |
|
2677 |
|
2678 // If not, the app will Rendezvous at its convenience. |
|
2679 if( AppUi()->FrameworkCallsRendezvous() ) |
|
2680 RProcess::Rendezvous(KErrNone); |
|
2681 |
|
2682 SetAppReady(); |
|
2683 } |
|
2684 |
|
2685 EXPORT_C void CEikonEnv::UpdateTaskNameL() |
|
2686 /** Updates the process and thread name from the caption. */ |
|
2687 { |
|
2688 CEikDocument* eikDoc = (CEikDocument*)(iProcess->MainDocument()); |
|
2689 eikDoc->UpdateTaskNameL(iWgName); |
|
2690 // Create a local copy of the CApaWindowGroupName's caption descriptor. |
|
2691 TBuf<KMaxFileName> caption( iWgName->Caption() ); |
|
2692 |
|
2693 // Adjust the caption name such that it satisfies the following conditions:- |
|
2694 // - Its length should not exceed 66 characters. An additional 14 chars(giving the maximum of 80) are added by the kernel. |
|
2695 // - ASCII character less than 0x20 or greater than 0x7e should be removed. |
|
2696 // - Special characters '?' ':' '*' should be replaced by '_'. |
|
2697 const TInt maxCaption = 66; |
|
2698 TBool setCaption = EFalse; |
|
2699 |
|
2700 if( caption.Length() > maxCaption ) |
|
2701 { |
|
2702 caption.SetLength( maxCaption ); |
|
2703 |
|
2704 setCaption = ETrue; |
|
2705 } |
|
2706 |
|
2707 TInt i = 0; |
|
2708 for(; i < caption.Length(); i++ ) |
|
2709 { |
|
2710 if( ((caption[ i ] < 0x20) || (caption[ i ] > 0x7e)) |
|
2711 || (('?' == caption[ i ]) || (':' == caption[ i ]) || ('*' == caption[ i ])) ) |
|
2712 { |
|
2713 caption[ i ] = '_'; |
|
2714 |
|
2715 setCaption = ETrue; |
|
2716 } |
|
2717 |
|
2718 } |
|
2719 |
|
2720 if( setCaption ) |
|
2721 { |
|
2722 iWgName->SetCaptionL( caption ); |
|
2723 } |
|
2724 |
|
2725 User::LeaveIfError( User::RenameThread(caption) ); |
|
2726 User::LeaveIfError( User::RenameProcess(caption) ); |
|
2727 iWgName->SetWindowGroupName(iRootWin); |
|
2728 } |
|
2729 |
|
2730 EXPORT_C void CEikonEnv::DisplayTaskList() |
|
2731 /** Displays tasks present in the Task List. |
|
2732 @publishedAll |
|
2733 @released |
|
2734 */ |
|
2735 { |
|
2736 TEikServEvent taskListMsg=EEikServShowTaskList; |
|
2737 SendEventToEikonServer(EEventUser, &taskListMsg, sizeof(taskListMsg)); |
|
2738 } |
|
2739 |
|
2740 EXPORT_C void CEikonEnv::DismissTaskList() |
|
2741 /** Causes the task list, if displayed, to be closed. |
|
2742 @publishedAll |
|
2743 @released |
|
2744 */ |
|
2745 { |
|
2746 TEikServEvent taskListMsg=EEikServHideTaskList; |
|
2747 SendEventToEikonServer(EEventUser, &taskListMsg, sizeof(taskListMsg)); |
|
2748 } |
|
2749 |
|
2750 EXPORT_C void CEikonEnv::SendEventToEikonServer(TInt aEvent,const TAny* aPtr,TInt aLength) |
|
2751 /** Sends the event to the Eikon Server. |
|
2752 |
|
2753 @param aEvent Event that has to be sent to Eikon Server. |
|
2754 @param aPtr Pointer to the message that has to be sent to Eikon Server. |
|
2755 @param aLength Length of the message that has to be sent to Eikon Server. |
|
2756 |
|
2757 @publishedPartner |
|
2758 @released |
|
2759 */ |
|
2760 { |
|
2761 TWsEvent event; |
|
2762 event.SetType(aEvent); |
|
2763 if (aLength>TWsEvent::EWsEventDataSize) |
|
2764 Panic(EEikPanicOverlongEikonServerMessage); |
|
2765 Mem::Copy(event.EventData(),aPtr,aLength); |
|
2766 TInt wgId=iWsSession.FindWindowGroupIdentifier(0, __EIKON_SERVER_NAME, 0); |
|
2767 iWsSession.SendEventToWindowGroup(wgId,event); |
|
2768 } |
|
2769 |
|
2770 EXPORT_C void CEikonEnv::SetBusy(TBool aBusy) |
|
2771 /** Sets the application's busy state. |
|
2772 |
|
2773 @param aBusy ETrue to set as busy, EFalse otherwise. */ |
|
2774 { |
|
2775 TBool busyChanged=EFalse; |
|
2776 if (aBusy) |
|
2777 { |
|
2778 if (!iBusyCount++) |
|
2779 { |
|
2780 iWgName->SetBusy(ETrue); |
|
2781 busyChanged=ETrue; |
|
2782 } |
|
2783 } |
|
2784 else |
|
2785 { |
|
2786 if (!--iBusyCount) |
|
2787 { |
|
2788 iWgName->SetBusy(EFalse); |
|
2789 busyChanged=ETrue; |
|
2790 } |
|
2791 } |
|
2792 if (busyChanged) |
|
2793 iWgName->SetWindowGroupName(iRootWin); |
|
2794 } |
|
2795 |
|
2796 EXPORT_C TBool CEikonEnv::IsBusy() const |
|
2797 /** Tests whether the application is marked as busy. |
|
2798 |
|
2799 @return ETrue if the application is busy, EFalse otherwise. */ |
|
2800 { |
|
2801 return iWgName->IsBusy(); |
|
2802 } |
|
2803 |
|
2804 EXPORT_C void CEikonEnv::SetSystem(TBool aSystem) |
|
2805 /** Sets the application's system attribute. |
|
2806 |
|
2807 While the system attribute is set, the application cannot be closed down e.g. by using |
|
2808 the @c TApaTask::EndTask function unless the requester has the capability PowerMgmt. |
|
2809 |
|
2810 @param aSystem ETrue to set the system attribute, EFalse to unset it. */ |
|
2811 { |
|
2812 iWgName->SetSystem(aSystem); |
|
2813 iWgName->SetWindowGroupName(iRootWin); |
|
2814 } |
|
2815 |
|
2816 EXPORT_C TBool CEikonEnv::IsSystem() const |
|
2817 /** Tests the value of the system attribute. |
|
2818 |
|
2819 @return ETrue if the system attribute is set, otherwise EFalse. */ |
|
2820 { |
|
2821 return iWgName->IsSystem(); |
|
2822 } |
|
2823 |
|
2824 EXPORT_C void CEikonEnv::SetDocNameIsAFile(TBool aDocNameIsAFile) |
|
2825 /** Sets whether a document name is a file. |
|
2826 |
|
2827 @param aDocNameIsAFile ETrue to set the document name as a file, EFalse otherwise. */ |
|
2828 { |
|
2829 iWgName->SetDocNameIsAFile(aDocNameIsAFile); |
|
2830 iWgName->SetWindowGroupName(iRootWin); |
|
2831 } |
|
2832 |
|
2833 EXPORT_C TBool CEikonEnv::DocNameIsAFile() const |
|
2834 /** Tests whether the document name is a file. |
|
2835 |
|
2836 @return ETrue if the document name is a file. EFalse otherwise. */ |
|
2837 { |
|
2838 return iWgName->DocNameIsAFile(); |
|
2839 } |
|
2840 |
|
2841 EXPORT_C void CEikonEnv::SetRespondsToShutdownEvent(TBool aRespondsToShutdownEvent) |
|
2842 /** Sets whether the application responds to shutdown events. |
|
2843 |
|
2844 @param aRespondsToShutdownEvent ETrue if the application responds to shutdown |
|
2845 events, EFalse otherwise. */ |
|
2846 { |
|
2847 iWgName->SetRespondsToShutdownEvent(aRespondsToShutdownEvent); |
|
2848 iWgName->SetWindowGroupName(iRootWin); |
|
2849 } |
|
2850 |
|
2851 EXPORT_C TBool CEikonEnv::RespondsToShutdownEvent() const |
|
2852 /** Tests whether the application responds to shutdown events. |
|
2853 |
|
2854 @return ETrue if the application responds to shutdown events, EFalse otherwise. */ |
|
2855 { |
|
2856 return iWgName->RespondsToShutdownEvent(); |
|
2857 } |
|
2858 |
|
2859 EXPORT_C void CEikonEnv::SetRespondsToSwitchFilesEvent(TBool aRespondsToSwitchFilesEvent) |
|
2860 /** Sets whether the application responds to switch files events. |
|
2861 |
|
2862 @param aRespondsToSwitchFilesEvent ETrue if the application responds to switch |
|
2863 files events, EFalse otherwise. */ |
|
2864 { |
|
2865 iWgName->SetRespondsToSwitchFilesEvent(aRespondsToSwitchFilesEvent); |
|
2866 iWgName->SetWindowGroupName(iRootWin); |
|
2867 } |
|
2868 |
|
2869 EXPORT_C TBool CEikonEnv::RespondsToSwitchFilesEvent() const |
|
2870 /** Tests whether an application responds to switch files events. |
|
2871 |
|
2872 @return ETrue if the application responds to switch files events, EFalse otherwise. */ |
|
2873 { |
|
2874 return iWgName->RespondsToSwitchFilesEvent(); |
|
2875 } |
|
2876 |
|
2877 EXPORT_C CColorList* CEikonEnv::CreateSystemColorListL() |
|
2878 /** Creates and returns a system colour list, which is a palette of standard |
|
2879 colours used by the system. |
|
2880 |
|
2881 The list is read from a system colour scheme file. The function returns NULL |
|
2882 if no such file can be found. In this case, clients are expected to create |
|
2883 the list using some other means (typically from a resource file). |
|
2884 |
|
2885 @return Pointer to the system colour list, or NULL. */ |
|
2886 { |
|
2887 return CCoeDataStorage::GetL(*this).GetSystemColorListL(); |
|
2888 } |
|
2889 |
|
2890 EXPORT_C CColorList* CEikonEnv::CreateSystemColorListL(const CColorList& aColorList) |
|
2891 /** Creates and returns a system colour list, which is a palette of standard |
|
2892 colours used by the system, and merges it with the colour list specified. |
|
2893 CColorList::AddColorArrayL() should be called before this function. |
|
2894 |
|
2895 @param aColorList The color list to merge in. |
|
2896 @return Pointer to the system colour list. */ |
|
2897 { |
|
2898 CColorList* colorList = CreateSystemColorListL(); |
|
2899 if(colorList) |
|
2900 CleanupStack::PushL(colorList); |
|
2901 else |
|
2902 colorList = CColorList::NewLC(); |
|
2903 |
|
2904 colorList->MergeL(aColorList); |
|
2905 CleanupStack::Pop(colorList); |
|
2906 return colorList; |
|
2907 } |
|
2908 |
|
2909 EXPORT_C void CEikonEnv::UpdateSystemColorListL(const CColorList& aColorList) |
|
2910 /** Replaces the system colour list with the list specified. |
|
2911 |
|
2912 If no system colour list exists, one is created. |
|
2913 |
|
2914 @param aColorList The new colour list. |
|
2915 @capability WriteDeviceData To protect against tampering. |
|
2916 */ |
|
2917 { |
|
2918 CCoeDataStorage::GetL(*this).SetSystemColorListL(aColorList); |
|
2919 } |
|
2920 |
|
2921 EXPORT_C TRgb CEikonEnv::ControlColor(TLogicalColor aLogicalColor, const CCoeControl& aControl) const |
|
2922 /** Gets the physical (TRgb) colour which corresponds to the logical colour specified |
|
2923 from the application's colour list. |
|
2924 |
|
2925 If the colour of the control specified in aControl has been overridden using |
|
2926 CCoeControl::OverrideColorL(), this function will return the overridden colour. |
|
2927 |
|
2928 @param aLogicalColor A logical colour value. |
|
2929 @param aControl A pointer to the control itself. |
|
2930 @return The physical colour which corresponds to aLogicalColor. */ |
|
2931 { |
|
2932 TRgb color = Color(aLogicalColor); // Get default color |
|
2933 aControl.GetColor(aLogicalColor, color); // Get overriden color, if any |
|
2934 return color; |
|
2935 } |
|
2936 |
|
2937 /** |
|
2938 Creates and populates a colour list, a palette of standard colours used by the system. |
|
2939 If the first attempt fails a separate executable, Z:\\SYS\\BIN\\UPDATESYSTEMCOLORLIST.EXE, is run to update system colours. |
|
2940 @return populated colour list. Ownership is passed to caller. |
|
2941 */ |
|
2942 // Export this for >9.0 but not before |
|
2943 EXPORT_C CColorList* CEikonEnv::PopulateColorArrayL() |
|
2944 { |
|
2945 CColorList* colorList = CreateSystemColorListL(); |
|
2946 if (!colorList) |
|
2947 { |
|
2948 _LIT(KExeName,"Z:\\SYS\\BIN\\UPDATESYSTEMCOLORLIST.EXE"); |
|
2949 RProcess process; |
|
2950 TRequestStatus processState; |
|
2951 const TInt err = process.Create(KExeName,KNullDesC); |
|
2952 User::LeaveIfError(err); |
|
2953 CleanupClosePushL(process); |
|
2954 process.Logon(processState); |
|
2955 process.Resume(); |
|
2956 User::WaitForRequest(processState); |
|
2957 CleanupStack::PopAndDestroy(&process); |
|
2958 colorList = CreateSystemColorListL(); |
|
2959 } |
|
2960 return colorList; |
|
2961 } |
|
2962 |
|
2963 /** |
|
2964 @internalComponent |
|
2965 */ |
|
2966 void CEikonEnv::InitColorSchemeL() |
|
2967 { |
|
2968 if (!iColorList) |
|
2969 iColorList = LafEnv::CreateColorListL(*this); |
|
2970 } |
|
2971 |
|
2972 /** |
|
2973 @internalComponent |
|
2974 */ |
|
2975 LOCAL_C void ReleaseParser(TAny* aSelf) |
|
2976 {REINTERPRET_CAST(MParser*,aSelf)->Release();} |
|
2977 |
|
2978 /** |
|
2979 @internalComponent |
|
2980 */ |
|
2981 void CEikonEnv::LoadParserListL() |
|
2982 { |
|
2983 TInt index=0; |
|
2984 FOREVER |
|
2985 { |
|
2986 MParser* parser = LafEnv::CreateTextParserL(index++); |
|
2987 if (!parser) |
|
2988 break; |
|
2989 |
|
2990 CleanupStack::PushL(TCleanupItem(ReleaseParser,parser)); |
|
2991 CRichText::ActivateDefaultParserL(parser); |
|
2992 CleanupStack::Pop(); // parser |
|
2993 } |
|
2994 } |
|
2995 |
|
2996 |
|
2997 EXPORT_C void CEikonEnv::SetAppUiFactoryL(MEikAppUiFactory* aAppUiFactory) |
|
2998 /** |
|
2999 @internalComponent |
|
3000 */ |
|
3001 { |
|
3002 if (!iAppUiFactoryArray) |
|
3003 iAppUiFactoryArray = new(ELeave) CArrayFixFlat<TEikAppUiFactory>(1); |
|
3004 |
|
3005 AddAppUiFactoryL(aAppUiFactory); |
|
3006 } |
|
3007 |
|
3008 EXPORT_C MEikAppUiFactory* CEikonEnv::AppUiFactory() const |
|
3009 /** Gets the application UI factory object. |
|
3010 |
|
3011 This object implements the MEikAppUiFactory interface. |
|
3012 |
|
3013 @return App UI factory interface or NULL. */ |
|
3014 { |
|
3015 const TInt index = iAppUiFactoryArray->Count() - 1; |
|
3016 return (index >= 0 ? (*iAppUiFactoryArray)[index].iFactory : NULL); |
|
3017 } |
|
3018 |
|
3019 EXPORT_C MEikAppUiFactory* CEikonEnv::AppUiFactory(const CEikAppUi& aAppUi) const |
|
3020 /** Gets the application UI factory object for the specified app UI. |
|
3021 |
|
3022 If the specified app UI does not exist in this environment, the function returns |
|
3023 NULL. Otherwise the function returns an object which implements the MEikAppUiFactory |
|
3024 interface. |
|
3025 |
|
3026 @param aAppUi The app UI for this application. |
|
3027 @return The app UI factory object, or NULL if aAppUi does't exist in this environment. */ |
|
3028 { |
|
3029 MEikAppUiFactory* ret = NULL; |
|
3030 for (TInt ii=iAppUiFactoryArray->Count();--ii>=0;) |
|
3031 { |
|
3032 TEikAppUiFactory factory=(*iAppUiFactoryArray)[ii]; |
|
3033 if (factory.iAppUi==&aAppUi || (ii==0 && !aAppUi.ContainerAppUi())) |
|
3034 { |
|
3035 ret=factory.iFactory; |
|
3036 break; |
|
3037 } |
|
3038 } |
|
3039 return ret; |
|
3040 } |
|
3041 |
|
3042 |
|
3043 EXPORT_C void CEikonEnv::AddAppUiFactoryL(MEikAppUiFactory* aAppUiFactory) |
|
3044 /** |
|
3045 @internalComponent |
|
3046 */ |
|
3047 { |
|
3048 TEikAppUiFactory factory; |
|
3049 factory.iAppUi = EikAppUi(); |
|
3050 factory.iFactory = aAppUiFactory; |
|
3051 iAppUiFactoryArray->AppendL(factory); |
|
3052 } |
|
3053 |
|
3054 EXPORT_C void CEikonEnv::RemoveAppUiFactory() |
|
3055 /** |
|
3056 @internalComponent |
|
3057 */ |
|
3058 { |
|
3059 const TInt index = iAppUiFactoryArray->Count() - 1; |
|
3060 iAppUiFactoryArray->Delete(index); |
|
3061 } |
|
3062 |
|
3063 /** |
|
3064 @publishedPartner |
|
3065 @deprecated |
|
3066 |
|
3067 Use CCoeStatic instead |
|
3068 */ |
|
3069 EXPORT_C void CEikonEnv::SetExtension(CBase* aExtension) |
|
3070 { |
|
3071 delete iExtension; |
|
3072 iExtension = aExtension; |
|
3073 } |
|
3074 |
|
3075 |
|
3076 EXPORT_C void CEikonEnv::WriteInternalStateOfStackedControlsL() |
|
3077 /** |
|
3078 Writes the internal state of all CCoeControls on the control stack into a file |
|
3079 c:\\debuglog_#APPNAME#(#NUMBER#) in the Symbian OS filing system. Works in debug mode only. |
|
3080 |
|
3081 @internalTechnology |
|
3082 */ |
|
3083 { |
|
3084 #ifdef _DEBUG |
|
3085 _LIT(KStdLogFilePrefix,":\\Debug_log_%S"); |
|
3086 TFileName fileName; |
|
3087 RBuf stdLogFormat; |
|
3088 TChar sysDrive = RFs::GetSystemDriveChar(); |
|
3089 TInt maxSizeOfFileName = KStdLogFilePrefix().Length() + 1; |
|
3090 stdLogFormat.CreateL(maxSizeOfFileName); |
|
3091 stdLogFormat.Append(sysDrive); |
|
3092 stdLogFormat.Append(KStdLogFilePrefix()); |
|
3093 stdLogFormat.CleanupClosePushL(); |
|
3094 fileName.Format(stdLogFormat,&(EikAppUi()->Application()->AppCaption())); |
|
3095 CleanupStack::PopAndDestroy(&stdLogFormat); |
|
3096 CApaApplication::GenerateFileName(iFsSession,fileName); |
|
3097 RFileWriteStream writeStream; |
|
3098 writeStream.PushL(); |
|
3099 User::LeaveIfError(writeStream.Create(iFsSession,fileName,EFileWrite)); |
|
3100 EikAppUi()->WriteInternalStateOfStackedControlsL(writeStream); |
|
3101 writeStream.CommitL(); |
|
3102 CleanupStack::PopAndDestroy(); //writeStream.Close() |
|
3103 #endif |
|
3104 } |
|
3105 |
|
3106 EXPORT_C const CFbsBitmap* CEikonEnv::TexturedBitmap() const |
|
3107 /** |
|
3108 @publishedAll |
|
3109 @deprecated |
|
3110 */ |
|
3111 { |
|
3112 TUid uid = TUid::Uid(KLafUidEikonTexturedVal); |
|
3113 return LafEnv::MatchBitmap(*iBitmapArray, uid); |
|
3114 } |
|
3115 |
|
3116 EXPORT_C const CFbsBitmap* CEikonEnv::GrayBitmap() const |
|
3117 /** |
|
3118 @publishedAll |
|
3119 @deprecated |
|
3120 */ |
|
3121 { |
|
3122 const TUid uid = TUid::Uid(KLafUidEikonGrayVal); |
|
3123 return LafEnv::MatchBitmap(*iBitmapArray, uid); |
|
3124 } |
|
3125 |
|
3126 EXPORT_C const CFbsBitmap* CEikonEnv::OptionBitmap() const |
|
3127 /** Gets the bitmap that is used by horizontal option buttons in this |
|
3128 environment. |
|
3129 |
|
3130 @publishedAll |
|
3131 @deprecated |
|
3132 |
|
3133 @return A pointer to the option bitmap. */ |
|
3134 { |
|
3135 const TUid uid = TUid::Uid(KLafUidEikonOptiVal); |
|
3136 return LafEnv::MatchBitmap(*iBitmapArray, uid); |
|
3137 } |
|
3138 |
|
3139 EXPORT_C const CFbsBitmap* CEikonEnv::HighlightedOptionBitmap() const |
|
3140 /** |
|
3141 @internalComponent |
|
3142 */ |
|
3143 { |
|
3144 TUid uid = TUid::Uid(KLafUidEikonOptihVal); |
|
3145 return LafEnv::MatchBitmap(*iBitmapArray, uid); |
|
3146 } |
|
3147 |
|
3148 EXPORT_C const CFbsBitmap* CEikonEnv::OptionMaskBitmap() const |
|
3149 /** |
|
3150 @publishedAll |
|
3151 @deprecated |
|
3152 */ |
|
3153 { |
|
3154 const TUid uid = TUid::Uid(KLafUidEikonOptimVal); |
|
3155 return LafEnv::MatchBitmap(*iBitmapArray, uid); |
|
3156 } |
|
3157 |
|
3158 EXPORT_C const CFbsBitmap* CEikonEnv::Bitmap(TUid aBmpUid) const |
|
3159 /** Gets the specified bitmap. |
|
3160 |
|
3161 This function returns a bitmap from the list of bitmaps by using the UID as an index. |
|
3162 |
|
3163 @param aUidBmp The UID of the bitmap to retrieve. |
|
3164 @return Pointer to the bitmap. */ |
|
3165 { |
|
3166 return LafEnv::MatchBitmap(*iBitmapArray, aBmpUid); |
|
3167 } |
|
3168 |
|
3169 EXPORT_C MLafEnv& CEikonEnv::LafEnv() const |
|
3170 /** |
|
3171 @publishedPartner |
|
3172 @released |
|
3173 */ |
|
3174 { |
|
3175 return *iLafEnv; |
|
3176 } |
|
3177 |
|
3178 EXPORT_C TDisplayMode CEikonEnv::DefaultDisplayMode() const |
|
3179 /** Gets the default display mode for the window server session with the maximum |
|
3180 possible number of colours. |
|
3181 |
|
3182 @return Default display mode. */ |
|
3183 { |
|
3184 TInt numGrays = 0; |
|
3185 TInt numColors = 0; |
|
3186 return WsSession().GetDefModeMaxNumColors(numColors, numGrays); |
|
3187 } |
|
3188 |
|
3189 /** |
|
3190 @internalComponent |
|
3191 */ |
|
3192 void CEikonEnv::SetAppReady() |
|
3193 { |
|
3194 iWgName->SetAppReady(ETrue); |
|
3195 iWgName->SetWindowGroupName(iRootWin); |
|
3196 } |
|
3197 |
|
3198 EXPORT_C CEikAppServer* CEikonEnv::AppServer() const |
|
3199 /** Gets required application server for running the application. |
|
3200 |
|
3201 @return Pointer to the application server which is derived from CEikAppServer. */ |
|
3202 { |
|
3203 if (iEikEnvExtra) |
|
3204 return iEikEnvExtra->iAppServer; |
|
3205 else |
|
3206 return NULL; |
|
3207 } |
|
3208 |
|
3209 EXPORT_C TBool CEikonEnv::StartedAsServerApp() const |
|
3210 /** Gets whether server is required or not. |
|
3211 |
|
3212 @return ETrue if application requires a server, EFalse otherwise. */ |
|
3213 { |
|
3214 return iEikonEnvFlags[EStartedAsServerApp]; |
|
3215 } |
|
3216 |
|
3217 /** |
|
3218 Sets language in iEikEnvExtra and baflutils. Gets language from application if possible, device otherwise. |
|
3219 @param aLsSession (open) session to apparc server |
|
3220 @internalComponent |
|
3221 */ |
|
3222 void CEikonEnv::StoreAppLanguageL(const RApaLsSession& aLsSession) |
|
3223 { |
|
3224 TBool err = KErrNone; |
|
3225 const TBool validSession = aLsSession.Handle(); |
|
3226 if(validSession) |
|
3227 { |
|
3228 // Get the app UID from the process, then use it to get the application language |
|
3229 // from apparc |
|
3230 const TUid appUid(RProcess().Type()[2]); |
|
3231 err = aLsSession.ApplicationLanguage(appUid, iEikEnvExtra->iAppLanguage); |
|
3232 } |
|
3233 |
|
3234 // If we can't get the language successfully then set it to the language of the device |
|
3235 if(err || !validSession) |
|
3236 iEikEnvExtra->iAppLanguage = User::Language(); |
|
3237 |
|
3238 // Set the app language in baflutils, this is used in order to load the correct language |
|
3239 // resource files |
|
3240 if (iEikEnvExtra->iAppLanguage != ELangNone) |
|
3241 User::LeaveIfError(BaflUtils::SetIdealLanguage(iEikEnvExtra->iAppLanguage)); |
|
3242 else // In the case of ELangNone, set the app-language to be the device's language |
|
3243 iEikEnvExtra->iAppLanguage = User::Language(); // Don't set ideal language (see PDEF102771) |
|
3244 |
|
3245 } |
|
3246 |
|
3247 |
|
3248 /** |
|
3249 @internalTechnology |
|
3250 */ |
|
3251 TLanguage CEikonEnv::ApplicationLanguage() const |
|
3252 { |
|
3253 return iEikEnvExtra->iAppLanguage; |
|
3254 } |
|
3255 |
|
3256 /** |
|
3257 @internalTechnology |
|
3258 */ |
|
3259 void CEikonEnv::PostAppUiDestroy() |
|
3260 { |
|
3261 CloseLibraries(); |
|
3262 |
|
3263 delete iAppUiFactoryArray; |
|
3264 iAppUiFactoryArray = NULL; |
|
3265 |
|
3266 delete iAutoMenuTitleArray; |
|
3267 iAutoMenuTitleArray = NULL; |
|
3268 } |
|
3269 |
|
3270 /** |
|
3271 @internalTechnology |
|
3272 */ |
|
3273 TInt CEikonEnv::ConstructorError() const |
|
3274 { |
|
3275 return CoeEnvConstructorError(); |
|
3276 } |
|
3277 |
|
3278 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_1() |
|
3279 { |
|
3280 } |
|
3281 |
|
3282 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_2() |
|
3283 { |
|
3284 } |
|
3285 |
|
3286 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_3() |
|
3287 { |
|
3288 } |
|
3289 |
|
3290 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_4() |
|
3291 { |
|
3292 } |
|
3293 |
|
3294 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_5() |
|
3295 { |
|
3296 } |
|
3297 |
|
3298 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_6() |
|
3299 { |
|
3300 } |
|
3301 |
|
3302 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_7() |
|
3303 { |
|
3304 } |
|
3305 |
|
3306 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_8() |
|
3307 { |
|
3308 } |
|
3309 |
|
3310 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_9() |
|
3311 { |
|
3312 } |
|
3313 |
|
3314 EXPORT_C void CEikonEnv::CEikonEnv_Reserved_10() |
|
3315 { |
|
3316 } |
|
3317 |