|
1 /* |
|
2 * Copyright (c) 2004 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: Server applications framework. |
|
15 * |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "AknServerApp.h" |
|
21 |
|
22 #include <avkon.hrh> |
|
23 #include <aknenv.h> |
|
24 #include "AknOpenFileServiceImpl.h" |
|
25 #include "AknNullServiceImpl.h" |
|
26 #include "AknLaunchAppServiceImpl.h" |
|
27 #include "AknDebug.h" |
|
28 |
|
29 |
|
30 // --------------------------------------------------------- |
|
31 // |
|
32 // --------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C void RAknAppServiceBase::ConnectChainedAppL(TUid aAppUid) |
|
35 { |
|
36 #ifdef AVKON_RDEBUG_INFO |
|
37 RDebug::Print(_L("RAknAppServiceBase::ConnectChainedAppL")); |
|
38 #endif |
|
39 CEikonEnv* eikEnv = CEikonEnv::Static(); |
|
40 RWindowGroup& wg = eikEnv->RootWin(); |
|
41 ConnectNewChildAppL(aAppUid, wg); |
|
42 } |
|
43 |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 // --------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C void RAknAppServiceBase::Close() |
|
49 { |
|
50 #ifdef AVKON_RDEBUG_INFO |
|
51 RDebug::Print(_L("RAknAppServiceBase::Close")); |
|
52 #endif |
|
53 REikAppServiceBase::Close(); |
|
54 } |
|
55 |
|
56 |
|
57 |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 EXPORT_C void MAknServerAppExitObserver::HandleServerAppExit(TInt aReason) |
|
64 { |
|
65 #ifdef AVKON_RDEBUG_INFO |
|
66 RDebug::Print(_L("MAknServerAppExitObserver::HandleServerAppExit")); |
|
67 #endif |
|
68 if (aReason == EAknCmdExit) |
|
69 { |
|
70 // ShutOrHideAppL is very unlikely to leave, app is supposed to be |
|
71 // exiting, so ignore errors anyway. |
|
72 TRAP_IGNORE(CAknEnv::ShutOrHideAppL()); |
|
73 } |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 EXPORT_C CAknAppServiceBase::CAknAppServiceBase() |
|
83 { |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------- |
|
87 // |
|
88 // --------------------------------------------------------- |
|
89 // |
|
90 EXPORT_C CAknAppServiceBase::~CAknAppServiceBase() |
|
91 { |
|
92 if ( Server() ) |
|
93 { |
|
94 static_cast<CAknAppServer*>(const_cast<CServer2*>(Server()))->HandleSessionClose(); |
|
95 } |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------- |
|
99 // |
|
100 // --------------------------------------------------------- |
|
101 // |
|
102 EXPORT_C void CAknAppServiceBase::CreateL() |
|
103 { |
|
104 #ifdef AVKON_RDEBUG_INFO |
|
105 RDebug::Print(_L("CAknAppServiceBase::CreateL")); |
|
106 #endif |
|
107 static_cast<CAknAppServer*>(const_cast<CServer2*>(Server()))->HandleSessionOpen(); |
|
108 CApaAppServiceBase::CreateL(); |
|
109 } |
|
110 |
|
111 // --------------------------------------------------------- |
|
112 // |
|
113 // --------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C void CAknAppServiceBase::ServiceL(const RMessage2& aMessage) |
|
116 { |
|
117 #ifdef AVKON_RDEBUG_INFO |
|
118 RDebug::Print(_L("CAknAppServiceBase::ServiceL")); |
|
119 #endif |
|
120 CApaAppServiceBase::ServiceL(aMessage); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------- |
|
124 // |
|
125 // --------------------------------------------------------- |
|
126 // |
|
127 EXPORT_C void CAknAppServiceBase::ServiceError(const RMessage2& aMessage,TInt aError) |
|
128 { |
|
129 #ifdef AVKON_RDEBUG_INFO |
|
130 RDebug::Print(_L("CAknAppServiceBase::ServiceError")); |
|
131 #endif |
|
132 CApaAppServiceBase::ServiceError(aMessage, aError); |
|
133 } |
|
134 |
|
135 |
|
136 // --------------------------------------------------------- |
|
137 // |
|
138 // --------------------------------------------------------- |
|
139 // |
|
140 EXPORT_C CAknAppServer::~CAknAppServer() |
|
141 { |
|
142 // CApaAppServiceBase destructors call back to this class, |
|
143 // so ensure that they are deleted before this class is |
|
144 // deleted, and ensure that a derived HandleAllClientsClosed() |
|
145 // is not called by artificially raising the session count. |
|
146 ++iSessionCount; |
|
147 iSessionIter.SetToFirst(); |
|
148 CSession2* s; |
|
149 while ((s=iSessionIter++)!=NULL) |
|
150 { |
|
151 delete s; |
|
152 } |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 // --------------------------------------------------------- |
|
158 // |
|
159 EXPORT_C void CAknAppServer::ConstructL(const TDesC& aFixedServerName) |
|
160 { |
|
161 #ifdef AVKON_RDEBUG_INFO |
|
162 RDebug::Print(_L("CAknAppServer::ConstructL")); |
|
163 #endif |
|
164 CEikAppServer::ConstructL(aFixedServerName); |
|
165 } |
|
166 |
|
167 // --------------------------------------------------------- |
|
168 // |
|
169 // --------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C CApaAppServiceBase* CAknAppServer::CreateServiceL(TUid aServiceType) const |
|
172 { |
|
173 #ifdef AVKON_RDEBUG_INFO |
|
174 RDebug::Print(_L("CAknAppServer::CreateServiceL")); |
|
175 #endif |
|
176 // two built-in services: Open File and Null service. |
|
177 if (aServiceType == KAknOpenFileServiceUid) |
|
178 { |
|
179 return new(ELeave) CAknOpenFileServiceSession; |
|
180 } |
|
181 else if (aServiceType == KAknNullServiceUid) |
|
182 { |
|
183 return new(ELeave) CAknAppServiceBase; |
|
184 } |
|
185 else if (aServiceType == KAknLaunchAppServiceUid) |
|
186 { |
|
187 return new(ELeave) CAknLaunchAppServiceSession; |
|
188 } |
|
189 return CEikAppServer::CreateServiceL(aServiceType); |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------- |
|
193 // |
|
194 // --------------------------------------------------------- |
|
195 // |
|
196 EXPORT_C void CAknAppServer::HandleAllClientsClosed() |
|
197 { |
|
198 #ifdef AVKON_RDEBUG_INFO |
|
199 RDebug::Print(_L("CAknAppServer::HandleAllClientsClosed")); |
|
200 #endif |
|
201 CAknEnv::Static()->RunAppShutter(); |
|
202 } |
|
203 |
|
204 // --------------------------------------------------------- |
|
205 // |
|
206 // --------------------------------------------------------- |
|
207 // |
|
208 void CAknAppServer::HandleSessionClose() |
|
209 { |
|
210 #ifdef AVKON_RDEBUG_INFO |
|
211 RDebug::Print(_L("CAknAppServer::HandleSessionClose")); |
|
212 #endif |
|
213 if (--iSessionCount<=0) |
|
214 { |
|
215 //CAknEnv::Static()->RunAppShutter(); |
|
216 HandleAllClientsClosed(); |
|
217 } |
|
218 } |
|
219 |
|
220 // --------------------------------------------------------- |
|
221 // |
|
222 // --------------------------------------------------------- |
|
223 // |
|
224 void CAknAppServer::HandleSessionOpen() |
|
225 { |
|
226 #ifdef AVKON_RDEBUG_INFO |
|
227 RDebug::Print(_L("CAknAppServer::HandleSessionOpen")); |
|
228 #endif |
|
229 iSessionCount++; |
|
230 } |
|
231 |
|
232 // End of file. |