author | mikaruus |
Tue, 19 Oct 2010 13:16:20 +0300 | |
changeset 9 | 8486d82aef45 |
parent 5 | 8ccc39f9d787 |
permissions | -rw-r--r-- |
0 | 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 |
// EXTERNAL RESOURCES |
|
21 |
||
22 |
// Include Files |
|
23 |
#include <ctsy/rmmcustomapi.h> |
|
24 |
#include "cmmsmscache.h" |
|
25 |
#include "tsylogger.h" |
|
26 |
#include "tisi.h" |
|
27 |
#include <smsisi.h> |
|
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
28 |
#include "OstTraceDefinitions.h" |
0 | 29 |
#ifdef OST_TRACE_COMPILER_IN_USE |
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
30 |
#include "cmmsmscacheTraces.h" |
0 | 31 |
#endif |
32 |
||
33 |
// External Data Structures |
|
34 |
// none |
|
35 |
||
36 |
// External Function Prototypes |
|
37 |
// none |
|
38 |
||
39 |
// LOCAL CONSTANTS AND MACROS |
|
40 |
// none |
|
41 |
||
42 |
// MODULE DATA STRUCTURES |
|
43 |
||
44 |
// Local Data Structures |
|
45 |
// none |
|
46 |
||
47 |
// Local Function Prototypes |
|
48 |
// none |
|
49 |
||
50 |
// LOCAL FUNCTIONS |
|
51 |
// none |
|
52 |
||
53 |
// MEMBER FUNCTIONS |
|
54 |
||
55 |
//============================================================================= |
|
56 |
||
57 |
// ----------------------------------------------------------------------------- |
|
58 |
// CMmSmsCache::CMmSmsCache |
|
59 |
// Creates new CMmSmsCache object |
|
60 |
// ----------------------------------------------------------------------------- |
|
61 |
// |
|
62 |
CMmSmsCache::CMmSmsCache() |
|
63 |
{ |
|
64 |
TFLOGSTRING("TSY: CMmSmsCache::CMmSmsCache"); |
|
9 | 65 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_CMMSMSCACHE_TD, "CMmSmsCache::CMmSmsCache" ); |
0 | 66 |
Reset(); |
67 |
// If SIM is offline,then won't get |
|
68 |
// sim ready completion and cache error state stays as |
|
69 |
// KErrNotFound. If user accesses SIM SMS --> immediate complete |
|
70 |
// with KErrNotFound |
|
71 |
SetStatus( KErrNotFound ); |
|
72 |
} |
|
73 |
||
74 |
// ----------------------------------------------------------------------------- |
|
75 |
// CMmSmsCache::~CMmSmsCache |
|
76 |
// delete CMmSmsCache |
|
77 |
// ----------------------------------------------------------------------------- |
|
78 |
// |
|
79 |
CMmSmsCache::~CMmSmsCache() |
|
80 |
{ |
|
81 |
TFLOGSTRING("TSY: CMmSmsCache::~CMmSmsCache"); |
|
9 | 82 |
OstTrace0( TRACE_NORMAL, DUP1_CMMSMSCACHE_CMMSMSCACHE_TD, "CMmSmsCache::~CMmSmsCache" ); |
0 | 83 |
Reset(); |
84 |
} |
|
85 |
||
86 |
// ----------------------------------------------------------------------------- |
|
87 |
// CMmSmsCache::Reset |
|
88 |
// reset cache to not ready state |
|
89 |
// ----------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
void CMmSmsCache::Reset() |
|
92 |
{ |
|
93 |
TFLOGSTRING("TSY: CMmSmsCache::Reset"); |
|
9 | 94 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_RESET_TD, "CMmSmsCache::Reset" ); |
0 | 95 |
|
96 |
iError = KErrNotReady; |
|
97 |
iDeleteLocation = 0; |
|
98 |
||
99 |
for ( TInt i = 0; i < iElements.Count(); i++ ) |
|
100 |
{ |
|
101 |
delete iElements[i]; |
|
102 |
iElements[i] = NULL; |
|
103 |
} |
|
104 |
iElements.Reset(); |
|
105 |
} |
|
106 |
||
107 |
// ----------------------------------------------------------------------------- |
|
108 |
// CMmSmsCache::UsedEntries |
|
109 |
// get the number of used entries from cache |
|
110 |
// ----------------------------------------------------------------------------- |
|
111 |
// |
|
112 |
TInt CMmSmsCache::UsedEntries() |
|
113 |
{ |
|
114 |
TFLOGSTRING("TSY: CMmSmsCache::UsedEntries"); |
|
9 | 115 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_USEDENTRIES_TD, "CMmSmsCache::UsedEntries" ); |
0 | 116 |
TInt count( 0 ); |
117 |
for ( TInt i = 0; i < iElements.Count(); i++ ) |
|
118 |
{ |
|
119 |
if ( iElements[i] ) |
|
120 |
{ |
|
121 |
count++; |
|
122 |
} |
|
123 |
} |
|
124 |
return count; |
|
125 |
} |
|
126 |
||
127 |
// ----------------------------------------------------------------------------- |
|
128 |
// CMmSmsCache::TotalEntries |
|
129 |
// get the total number of entries in SIM |
|
130 |
// ----------------------------------------------------------------------------- |
|
131 |
// |
|
132 |
TInt CMmSmsCache::TotalEntries() |
|
133 |
{ |
|
134 |
TFLOGSTRING2("TSY: CMmSmsCache::TotalEntries: %d",iElements.Count()); |
|
9 | 135 |
OstTrace1( TRACE_NORMAL, CMMSMSCACHE_TOTALENTRIES_TD, "CMmSmsCache::TotalEntries;iElements.Count=%d", iElements.Count() ); |
0 | 136 |
return iElements.Count(); |
137 |
} |
|
138 |
||
139 |
// ----------------------------------------------------------------------------- |
|
140 |
// CMmSmsCache::Status |
|
141 |
// Returns cache status, this can be KErrNotReady (cache is being read) |
|
142 |
// KErrNone (cache is ok and can be used) |
|
143 |
// any other (cache is in error state and is unusable) |
|
144 |
// ----------------------------------------------------------------------------- |
|
145 |
// |
|
146 |
TInt CMmSmsCache::Status() |
|
147 |
{ |
|
148 |
TFLOGSTRING("TSY: CMmSmsCache::Status"); |
|
9 | 149 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_STATUS_TD, "CMmSmsCache::Status" ); |
0 | 150 |
return iError; |
151 |
} |
|
152 |
||
153 |
// ----------------------------------------------------------------------------- |
|
154 |
// CMmSmsCache::SetStatus |
|
155 |
// set cache error state |
|
156 |
// ----------------------------------------------------------------------------- |
|
157 |
// |
|
158 |
void CMmSmsCache::SetStatus( TInt aError ) |
|
159 |
{ |
|
160 |
TFLOGSTRING2("TSY: CMmSmsCache::SetStatus %d", aError); |
|
9 | 161 |
OstTrace1( TRACE_NORMAL, CMMSMSCACHE_SETSTATUS_TD, "CMmSmsCache::SetStatus;aError=%d", aError ); |
0 | 162 |
iError = aError; |
163 |
} |
|
164 |
||
165 |
// ----------------------------------------------------------------------------- |
|
166 |
// CMmSmsCache::SetTotalEntriesL |
|
167 |
// initialize cache to contain aTotal number of empty entries |
|
168 |
// it is assumed that cache is Reset before call to this.. |
|
169 |
// ----------------------------------------------------------------------------- |
|
170 |
// |
|
171 |
void CMmSmsCache::SetTotalEntriesL( TInt aTotal ) |
|
172 |
{ |
|
173 |
TFLOGSTRING2("TSY: CMmSmsCache::SetTotalEntriesL %d", aTotal); |
|
9 | 174 |
OstTrace1( TRACE_NORMAL, CMMSMSCACHE_SETTOTALENTRIESL_TD, "CMmSmsCache::SetTotalEntriesL;aTotal=%d", aTotal ); |
0 | 175 |
|
176 |
RMobileSmsStore::TMobileGsmSmsEntryV1* element = NULL; |
|
177 |
for ( TInt i = 0; i < aTotal; i++ ) |
|
178 |
{ |
|
179 |
iElements.AppendL( element ); |
|
180 |
} |
|
181 |
} |
|
182 |
||
183 |
// ----------------------------------------------------------------------------- |
|
184 |
// CMmSmsCache::AddEntryL |
|
185 |
// adds new entry to cache, if the cause of isi msg is not |
|
186 |
// ok, then we add just a null pointer (to save space) |
|
187 |
// returns true if element was cache and false |
|
188 |
// if cache location is empty |
|
189 |
// ----------------------------------------------------------------------------- |
|
190 |
// |
|
191 |
TBool CMmSmsCache::AddEntryL( |
|
192 |
const RMobileSmsStore::TMobileGsmSmsEntryV1* aEntry, |
|
193 |
const TUint8 aRecordId ) |
|
194 |
{ |
|
195 |
TFLOGSTRING("TSY: CMmSmsCache::AddEntryL"); |
|
9 | 196 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_ADDENTRYL_TD, "CMmSmsCache::AddEntryL" ); |
0 | 197 |
|
198 |
if ( 0 < iElements.Count() ) |
|
199 |
{ |
|
200 |
delete iElements[aRecordId - 1]; |
|
201 |
iElements[aRecordId - 1] = NULL; |
|
202 |
} |
|
203 |
||
204 |
// If the location is non-empty (filled with 0xFF (3GPP TS 31.102 |
|
205 |
// 4.2.25 EFSMS (Short messages))) |
|
206 |
||
207 |
if ( EMPTY_LOCATION != aEntry->iMsgStatus ) |
|
208 |
{ |
|
209 |
// Make a copy of the received SIM SMS. |
|
210 |
// Reserve heap memory; can leave if out of mem. |
|
211 |
RMobileSmsStore::TMobileGsmSmsEntryV1* tmpBuf = |
|
212 |
new( ELeave ) RMobileSmsStore::TMobileGsmSmsEntryV1; |
|
213 |
*tmpBuf = *aEntry; |
|
214 |
// copy data |
|
215 |
iElements[aRecordId - 1] = tmpBuf; |
|
216 |
||
217 |
return ETrue; |
|
218 |
} |
|
219 |
return EFalse; |
|
220 |
} |
|
221 |
||
222 |
// ----------------------------------------------------------------------------- |
|
223 |
// CMmSmsCache::GetEntry |
|
224 |
// get entry from cache, returns null if cache doesn't c;ontain |
|
225 |
// valid entry in the given location location range is in range |
|
226 |
// [1... max sim sms slots] |
|
227 |
// ----------------------------------------------------------------------------- |
|
228 |
// |
|
229 |
RMobileSmsStore::TMobileGsmSmsEntryV1* CMmSmsCache::GetEntry( TInt aLocation ) |
|
230 |
{ |
|
231 |
TFLOGSTRING2("TSY: CMmSmsCache::GetEntry - location: %d", aLocation); |
|
9 | 232 |
OstTrace1( TRACE_NORMAL, CMMSMSCACHE_GETENTRY_TD, "CMmSmsCache::GetEntry;aLocation=%d", aLocation ); |
0 | 233 |
RMobileSmsStore::TMobileGsmSmsEntryV1* smsData = NULL; |
234 |
if ( aLocation <= iElements.Count() && aLocation >= 1 ) |
|
235 |
{ |
|
236 |
if ( iElements[aLocation-1] ) |
|
237 |
{ |
|
238 |
RMobileSmsStore::TMobileGsmSmsEntryV1* tempHBuf( |
|
239 |
iElements[aLocation-1] ); |
|
240 |
smsData = tempHBuf; |
|
241 |
} |
|
242 |
} |
|
243 |
return smsData; |
|
244 |
} |
|
245 |
||
246 |
// ----------------------------------------------------------------------------- |
|
247 |
// CMmSmsCache::FirstFreeLocation |
|
248 |
// return first free location in range [1... max sim sms slots] |
|
249 |
// or zero if no free slots are found |
|
250 |
// ----------------------------------------------------------------------------- |
|
251 |
// |
|
252 |
TUint CMmSmsCache::FirstFreeLocation() |
|
253 |
{ |
|
254 |
TFLOGSTRING("TSY: CMmSmsCache::FirstFreeLocation"); |
|
9 | 255 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_FIRSTFREELOCATION_TD, "CMmSmsCache::FirstFreeLocation" ); |
0 | 256 |
TInt location( 0 ); |
257 |
for ( TInt i = 0; i < iElements.Count(); i++ ) |
|
258 |
{ |
|
259 |
if ( !iElements[i] ) |
|
260 |
{ |
|
261 |
location = i + 1; |
|
262 |
i = iElements.Count(); // exit loop |
|
263 |
} |
|
264 |
} |
|
265 |
TFLOGSTRING2("TSY: CMmSmsCache::FirstFreeLocation - found location: %d", location); |
|
9 | 266 |
OstTrace0( TRACE_NORMAL, DUP1_CMMSMSCACHE_FIRSTFREELOCATION_TD, "CMmSmsCache::FirstFreeLocation" ); |
0 | 267 |
return location; |
268 |
} |
|
269 |
||
270 |
// ----------------------------------------------------------------------------- |
|
271 |
// CMmSmsCache::SetDeleteLocation |
|
272 |
// set the location to delete by Delete() |
|
273 |
// ----------------------------------------------------------------------------- |
|
274 |
// |
|
275 |
void CMmSmsCache::SetDeleteLocation( TInt aLocation ) |
|
276 |
{ |
|
277 |
TFLOGSTRING2("TSY: CMmSmsCache::SetDeleteLocation %d", aLocation); |
|
9 | 278 |
OstTrace1( TRACE_NORMAL, CMMSMSCACHE_SETDELETELOCATION_TD, "CMmSmsCache::SetDeleteLocation;aLocation=%d", aLocation ); |
0 | 279 |
iDeleteLocation = aLocation; |
280 |
} |
|
281 |
||
282 |
// ----------------------------------------------------------------------------- |
|
283 |
// CMmSmsCache::Delete |
|
284 |
// if flush location is set, then flush it |
|
285 |
// ----------------------------------------------------------------------------- |
|
286 |
// |
|
287 |
void CMmSmsCache::Delete() |
|
288 |
{ |
|
289 |
TFLOGSTRING("TSY: CMmSmsCache::Delete"); |
|
9 | 290 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_DELETE_TD, "CMmSmsCache::Delete" ); |
0 | 291 |
if ( iDeleteLocation!=0 ) |
292 |
{ |
|
293 |
Delete( iDeleteLocation ); |
|
294 |
iDeleteLocation = NULL; |
|
295 |
} |
|
296 |
} |
|
297 |
||
298 |
// ----------------------------------------------------------------------------- |
|
299 |
// CMmSmsCache::Delete |
|
300 |
// Delete an element from cache |
|
301 |
// ----------------------------------------------------------------------------- |
|
302 |
// |
|
303 |
void CMmSmsCache::Delete( TInt aLocation ) |
|
304 |
{ |
|
305 |
TFLOGSTRING2("TSY: CMmSmsCache::Delete %d", aLocation); |
|
9 | 306 |
OstTrace1( TRACE_NORMAL, DUP1_CMMSMSCACHE_DELETE_TD, "CMmSmsCache::Delete;aLocation=%d", aLocation ); |
0 | 307 |
|
308 |
if ( aLocation <= iElements.Count() && aLocation >= 1 ) |
|
309 |
{ |
|
310 |
delete iElements[aLocation-1]; |
|
311 |
iElements[aLocation-1] = NULL; |
|
312 |
} |
|
313 |
} |
|
314 |
||
315 |
// ----------------------------------------------------------------------------- |
|
316 |
// CMmSmsCache::DeleteAll |
|
317 |
// empty all of cache |
|
318 |
// ----------------------------------------------------------------------------- |
|
319 |
// |
|
320 |
void CMmSmsCache::DeleteAll() |
|
321 |
{ |
|
322 |
TFLOGSTRING("TSY: CMmSmsCache::DeleteAll"); |
|
9 | 323 |
OstTrace0( TRACE_NORMAL, CMMSMSCACHE_DELETEALL_TD, "CMmSmsCache::DeleteAll" ); |
0 | 324 |
for ( TInt i = 0; i < iElements.Count(); i++ ) |
325 |
{ |
|
326 |
delete iElements[i]; |
|
327 |
iElements[i] = NULL; |
|
328 |
} |
|
329 |
} |
|
330 |
||
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
331 |
// ----------------------------------------------------------------------------- |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
332 |
// CMmSmsCache::SetStorageStatus |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
333 |
// Changes the storage status of a cached entry (TS 31.102, clause 4.2.25) |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
334 |
// ----------------------------------------------------------------------------- |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
335 |
// |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
336 |
void CMmSmsCache::SetStorageStatus( |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
337 |
TInt aLocation, |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
338 |
RMobileSmsStore::TMobileSmsStoreStatus aMsgStatus ) |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
339 |
{ |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
340 |
TFLOGSTRING2("TSY: CMmSmsCache::SetStorageStatus(loc=%d)", aLocation); |
9 | 341 |
OstTrace1( TRACE_NORMAL, CMMSMSCACHE_SETSTORAGESTATUS_TD, "CMmSmsCache::SetStorageStatus;aLocation=%d", aLocation ); |
5
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
342 |
|
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
343 |
if ( aLocation <= iElements.Count() |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
344 |
&& aLocation >= 1 |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
345 |
&& iElements[aLocation-1] ) |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
346 |
{ |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
347 |
// Entry exists, update status. |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
348 |
iElements[aLocation-1]->iMsgStatus = aMsgStatus; |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
349 |
} |
8ccc39f9d787
New release based on our 2010wk02 release
mikaruus <mika.a.ruuskanen@nokia.com>
parents:
0
diff
changeset
|
350 |
} |
0 | 351 |
// End of File |