|
1 /* |
|
2 * Copyright (c) 2007-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 the License "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 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "saticon.h" // sat icon class |
|
23 #include "satmessaging.h" // sat messaging |
|
24 #include "satmesshandler.h" // sat message handler class |
|
25 #include "satutil.h" // sat utility class |
|
26 #include "osttracedefinitions.h" |
|
27 #ifdef OST_TRACE_COMPILER_IN_USE |
|
28 #include "saticontraces.h" |
|
29 #endif |
|
30 |
|
31 |
|
32 // CONSTANTS |
|
33 const TUint8 KDescriptionSize = 9; |
|
34 |
|
35 // KMaxThumbPhonetMessageSize (16384) - header (8) - subBlock parameters (16) |
|
36 const TUint16 KIconDataMaxSize = 0x3FE8; |
|
37 |
|
38 |
|
39 // ==================== MEMBER FUNCTIONS ======================================= |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CSatIcon::CSatIcon |
|
43 // C++ default constructor can NOT contain any code, that |
|
44 // might leave. |
|
45 // ----------------------------------------------------------------------------- |
|
46 // |
|
47 CSatIcon::CSatIcon |
|
48 ( |
|
49 CSatMessHandler* aSatMessHandler, |
|
50 CTsySatMessaging* aSatMessaging |
|
51 ) |
|
52 : |
|
53 iSatMessHandler( aSatMessHandler ), |
|
54 iSatMessaging( aSatMessaging ), |
|
55 iIconData( NULL ), |
|
56 iIconTsyReqHandle( NULL ), |
|
57 iGetIconFlag( EFalse ), |
|
58 iRecordNumber( KZero ), |
|
59 iImageInstanceNoInRecord( KZero ) |
|
60 { |
|
61 OstTrace0( TRACE_NORMAL, CSATICON_CSATICON, "CSatIcon::CSatIcon" ); |
|
62 iRecordData.Zero(); |
|
63 } |
|
64 |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSatIcon::ConstructL |
|
68 // Symbian 2nd phase constructor can leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 void CSatIcon::ConstructL() |
|
72 { |
|
73 OstTrace0( TRACE_NORMAL, CSATICON_CONSTRUCTL, "CSatIcon::ConstructL" ); |
|
74 // None. Reserved for future use. |
|
75 } |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CSatIcon::NewL |
|
80 // Two-phased constructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CSatIcon* CSatIcon::NewL |
|
84 ( |
|
85 CSatMessHandler* aSatMessHandler, |
|
86 CTsySatMessaging* aSatMessaging |
|
87 ) |
|
88 { |
|
89 OstTrace0( TRACE_NORMAL, CSATICON_NEWL, "CSatIcon::NewL" ); |
|
90 TFLOGSTRING("TSY: CSatIcon::NewL"); |
|
91 |
|
92 CSatIcon* self = new( ELeave ) CSatIcon( aSatMessHandler, aSatMessaging ); |
|
93 |
|
94 CleanupStack::PushL( self ); |
|
95 self->ConstructL(); |
|
96 CleanupStack::Pop( self ); |
|
97 |
|
98 return self; |
|
99 } |
|
100 |
|
101 |
|
102 // ----------------------------------------------------------------------------- |
|
103 // CSatCC::~CSatCC |
|
104 // C++ destructor |
|
105 // ----------------------------------------------------------------------------- |
|
106 // |
|
107 CSatIcon::~CSatIcon() |
|
108 { |
|
109 OstTrace0( TRACE_NORMAL, DUP1_CSATICON_CSATICON, "CSatIcon::~CSatIcon" ); |
|
110 TFLOGSTRING("TSY: CSatIcon::~CSatIcon"); |
|
111 } |
|
112 |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CSatIcon::GetIcon |
|
116 // This method gets the content of the EF_IMG record specified |
|
117 // by aRecordnumber |
|
118 // ----------------------------------------------------------------------------- |
|
119 // |
|
120 TInt CSatIcon::GetIcon |
|
121 ( |
|
122 TUint8* aRecordNumber, // Record number |
|
123 RSat::TIcon* aIconEf, // Icon elementary file |
|
124 TTsyReqHandle aTsyReqHandle // Request handle |
|
125 ) |
|
126 { |
|
127 OstTrace0( TRACE_NORMAL, CSATICON_GETICON, "CSatIcon::GetIcon" ); |
|
128 TFLOGSTRING("TSY: CSatIcon::GetIcon"); |
|
129 iImageInstanceNoInRecord = 0; |
|
130 |
|
131 TInt ret( KErrNone ); |
|
132 |
|
133 if ( iIconTsyReqHandle ) |
|
134 { |
|
135 TFLOGSTRING("TSY: CSatIcon::GetIcon : KErrServerBusy"); |
|
136 OstTrace0( TRACE_NORMAL, DUP1_CSATICON_GETICON, "CSatIcon::GetIcon : KErrServerBusy" ); |
|
137 |
|
138 iSatMessaging->ReqCompleted( aTsyReqHandle, KErrServerBusy); |
|
139 } |
|
140 else |
|
141 { |
|
142 iIconData = aIconEf; |
|
143 iIconTsyReqHandle = aTsyReqHandle; |
|
144 iGetIconFlag = ETrue; |
|
145 iRecordNumber = *aRecordNumber; |
|
146 |
|
147 ret = iSatMessHandler->UiccReadSatIconReq( |
|
148 *aRecordNumber, |
|
149 0, // File offset, read from start of record |
|
150 0, // Data amouont, read all the data |
|
151 KUiccTrIdReadSatIcon ); |
|
152 } |
|
153 |
|
154 TFLOGSTRING2("TSY: CSatIcon::GetIcon, ret: %d", ret ); |
|
155 OstTrace1( TRACE_NORMAL, DUP3_CSATICON_GETICON, "CSatIcon::GetIcon, ret: %d", ret ); |
|
156 |
|
157 return ret; |
|
158 |
|
159 } |
|
160 |
|
161 // ----------------------------------------------------------------------------- |
|
162 // CSatIcon::CompleteIconRequest |
|
163 // Completes icon request |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 void CSatIcon::CompleteIconRequest |
|
167 ( |
|
168 TInt aStatus, // Message sending status |
|
169 TPtrC8 aIcon, // Icon elementary file data |
|
170 const TDesC8& aInfo // Icon info block |
|
171 ) |
|
172 { |
|
173 OstTrace0( TRACE_NORMAL, CSATICON_COMPLETEICONREQUEST, "CSatIcon::CompleteIconRequest" ); |
|
174 TFLOGSTRING("TSY: CSatIcon::CompleteIconRequest, entered"); |
|
175 |
|
176 if ( iIconTsyReqHandle ) |
|
177 { |
|
178 if ( KErrNone == aStatus && aIcon.Length() > 0) |
|
179 { |
|
180 //check the size.... |
|
181 if ( (*iIconData).MaxLength() >= aIcon.Length()) |
|
182 { |
|
183 //icon body |
|
184 if( aInfo.Length() == 6 ) |
|
185 { |
|
186 // Color coding scheme is located at index 3 in Image |
|
187 // Instance's Description. |
|
188 TInt index( 3 + ( iImageInstanceNoInRecord - 1) |
|
189 * KDescriptionSize ); |
|
190 |
|
191 TInt colorCoding = iRecordData[index]; |
|
192 if ( KBlackAndWhite == colorCoding ) |
|
193 { |
|
194 // Black and white icon info block contain only |
|
195 // two bytes: width and heigth |
|
196 (*iIconData).Copy( aInfo.Mid( 0, 2) ); |
|
197 } |
|
198 else |
|
199 { |
|
200 // Color icons have six bytes info block |
|
201 (*iIconData).Copy( aInfo ); |
|
202 } |
|
203 |
|
204 // Append icon data after the info block |
|
205 (*iIconData).Append( aIcon ); |
|
206 } |
|
207 //clut and record |
|
208 else |
|
209 { |
|
210 (*iIconData).Copy( aIcon ); |
|
211 } |
|
212 |
|
213 // if this is completed for GetIcon request, store records |
|
214 // content |
|
215 if( iGetIconFlag ) |
|
216 { |
|
217 iRecordData.Copy( *iIconData ); |
|
218 } |
|
219 } |
|
220 else //data is too big for client's buffer |
|
221 { |
|
222 aStatus = KErrOverflow; |
|
223 (*iIconData).Zero(); |
|
224 } |
|
225 } |
|
226 else |
|
227 { |
|
228 //reset the length |
|
229 (*iIconData).Zero(); |
|
230 } |
|
231 |
|
232 iIconData = NULL; |
|
233 iGetIconFlag = EFalse; |
|
234 TFLOGSTRING2("TSY: CSatIcon::CompleteIconRequest, aStatus: %d", aStatus ); |
|
235 OstTrace1( TRACE_NORMAL, DUP1_CSATICON_COMPLETEICONREQUEST, "CSatIcon::CompleteIconRequest, aStatus: %d", aStatus ); |
|
236 |
|
237 iSatMessaging->ReqCompleted( iIconTsyReqHandle, aStatus ); |
|
238 iIconTsyReqHandle = NULL; |
|
239 |
|
240 } |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CSatIcon::GetImageInstance |
|
245 // This method gets the image instance specified by the |
|
246 // InstanceNumber, Offset and Length |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 TInt CSatIcon::GetImageInstance |
|
250 ( |
|
251 TDesC8* aInstanceInfo, // instance info |
|
252 TDes8* aInstance, // instance |
|
253 TTsyReqHandle aTsyReqHandle // request handle |
|
254 ) |
|
255 { |
|
256 OstTrace0( TRACE_NORMAL, CSATICON_GETIMAGEINSTANCE, "CSatIcon::GetImageInstance" ); |
|
257 TFLOGSTRING("TSY: CSatIcon::GetImageInstance"); |
|
258 |
|
259 TInt ret( KErrNotFound ); |
|
260 |
|
261 if( iIconTsyReqHandle ) |
|
262 { |
|
263 TFLOGSTRING("TSY: CSatIcon::GetImageInstance : KErrServerBusy"); |
|
264 OstTrace0( TRACE_NORMAL, DUP1_CSATICON_GETIMAGEINSTANCE, "CSatIcon::GetImageInstance : KErrServerBusy" ); |
|
265 |
|
266 iSatMessaging->ReqCompleted( aTsyReqHandle, KErrServerBusy); |
|
267 } |
|
268 else |
|
269 { |
|
270 iIconData = aInstance; |
|
271 iIconTsyReqHandle = aTsyReqHandle; |
|
272 |
|
273 RSat::TInstanceInfoV2Pckg* aPckg = |
|
274 REINTERPRET_CAST( RSat::TInstanceInfoV2Pckg*, aInstanceInfo ); |
|
275 RSat::TInstanceInfoV2& instanceInfo = ( *aPckg ) (); |
|
276 |
|
277 //Calculate position for icon imageinstance selected from record. |
|
278 TInt iconNumber = iRecordData[0]; |
|
279 TBool iconFound(EFalse); |
|
280 TInt pos(4); |
|
281 while( iconNumber && !iconFound ) |
|
282 { |
|
283 if( ( (TUint16)instanceInfo.iInstanceNumber == |
|
284 (TUint16)(iRecordData[pos]<<8 | iRecordData[pos+1])) |
|
285 && ( (TUint16)instanceInfo.iOffset == |
|
286 (TUint16)(iRecordData[pos+2]<<8 | iRecordData[pos+3])) |
|
287 && ( (TUint16)instanceInfo.iLength == |
|
288 (TUint16)(iRecordData[pos+4]<<8 | iRecordData[pos+5]))) |
|
289 { |
|
290 iconFound = ETrue; |
|
291 } |
|
292 pos+= 9; |
|
293 iconNumber--; |
|
294 } |
|
295 |
|
296 iImageInstanceNoInRecord = iRecordData[0] - iconNumber; |
|
297 |
|
298 //Check icon data length |
|
299 if( ( KIconDataMaxSize > instanceInfo.iLength ) && iconFound ) |
|
300 { |
|
301 // Calculate the offset of instance |
|
302 TUint8 instanceOffset( |
|
303 ( iImageInstanceNoInRecord - 1 ) * KDescriptionSize + 1 ); |
|
304 |
|
305 |
|
306 // At first read image instance data from record of EF IMG |
|
307 ret = iSatMessHandler->UiccReadSatIconReq( |
|
308 iRecordNumber, |
|
309 instanceOffset, |
|
310 KDescriptionSize, |
|
311 KUiccTrIdReadIconInstancePhase1 |
|
312 ); |
|
313 } |
|
314 } |
|
315 TFLOGSTRING2("TSY: CSatIcon::GetImageInstance, ret: %d", ret ); |
|
316 OstTrace1( TRACE_NORMAL, DUP3_CSATICON_GETIMAGEINSTANCE, "CSatIcon::GetImageInstance, ret: %d", ret ); |
|
317 |
|
318 return ret; |
|
319 } |
|
320 |
|
321 |
|
322 // ----------------------------------------------------------------------------- |
|
323 // CSatIcon::GetClut |
|
324 // This method gets the CLUT (Color look-up table) specified |
|
325 // by aInstanceNumber and Offset. |
|
326 // ----------------------------------------------------------------------------- |
|
327 // |
|
328 TInt CSatIcon::GetClut |
|
329 ( |
|
330 RSat::TInstanceNumberAndOffset*, |
|
331 TDes8* aClut, // Colour look-up table |
|
332 TTsyReqHandle aTsyReqHandle // Request handle |
|
333 ) |
|
334 { |
|
335 OstTrace0( TRACE_NORMAL, CSATICON_GETCLUT, "CSatIcon::GetClut" ); |
|
336 TFLOGSTRING("TSY: CSatIcon::GetClut"); |
|
337 TInt ret( KErrNotFound ); |
|
338 |
|
339 if( iIconTsyReqHandle ) |
|
340 { |
|
341 TFLOGSTRING("TSY: CSatIcon::GetClut : KErrServerBusy"); |
|
342 OstTrace0( TRACE_NORMAL, DUP1_CSATICON_GETCLUT, "CSatIcon::GetClut : KErrServerBusy" ); |
|
343 |
|
344 iSatMessaging->ReqCompleted( aTsyReqHandle, KErrServerBusy); |
|
345 } |
|
346 else |
|
347 { |
|
348 iIconData = aClut; |
|
349 iIconTsyReqHandle = aTsyReqHandle; |
|
350 |
|
351 // Image instance elementary file (includes also clut ) was read in |
|
352 // previous phase. Read data from sat message handler and complete |
|
353 // request. Check icon data length |
|
354 if( KIconDataMaxSize > (*aClut).MaxLength() ) |
|
355 { |
|
356 TBuf8<1> infoNotSet( 0 ); |
|
357 TPtrC8 clutData( iSatMessHandler->GetClut() ); |
|
358 CompleteIconRequest( KErrNone, clutData, infoNotSet ); |
|
359 } |
|
360 } |
|
361 TFLOGSTRING2("TSY: CSatIcon::GetClut, ret: %d", ret ); |
|
362 OstTrace1( TRACE_NORMAL, DUP3_CSATICON_GETCLUT, "CSatIcon::GetClut, ret: %d", ret ); |
|
363 |
|
364 iImageInstanceNoInRecord = 0; |
|
365 return ret; |
|
366 } |
|
367 |
|
368 |
|
369 |
|
370 // ================= OTHER EXPORTED FUNCTIONS ================================= |
|
371 |