|
1 /* |
|
2 * Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "aknapp.h" |
|
19 #include <eikenv.h> |
|
20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
21 #include <uikon/eikenvinterface.h> |
|
22 #endif |
|
23 |
|
24 #include <apgtask.h> |
|
25 #include <apgwgnam.h> |
|
26 #include <AknServerApp.h> |
|
27 #include "AknTaskList.h" |
|
28 |
|
29 #include <aknenv.h> |
|
30 #include <akntranseffect.h> // for Transition effect enumerations |
|
31 #include <UikonInternalPSKeys.h> |
|
32 #include <e32property.h> |
|
33 #include <AknSgcc.h> |
|
34 |
|
35 LOCAL_C TBool IsInHiddenList(const TUid& aUid) |
|
36 { |
|
37 TBuf16<2 * KMaxHiddenApps> lst; |
|
38 if(KErrNone != RProperty::Get(KPSUidUikon, KUikAppHiddenList, lst)) |
|
39 return EFalse; |
|
40 for(TInt i = 0; i < KMaxHiddenApps; i++) |
|
41 { |
|
42 const TInt bytePos = i << 1; |
|
43 const TUint32 uid = (lst[bytePos] << 16) | lst[bytePos + 1]; |
|
44 if(aUid.iUid == uid) |
|
45 return ETrue; |
|
46 if(uid == 0) //end of list |
|
47 return EFalse; |
|
48 } |
|
49 return EFalse; |
|
50 } |
|
51 |
|
52 EXPORT_C void CAknApplication::PreDocConstructL() |
|
53 { |
|
54 CEikonEnv* env = CEikonEnv::Static(); |
|
55 if (!env->StartedAsServerApp() && !env->EikAppUi()) |
|
56 { |
|
57 // Only run this check for top level (non embedded) apps. |
|
58 RWsSession& ws = env->WsSession(); |
|
59 const TInt myWg = env->RootWin().Identifier(); |
|
60 TInt wgId = 0; |
|
61 |
|
62 // set this apps UID in the window group name to remove the gap between this check and it being set in UpdateTaskNameL() |
|
63 TUid uid(AppDllUid()); |
|
64 CApaWindowGroupName* wgName = CApaWindowGroupName::NewLC(ws, myWg); |
|
65 wgName->SetAppUid(uid); |
|
66 wgName->SetWindowGroupName(env->RootWin()); |
|
67 |
|
68 // Use a CAknTaskList to check for root instances of apps |
|
69 CAknTaskList* taskList = CAknTaskList::NewLC(ws); |
|
70 TBool foundInstance = EFalse; |
|
71 |
|
72 // Look for another instance of this app |
|
73 while (wgId>=0) |
|
74 { |
|
75 if (wgId && wgId != myWg && taskList->IsRootWindowGroup(wgId)) |
|
76 { // found another app, switch to it & die |
|
77 /* |
|
78 TApaTask other(ws); |
|
79 other.SetWgId(wgId); |
|
80 other.BringToForeground(); |
|
81 |
|
82 CBaActiveScheduler::Exit(); |
|
83 */ |
|
84 foundInstance = ETrue; |
|
85 break; |
|
86 |
|
87 } |
|
88 |
|
89 CApaWindowGroupName::FindByAppUid(uid,ws,wgId); |
|
90 } |
|
91 |
|
92 if(!foundInstance) |
|
93 { |
|
94 // |
|
95 // Application launched with commands EApaCommandBackground or |
|
96 // EApaCommandRunWithoutViews has non-zero ordinal position for their |
|
97 // window group. |
|
98 // For such applications transition effects on application start |
|
99 // should not be used. |
|
100 // |
|
101 TInt ordPosition = env->RootWin().OrdinalPosition(); |
|
102 |
|
103 if (!ordPosition) |
|
104 { |
|
105 iAvkonEnv->TransitionEvent(AknTransEffect::EApplicationStart, AppDllUid()); |
|
106 } |
|
107 else |
|
108 { |
|
109 iAvkonEnv->TransitionEvent( AknTransEffect::EAppStartupBackground, AppDllUid() ); |
|
110 } |
|
111 } |
|
112 else |
|
113 { |
|
114 // If application is launched to background, then do not bring application to |
|
115 // foreground. This needs to be deduced using ordinal position of root window |
|
116 // as command line parameters are not available to this method. With this |
|
117 // approach, there is small chance for error, but it's considered to be so |
|
118 // rare that this is acceptable. For example, otherwise applications launched |
|
119 // to background during startup might cause foreground application changes. |
|
120 const TInt ordPosition = env->RootWin().OrdinalPosition(); |
|
121 if ( !ordPosition ) |
|
122 { |
|
123 if(wgName->Hidden() || IsInHiddenList(AppDllUid())) |
|
124 { |
|
125 iAvkonEnv->TransitionEvent(AknTransEffect::EApplicationStartSwitch, AppDllUid()); |
|
126 } |
|
127 CAknSgcClient::MoveApp(wgId, ESgcMoveAppToForeground); |
|
128 } |
|
129 CBaActiveScheduler::Exit(); |
|
130 } |
|
131 CleanupStack::PopAndDestroy(taskList); //taskList |
|
132 CleanupStack::PopAndDestroy(wgName); |
|
133 } |
|
134 |
|
135 if(env->StartedAsServerApp()) |
|
136 { |
|
137 // Start embedded |
|
138 iAvkonEnv->TransitionEvent(AknTransEffect::EEmbeddedApplicationStart, AppDllUid()); |
|
139 } |
|
140 CEikApplication::PreDocConstructL(); |
|
141 } |
|
142 |
|
143 EXPORT_C CDictionaryStore* CAknApplication::OpenIniFileLC(RFs& /*aFs*/) const |
|
144 { |
|
145 // By default, ini files are not supported by SERIES60 applications. |
|
146 // If you want to use an ini file, either override this function to base call |
|
147 // CEikApplication::OpenIniFileLC, or call it directly. |
|
148 User::Leave(KErrNotSupported); |
|
149 return NULL; |
|
150 } |
|
151 |
|
152 EXPORT_C void CAknApplication::NewAppServerL(CApaAppServer*& aAppServer) |
|
153 { |
|
154 aAppServer = new(ELeave) CAknAppServer; |
|
155 } |