|
1 /* |
|
2 * Copyright (c) 2002-2008 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: The UI Client API of the SAT Server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32def.h> |
|
22 #include <RSatSession.h> |
|
23 #include <data_caging_path_literals.hrh> |
|
24 |
|
25 #include "RSatUiSession.h" |
|
26 #include "MSatUiObserver.h" |
|
27 #include "MSatUiAdapter.h" |
|
28 #include "SatSOpcodes.h" |
|
29 #include "CSatCCommandProcessor.h" |
|
30 #include "SatServerFactory.h" |
|
31 #include "SatLog.h" |
|
32 |
|
33 // CONSTANTS |
|
34 |
|
35 #if defined( __WINS__ ) |
|
36 const TInt KHeapMinSize = 0x10000; |
|
37 const TInt KHeapMaxSize = 0x10000; |
|
38 #endif |
|
39 |
|
40 // ============================ MEMBER FUNCTIONS =============================== |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // RSatUiSession::RSatUiSession |
|
44 // Class constructor. |
|
45 // (other items were commented in a header). |
|
46 // ----------------------------------------------------------------------------- |
|
47 // |
|
48 EXPORT_C RSatUiSession::RSatUiSession() : |
|
49 RSubSessionBase(), |
|
50 iCommandProcessor( NULL ), |
|
51 iSatUiObserver( NULL ) |
|
52 { |
|
53 } |
|
54 |
|
55 // ----------------------------------------------------------------------------- |
|
56 // RSatUiSession::RegisterL |
|
57 // Registers a new client. |
|
58 // (other items were commented in a header). |
|
59 // ----------------------------------------------------------------------------- |
|
60 // |
|
61 EXPORT_C void RSatUiSession::RegisterL( |
|
62 const RSatSession& aSession, |
|
63 MSatUiObserver* aSatUiObserver ) |
|
64 { |
|
65 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::RegisterL calling" ) |
|
66 |
|
67 // If the server isn't already started, we can't do anything. |
|
68 if ( !IsServerStarted() ) |
|
69 { |
|
70 LOG( SIMPLE, |
|
71 "SATINTERNALCLIENT: RSatUiSession::RegisterL server not started" ) |
|
72 User::Leave( KErrCouldNotConnect ); |
|
73 } |
|
74 |
|
75 iSatUiObserver = aSatUiObserver; |
|
76 iCommandProcessor = CSatCCommandProcessor::NewL( this ); |
|
77 |
|
78 // Connect to the server side session. |
|
79 TIpcArgs arguments( 0 ); |
|
80 User::LeaveIfError( |
|
81 CreateSubSession( |
|
82 aSession, |
|
83 ESatSOpenUiSubSession, arguments ) ); |
|
84 |
|
85 // Start the handlers. |
|
86 iCommandProcessor->Start(); |
|
87 |
|
88 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::RegisterL exiting" ) |
|
89 } |
|
90 |
|
91 // ----------------------------------------------------------------------------- |
|
92 // RSatUiSession::Adapter |
|
93 // Returns a pointer to an adapter object. |
|
94 // (other items were commented in a header). |
|
95 // ----------------------------------------------------------------------------- |
|
96 // |
|
97 EXPORT_C MSatUiAdapter* RSatUiSession::Adapter() const |
|
98 { |
|
99 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Adapter calling" ) |
|
100 |
|
101 if ( iCommandProcessor ) |
|
102 { |
|
103 MSatUiAdapter* satUiAdapter = iCommandProcessor->ActiveCommandHandler(); |
|
104 |
|
105 LOG( SIMPLE, |
|
106 "SATINTERNALCLIENT: RSatUiSession::Adapter (iCommandProcessor) exiting" ) |
|
107 return satUiAdapter; |
|
108 } |
|
109 |
|
110 else |
|
111 { |
|
112 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Adapter exiting" ) |
|
113 return NULL; |
|
114 } |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // RSatUiSession::Unregister |
|
119 // Unregisters a client. |
|
120 // (other items were commented in a header). |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 void RSatUiSession::Unregister() |
|
124 { |
|
125 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Unregister calling" ) |
|
126 |
|
127 if ( iCommandProcessor ) |
|
128 { |
|
129 LOG( SIMPLE, |
|
130 "SATINTERNALCLIENT: RSatUiSession::Unregister iCommandProcessor true" ) |
|
131 delete iCommandProcessor; |
|
132 iCommandProcessor = NULL; |
|
133 } |
|
134 |
|
135 iSatUiObserver = NULL; |
|
136 |
|
137 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Unregister exiting" ) |
|
138 } |
|
139 |
|
140 // ----------------------------------------------------------------------------- |
|
141 // RSatUiSession::Version |
|
142 // Returns the current version of the client. |
|
143 // (other items were commented in a header). |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 EXPORT_C TVersion RSatUiSession::Version() const |
|
147 { |
|
148 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Version calling-exiting" ) |
|
149 return TVersion( |
|
150 KSatServerMajorVersionNumber, |
|
151 KSatServerMinorVersionNumber, |
|
152 KSatServerBuildVersionNumber ); |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // RSatUiSession::Close |
|
157 // Closes the server session. |
|
158 // (other items were commented in a header). |
|
159 // ----------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C void RSatUiSession::Close() |
|
162 { |
|
163 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Close calling" ) |
|
164 |
|
165 Unregister(); |
|
166 CloseSubSession( ESatSCloseUiSubSession ); |
|
167 |
|
168 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Close exiting" ) |
|
169 } |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // RSatUiSession::Panic |
|
173 // Panics the client. |
|
174 // (other items were commented in a header). |
|
175 // ----------------------------------------------------------------------------- |
|
176 // |
|
177 EXPORT_C void RSatUiSession::Panic( |
|
178 TSatClientPanic aReason ) const |
|
179 { |
|
180 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::Panic" ) |
|
181 |
|
182 User::Panic( KSatCliName, aReason ); |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // RSatUiSession::KillServer |
|
187 // Kills the server. |
|
188 // (other items were commented in a header). |
|
189 // ----------------------------------------------------------------------------- |
|
190 // |
|
191 EXPORT_C void RSatUiSession::KillServer() const |
|
192 { |
|
193 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::KillServer calling" ) |
|
194 |
|
195 // Use a dummy arguments table. |
|
196 TIpcArgs arguments( 0 ); |
|
197 |
|
198 // Request the server shutdown. |
|
199 SendReceive( ESatSShutdown, arguments ); |
|
200 |
|
201 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::KillServer exiting" ) |
|
202 } |
|
203 |
|
204 // ----------------------------------------------------------------------------- |
|
205 // RSatUiSession::IsServerStarted |
|
206 // Checks if the server is already started. |
|
207 // (other items were commented in a header). |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 TBool RSatUiSession::IsServerStarted() const |
|
211 { |
|
212 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::IsServerStarted calling" ) |
|
213 |
|
214 TFindServer findServer( KSatServerName ); |
|
215 TFullName name; |
|
216 TBool started = ( KErrNone == findServer.Next( name ) ); |
|
217 |
|
218 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::IsServerStarted exiting" ) |
|
219 return started; |
|
220 } |
|
221 |
|
222 // ----------------------------------------------------------------------------- |
|
223 // RSatUiSession::CreateRequest |
|
224 // Creates Send Receive request. |
|
225 // (other items were commented in a header). |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 EXPORT_C void RSatUiSession::CreateRequest( |
|
229 TInt aFunction, |
|
230 const TIpcArgs& aArgs, |
|
231 TRequestStatus& aStatus ) const |
|
232 { |
|
233 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::CreateRequest calling" ) |
|
234 |
|
235 SendReceive( aFunction, aArgs, aStatus ); |
|
236 |
|
237 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::CreateRequest exiting" ) |
|
238 } |
|
239 |
|
240 // ----------------------------------------------------------------------------- |
|
241 // RSatUiSession::CreateRequest |
|
242 // Creates Send Receive request. |
|
243 // (other items were commented in a header). |
|
244 // ----------------------------------------------------------------------------- |
|
245 // |
|
246 EXPORT_C void RSatUiSession::CreateRequest( |
|
247 TInt aFunction, |
|
248 const TIpcArgs& aArgs ) const |
|
249 { |
|
250 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::CreateRequest calling" ) |
|
251 |
|
252 SendReceive( aFunction, aArgs ); |
|
253 |
|
254 LOG( SIMPLE, "SATINTERNALCLIENT: RSatUiSession::CreateRequest exiting" ) |
|
255 } |
|
256 |
|
257 // ----------------------------------------------------------------------------- |
|
258 // RSatUiSession::SatUiObserver |
|
259 // Returns a pointer to a client observer object. |
|
260 // (other items were commented in a header). |
|
261 // ----------------------------------------------------------------------------- |
|
262 // |
|
263 EXPORT_C MSatUiObserver* RSatUiSession::SatUiObserver() |
|
264 { |
|
265 LOG( SIMPLE, |
|
266 "SATINTERNALCLIENT: RSatUiSession::SatUiObserver calling-exiting" ) |
|
267 return iSatUiObserver; |
|
268 } |
|
269 |
|
270 // ----------------------------------------------------------------------------- |
|
271 // RSatUiSession::CommandProcessor |
|
272 // Returns a pointer to a command processor object. |
|
273 // (other items were commented in a header). |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 CSatCCommandProcessor* RSatUiSession::CommandProcessor() |
|
277 { |
|
278 LOG( SIMPLE, |
|
279 "SATINTERNALCLIENT: RSatUiSession::CommandProcessor calling-exiting" ) |
|
280 return iCommandProcessor; |
|
281 } |
|
282 |
|
283 // End of File |