|
1 /* |
|
2 * Copyright (c) 2004-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: Interface for accessing icon data in SIM. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "TUSatAPI.h" |
|
20 #include "MSatIconObserver.h" |
|
21 #include "CSatIconHandler.h" |
|
22 #include "SatLog.h" |
|
23 #include "EnginePanic.h" |
|
24 #include "csatsactivewrapper.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CSatIconHandler::CSatIconHandler |
|
30 // C++ default constructor can NOT contain any code, that |
|
31 // might leave. |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 CSatIconHandler::CSatIconHandler( |
|
35 MSatApi& aSatApi ) : |
|
36 CActive( EPriorityStandard ), |
|
37 MSatSIconAPI(), |
|
38 iSatApi( aSatApi ), |
|
39 iGetIconInfoActive( EFalse ), |
|
40 iGetIconInstanceActive( EFalse ), |
|
41 iGetClutActive( EFalse ), |
|
42 iSyncIconFetching( EFalse ) |
|
43 { |
|
44 LOG( SIMPLE, "SATENGINE: CSatIconHandler::CSatIconHandler calling" ) |
|
45 |
|
46 CActiveScheduler::Add( this ); |
|
47 |
|
48 LOG( SIMPLE, "SATENGINE: CSatIconHandler::CSatIconHandler exiting" ) |
|
49 } |
|
50 |
|
51 // ----------------------------------------------------------------------------- |
|
52 // CSatIconHandler::~CSatIconHandler() |
|
53 // Destructor |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 CSatIconHandler::~CSatIconHandler() |
|
57 { |
|
58 LOG( SIMPLE, "SATENGINE: CSatIconHandler::~CSatIconHandler calling" ) |
|
59 |
|
60 iObserver = NULL; |
|
61 |
|
62 LOG( SIMPLE, "SATENGINE: CSatIconHandler::~CSatIconHandler exiting" ) |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CSatIconHandler::GetIconInfo |
|
67 // Gets the icon info from SIM through USAT-API. |
|
68 // (other items were commented in a header). |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CSatIconHandler::GetIconInfo( |
|
72 TUint8 aRecordNumber, |
|
73 RSat::TIcon& aIconEf, |
|
74 MSatIconObserver& aObserver ) |
|
75 { |
|
76 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInfo calling" ) |
|
77 |
|
78 iObserver = &aObserver; |
|
79 |
|
80 // Check is RSat connected |
|
81 if ( iSatApi.IsRSatConnected() ) |
|
82 { |
|
83 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInfo connected" ) |
|
84 iSatApi.GetIcon( iStatus, aRecordNumber, aIconEf ); |
|
85 iGetIconInfoActive = ETrue; |
|
86 SetActive(); |
|
87 } |
|
88 else |
|
89 { |
|
90 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInfo Not connected" ) |
|
91 iObserver->NotifyFailure( KErrDisconnected ); |
|
92 } |
|
93 |
|
94 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInfo exiting" ) |
|
95 } |
|
96 |
|
97 // ----------------------------------------------------------------------------- |
|
98 // CSatIconHandler::GetIconInstance |
|
99 // Gets the icon data from SIM through USAT-API. |
|
100 // (other items were commented in a header). |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 void CSatIconHandler::GetIconInstance( |
|
104 const RSat::TInstanceInfoV3& aInstanceInfo, |
|
105 TDes8& aInstance, |
|
106 MSatIconObserver& aObserver ) |
|
107 { |
|
108 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInstance calling" ) |
|
109 |
|
110 iObserver = &aObserver; |
|
111 |
|
112 // Check is RSat connected |
|
113 if ( iSatApi.IsRSatConnected() ) |
|
114 { |
|
115 LOG( SIMPLE, |
|
116 "SATENGINE: CSatIconHandler::GetIconInstance connected" ) |
|
117 #ifndef __WINS__ |
|
118 RSat::TInstanceInfoV3Pckg instanceInfoPckg( aInstanceInfo ); |
|
119 if ( !iSyncIconFetching ) |
|
120 { |
|
121 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInstance \ |
|
122 iSyncIconFetching false" ) |
|
123 iSatApi.GetImageInstance( |
|
124 iStatus, instanceInfoPckg, aInstance ); |
|
125 iGetIconInstanceActive = ETrue; |
|
126 SetActive(); |
|
127 } |
|
128 else |
|
129 { |
|
130 CSatSActiveWrapper* wrapper = NULL; |
|
131 wrapper = new CSatSActiveWrapper(); |
|
132 TInt error( KErrNoMemory ); |
|
133 if ( wrapper ) |
|
134 { |
|
135 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInstance\ |
|
136 wrapper" ) |
|
137 iSatApi.GetImageInstance( wrapper->RequestStatus(), |
|
138 instanceInfoPckg, aInstance ); |
|
139 error = wrapper->SetActiveAndWait(); |
|
140 delete wrapper; |
|
141 wrapper = NULL; |
|
142 } |
|
143 |
|
144 LOG2( |
|
145 SIMPLE, |
|
146 "SATENGINE: CSatIconHandler::GetIconInstance iStatus: %i", |
|
147 error ) |
|
148 if ( KErrNone != error ) |
|
149 { |
|
150 iObserver->NotifyFailure( error ); |
|
151 } |
|
152 else |
|
153 { |
|
154 TRAP_IGNORE( iObserver->NotifyGetIconInstanceL(); ); |
|
155 } |
|
156 } |
|
157 #else |
|
158 CSatSActiveWrapper* wrapper = NULL; |
|
159 wrapper = new CSatSActiveWrapper(); |
|
160 TInt error( KErrNoMemory ); |
|
161 if ( wrapper ) |
|
162 { |
|
163 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInstance\ |
|
164 wrapper true" ) |
|
165 RSat::TInstanceInfoV3Pckg instanceInfoPckg( aInstanceInfo ); |
|
166 iSatApi.GetImageInstance( wrapper->RequestStatus(), |
|
167 instanceInfoPckg, aInstance ); |
|
168 error = wrapper->SetActiveAndWait(); |
|
169 delete wrapper; |
|
170 wrapper = NULL; |
|
171 } |
|
172 |
|
173 LOG2( |
|
174 SIMPLE, |
|
175 "SATENGINE: CSatIconHandler::GetIconInstance iStatus: %i", |
|
176 error ) |
|
177 if ( KErrNone != error ) |
|
178 { |
|
179 iObserver->NotifyFailure( error ); |
|
180 } |
|
181 else |
|
182 { |
|
183 TRAP_IGNORE( iObserver->NotifyGetIconInstanceL(); ); |
|
184 } |
|
185 #endif |
|
186 |
|
187 } |
|
188 else |
|
189 { |
|
190 LOG( SIMPLE, |
|
191 "SATENGINE: CSatIconHandler::GetIconInstance not connected" ) |
|
192 iObserver->NotifyFailure( KErrDisconnected ); |
|
193 } |
|
194 |
|
195 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetIconInstance exiting" ) |
|
196 } |
|
197 |
|
198 // ----------------------------------------------------------------------------- |
|
199 // CSatIconHandler::GetClut |
|
200 // Gets the Clut from SIM through USAT-API. |
|
201 // (other items were commented in a header). |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CSatIconHandler::GetClut( |
|
205 TUint aInstanceNumber, |
|
206 TUint aOffset, |
|
207 TDes8& aClut, |
|
208 MSatIconObserver& aObserver ) |
|
209 { |
|
210 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetClut calling" ) |
|
211 |
|
212 iObserver = &aObserver; |
|
213 // Check is RSat connected |
|
214 if ( iSatApi.IsRSatConnected() ) |
|
215 { |
|
216 LOG( SIMPLE, |
|
217 "SATENGINE: CSatIconHandler::GetClut connected" ) |
|
218 #ifndef __WINS__ |
|
219 if ( !iSyncIconFetching ) |
|
220 { |
|
221 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetClut \ |
|
222 iSyncIconFetching false" ) |
|
223 iSatApi.GetClut( iStatus, aInstanceNumber, aOffset, aClut ); |
|
224 iGetClutActive = ETrue; |
|
225 SetActive(); |
|
226 } |
|
227 else |
|
228 { |
|
229 CSatSActiveWrapper* wrapper = NULL; |
|
230 wrapper = new CSatSActiveWrapper(); |
|
231 TInt error( KErrNoMemory ); |
|
232 if ( wrapper ) |
|
233 { |
|
234 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetClut\ |
|
235 wrapper" ) |
|
236 iSatApi.GetClut( wrapper->RequestStatus(), |
|
237 aInstanceNumber, aOffset, aClut ); |
|
238 error = wrapper->SetActiveAndWait(); |
|
239 delete wrapper; |
|
240 wrapper = NULL; |
|
241 } |
|
242 |
|
243 LOG2( |
|
244 SIMPLE, |
|
245 "SATENGINE: CSatIconHandler::GetClut iStatus: %i", error ) |
|
246 if ( KErrNone != error ) |
|
247 { |
|
248 iObserver->NotifyFailure( error ); |
|
249 } |
|
250 else |
|
251 { |
|
252 TRAP_IGNORE( iObserver->NotifyGetClutL(); ); |
|
253 } |
|
254 } |
|
255 #else |
|
256 CSatSActiveWrapper* wrapper = NULL; |
|
257 wrapper = new CSatSActiveWrapper(); |
|
258 TInt error( KErrNoMemory ); |
|
259 if ( wrapper ) |
|
260 { |
|
261 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetClut\ |
|
262 wrapper true" ) |
|
263 iSatApi.GetClut( wrapper->RequestStatus(), aInstanceNumber, |
|
264 aOffset, aClut ); |
|
265 error = wrapper->SetActiveAndWait(); |
|
266 delete wrapper; |
|
267 wrapper = NULL; |
|
268 } |
|
269 |
|
270 LOG2( |
|
271 SIMPLE, |
|
272 "SATENGINE: CSatIconHandler::GetClut iStatus: %i", error ) |
|
273 if ( KErrNone != error ) |
|
274 { |
|
275 iObserver->NotifyFailure( error ); |
|
276 } |
|
277 else |
|
278 { |
|
279 TRAP_IGNORE( iObserver->NotifyGetClutL(); ); |
|
280 } |
|
281 #endif |
|
282 |
|
283 } |
|
284 else |
|
285 { |
|
286 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetClut Not connected" ) |
|
287 iObserver->NotifyFailure( KErrDisconnected ); |
|
288 } |
|
289 |
|
290 LOG( SIMPLE, "SATENGINE: CSatIconHandler::GetClut exiting" ) |
|
291 } |
|
292 |
|
293 // ----------------------------------------------------------------------------- |
|
294 // CSatIconHandler::DoCancel |
|
295 // (other items were commented in a header). |
|
296 // ----------------------------------------------------------------------------- |
|
297 // |
|
298 void CSatIconHandler::DoCancel() |
|
299 { |
|
300 LOG( SIMPLE, "SATENGINE: CSatIconHandler::DoCancel calling" ) |
|
301 |
|
302 // Complete the request with cancel code. |
|
303 iObserver->NotifyFailure( KErrCancel ); |
|
304 |
|
305 LOG( SIMPLE, "SATENGINE: CSatIconHandler::DoCancel exiting" ) |
|
306 } |
|
307 |
|
308 // ----------------------------------------------------------------------------- |
|
309 // CSatIconHandler::RunL |
|
310 // (other items were commented in a header). |
|
311 // ----------------------------------------------------------------------------- |
|
312 // |
|
313 void CSatIconHandler::RunL() |
|
314 { |
|
315 LOG( SIMPLE, "SATENGINE: CSatIconHandler::RunL calling" ) |
|
316 LOG2( SIMPLE, |
|
317 "SATENGINE: CSatIconHandler::RunL error: %i", iStatus.Int() ) |
|
318 if ( KErrNone == iStatus.Int() ) |
|
319 { |
|
320 if ( iGetIconInfoActive ) |
|
321 { |
|
322 LOG( NORMAL, "SATENGINE: iGetIconInfoActive" ) |
|
323 iGetIconInfoActive = EFalse; |
|
324 iObserver->NotifyGetIconInfo(); |
|
325 } |
|
326 |
|
327 else if ( iGetIconInstanceActive ) |
|
328 { |
|
329 LOG( NORMAL, "SATENGINE: iGetIconInstanceActive" ) |
|
330 iGetIconInstanceActive = EFalse; |
|
331 iObserver->NotifyGetIconInstanceL(); |
|
332 } |
|
333 |
|
334 else if ( iGetClutActive ) |
|
335 { |
|
336 LOG( NORMAL, "SATENGINE: iGetClutActive" ) |
|
337 iGetClutActive = EFalse; |
|
338 iObserver->NotifyGetClutL(); |
|
339 } |
|
340 |
|
341 else |
|
342 { |
|
343 LOG( SIMPLE, "SATENGINE: Unexpected RunL" ) |
|
344 PanicSatEngine( ESatSBadRequest ); |
|
345 } |
|
346 } |
|
347 else |
|
348 { |
|
349 iObserver->NotifyFailure( iStatus.Int() ); |
|
350 } |
|
351 |
|
352 LOG( SIMPLE, "SATENGINE: CSatIconHandler::RunL exiting" ) |
|
353 } |
|
354 |
|
355 // ----------------------------------------------------------------------------- |
|
356 // CSatIconHandler::RunError |
|
357 // (other items were commented in a header). |
|
358 // ----------------------------------------------------------------------------- |
|
359 // |
|
360 TInt CSatIconHandler::RunError( TInt aError ) |
|
361 { |
|
362 LOG( SIMPLE, "SATENGINE: CSatIconHandler::RunError calling" ) |
|
363 |
|
364 // If leave happened before completion of iMessage, we do it now |
|
365 TInt err = iObserver->CompleteError( aError ); |
|
366 // If completed succesfully, aError is sent forward in completion. |
|
367 // If not, we should return aError forward |
|
368 if ( KErrNone != err ) |
|
369 { |
|
370 LOG( SIMPLE, "SATENGINE: CSatIconHandler::RunError KErrNone != err" ) |
|
371 err = aError; |
|
372 } |
|
373 |
|
374 LOG2( SIMPLE, "SATENGINE: CSatIconHandler::RunError exiting, err: %i", |
|
375 err ) |
|
376 return err; |
|
377 } |
|
378 // ----------------------------------------------------------------------------- |
|
379 // Set a mode to determine whether to fetch icons from NAA syncronously or |
|
380 // asynchronously. |
|
381 // ----------------------------------------------------------------------------- |
|
382 // |
|
383 void CSatIconHandler::SetIconFetchingMode( TBool aMode ) |
|
384 { |
|
385 LOG( SIMPLE, "SATENGINE: CSatIconHandler::SetIconFetchingMode calling" ) |
|
386 |
|
387 iSyncIconFetching = aMode; |
|
388 |
|
389 LOG( SIMPLE, "SATENGINE: CSatIconHandler::SetIconFetchingMode exiting" ) |
|
390 } |