|
1 // Copyright (c) 1998-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 #include <s32std.h> |
|
17 |
|
18 #include "MSVSTD.H" |
|
19 #include "MSVRCPT.H" |
|
20 #include "MSVIDS.H" |
|
21 #include "MSVUIDS.H" |
|
22 #include "MSVPANIC.H" |
|
23 |
|
24 const TInt KMessageSelectionGranularity=32; |
|
25 |
|
26 _LIT(KDefaultSubjectSkipString,": "); |
|
27 |
|
28 //********************************** |
|
29 // TMsvEntry |
|
30 //********************************** |
|
31 |
|
32 EXPORT_C TMsvEntry::TMsvEntry() |
|
33 : iId(KMsvNullIndexEntryId), iParentId(KMsvNullIndexEntryId), iData(KMsvEntryMediumPriority), |
|
34 iPcSyncCount(0), iReserved(0), |
|
35 iServiceId(KMsvNullIndexEntryId), iRelatedId(KMsvNullIndexEntryId), |
|
36 iType(KUidMsvNullEntry), iMtm(KUidMsvNullEntry), |
|
37 iSize(0), iError(KErrNone), iBioType(0), |
|
38 iMtmData1(0), iMtmData2(0), iMtmData3(0) |
|
39 /** Default constructor. |
|
40 |
|
41 Initialises the new object to null values: 0 for integer values, KMsvNullIndexEntryId |
|
42 for IDs, and KUidMsvNullEntry for UIDs. */ |
|
43 { |
|
44 } |
|
45 |
|
46 EXPORT_C TMsvEntry::TMsvEntry(const TMsvEntry& aEntry) |
|
47 /** Copy constructor. |
|
48 |
|
49 It creates a simple copy of the entry, so the TPtrC members iDescription and iDetails |
|
50 will point to the same descriptor data in the original and new objects. |
|
51 |
|
52 @param aEntry The entry to copy */ |
|
53 { |
|
54 Copy(aEntry); |
|
55 } |
|
56 |
|
57 EXPORT_C TMsvEntry& TMsvEntry::operator=(const TMsvEntry& aEntry) |
|
58 /** Overloaded assignment operator. |
|
59 |
|
60 This acts similarly to the copy constructor: i.e. it makes a simple copy of entry, |
|
61 so the TPtrC entry description and details members will point to the same |
|
62 descriptor data in the original and new objects. |
|
63 |
|
64 @param aEntry The entry from which to assign |
|
65 @return Object after assignment */ |
|
66 { |
|
67 Copy(aEntry); |
|
68 return *this; |
|
69 } |
|
70 |
|
71 EXPORT_C TBool TMsvEntry::operator==(const TMsvEntry& aEntry) const |
|
72 /** Overloaded equality operator. |
|
73 |
|
74 This tests whether the fields of the specified entry are equal to those of this |
|
75 object. The contents, rather than pointer values, of the TPtrC members are |
|
76 compared. |
|
77 |
|
78 @param aEntry The entry with which to compare |
|
79 @return ETrue if the entries are equal, else EFalse */ |
|
80 { |
|
81 TInt size=sizeof(*this)-2*sizeof(TPtrC); |
|
82 TBool equal = !(Mem::Compare((TUint8*)&aEntry, size, (TUint8*)this, size)); |
|
83 equal &= (aEntry.iDescription==this->iDescription); |
|
84 equal &= (aEntry.iDetails==this->iDetails); |
|
85 return equal; |
|
86 } |
|
87 |
|
88 |
|
89 void TMsvEntry::Copy(const TMsvEntry& aEntry) |
|
90 { |
|
91 Mem::Copy(this,&aEntry,sizeof(*this)); |
|
92 } |
|
93 |
|
94 |
|
95 EXPORT_C TMsvPriority TMsvEntry::Priority() const |
|
96 /** Gets the value of the message priority field. |
|
97 |
|
98 @return The value of the message priority field */ |
|
99 { |
|
100 if (iData&KMsvEntryHighPriority) |
|
101 return EMsvHighPriority; |
|
102 else if (iData&KMsvEntryMediumPriority) |
|
103 return EMsvMediumPriority; |
|
104 else |
|
105 return EMsvLowPriority; |
|
106 } |
|
107 |
|
108 EXPORT_C void TMsvEntry::SetPriority(TMsvPriority aPriority) |
|
109 /** Sets the message priority. |
|
110 |
|
111 @param aPriority Value for the message priority */ |
|
112 { |
|
113 switch (aPriority) |
|
114 { |
|
115 case EMsvHighPriority: |
|
116 iData = (iData & ~KMsvEntryPriorityMask) | KMsvEntryHighPriority; |
|
117 break; |
|
118 case EMsvMediumPriority: |
|
119 iData = (iData & ~KMsvEntryPriorityMask) | KMsvEntryMediumPriority; |
|
120 break; |
|
121 default: |
|
122 iData = (iData & ~KMsvEntryPriorityMask) | KMsvEntryLowPriority; |
|
123 } |
|
124 } |
|
125 |
|
126 |
|
127 EXPORT_C void TMsvEntry::InternalizeL(RReadStream& aStream) |
|
128 /** Reads an externalised object from the specified stream. |
|
129 |
|
130 @param aStream Stream from which to read */ |
|
131 { |
|
132 iId = aStream.ReadInt32L(); |
|
133 iParentId = aStream.ReadInt32L(); |
|
134 iData = aStream.ReadInt32L(); |
|
135 iPcSyncCount= aStream.ReadInt32L(); |
|
136 iReserved = aStream.ReadInt32L(); |
|
137 // |
|
138 iServiceId = aStream.ReadInt32L(); |
|
139 iRelatedId = aStream.ReadInt32L(); |
|
140 aStream >> iType; |
|
141 aStream >> iMtm; |
|
142 // |
|
143 TInt64 time; |
|
144 aStream >> time; |
|
145 iDate = time; |
|
146 // |
|
147 iSize = aStream.ReadInt32L(); |
|
148 iError = aStream.ReadInt32L(); |
|
149 iBioType = aStream.ReadInt32L(); |
|
150 // |
|
151 iMtmData1 = aStream.ReadInt32L(); |
|
152 iMtmData2 = aStream.ReadInt32L(); |
|
153 iMtmData3 = aStream.ReadInt32L(); |
|
154 } |
|
155 |
|
156 |
|
157 |
|
158 EXPORT_C void TMsvEntry::ExternalizeL(RWriteStream& aStream) const |
|
159 /** Writes the object into the stream specified. |
|
160 |
|
161 @param aStream Stream to which to write */ |
|
162 { |
|
163 aStream.WriteUint32L(iId); |
|
164 aStream.WriteUint32L(iParentId); |
|
165 aStream.WriteUint32L(iData & KMsvEntryPersistedFlags); |
|
166 aStream.WriteUint32L(iPcSyncCount); |
|
167 aStream.WriteUint32L(iReserved); |
|
168 // |
|
169 aStream.WriteUint32L(iServiceId); |
|
170 aStream.WriteUint32L(iRelatedId); |
|
171 aStream << iType; |
|
172 aStream << iMtm; |
|
173 // |
|
174 aStream << iDate.Int64(); |
|
175 // |
|
176 aStream.WriteUint32L(iSize); |
|
177 aStream.WriteUint32L(iError); |
|
178 aStream.WriteUint32L(iBioType); |
|
179 // |
|
180 aStream.WriteUint32L(iMtmData1); |
|
181 aStream.WriteUint32L(iMtmData2); |
|
182 aStream.WriteUint32L(iMtmData3); |
|
183 } |
|
184 |
|
185 |
|
186 /** Compares if the flag settings in two index entries are the same. The |
|
187 Connected and Pending Delete flags are not used in the comparison, as they |
|
188 indicate temporary conditions of the entry. |
|
189 |
|
190 @param aEntry Index entry to compare against |
|
191 @return True if the flags settings are equal, otherwise false |
|
192 */ |
|
193 EXPORT_C TBool TMsvEntry::PermanentDataUnchanged(const TMsvEntry& aEntry) const |
|
194 // |
|
195 // Returns true if the permanent data is equal |
|
196 // |
|
197 { |
|
198 TMsvEntry self=*this; |
|
199 TMsvEntry that=aEntry; |
|
200 self.iData &= KMsvEntryPersistedFlags; |
|
201 that.iData &= KMsvEntryPersistedFlags; |
|
202 return self==that; |
|
203 } |
|
204 |
|
205 /** Gets the pending conditions flag. |
|
206 |
|
207 @return |
|
208 The value for the pending conditions flag. |
|
209 */ |
|
210 EXPORT_C TBool TMsvEntry::PendingConditions() const |
|
211 { |
|
212 return iData & KMsvEntryPendingConditionsFlag; |
|
213 } |
|
214 |
|
215 /** Sets the pending conditions flag. |
|
216 |
|
217 @param aScheduled |
|
218 The value for the pending conditions flag. |
|
219 */ |
|
220 EXPORT_C void TMsvEntry::SetPendingConditions(TBool aPendingConditions) |
|
221 { |
|
222 iData = (iData & ~KMsvEntryPendingConditionsFlag) | (aPendingConditions ? KMsvEntryPendingConditionsFlag : KMsvEntryClearFlag); |
|
223 } |
|
224 |
|
225 /** Gets the integer value of iMtmData1 |
|
226 |
|
227 @return the integer value of iMtmData1 |
|
228 */ |
|
229 EXPORT_C TInt32 TMsvEntry::MtmData1() const |
|
230 { |
|
231 return iMtmData1; |
|
232 } |
|
233 |
|
234 /** Gets the integer value of iMtmData2 |
|
235 |
|
236 @return the integer value of iMtmData2 |
|
237 */ |
|
238 EXPORT_C TInt32 TMsvEntry::MtmData2() const |
|
239 { |
|
240 return iMtmData2; |
|
241 } |
|
242 |
|
243 /** Gets the integer value of iMtmData3 |
|
244 |
|
245 @return the integer value of iMtmData3 |
|
246 */ |
|
247 EXPORT_C TInt32 TMsvEntry::MtmData3() const |
|
248 { |
|
249 return iMtmData3; |
|
250 } |
|
251 |
|
252 /** Sets the value of iMtmData1. This API should only be called |
|
253 by Symbian Software Ltd. |
|
254 |
|
255 @param aMtmData Value of the data to be stored in iMtmData1 |
|
256 |
|
257 @internalTechnology |
|
258 */ |
|
259 EXPORT_C void TMsvEntry::SetMtmData1(TInt32 aMtmData) |
|
260 { |
|
261 iMtmData1 = aMtmData; |
|
262 } |
|
263 |
|
264 /** Sets the value of iMtmData2. This API should only be called |
|
265 by Symbian Software Ltd. |
|
266 |
|
267 @param aMtmData Value of the data to be stored in iMtmData2 |
|
268 |
|
269 @internalTechnology |
|
270 */ |
|
271 EXPORT_C void TMsvEntry::SetMtmData2(TInt32 aMtmData) |
|
272 { |
|
273 iMtmData2 = aMtmData; |
|
274 } |
|
275 |
|
276 /** Sets the value of iMtmData3. This API should only be called |
|
277 by Symbian Software Ltd. |
|
278 |
|
279 @param aMtmData Value of the data to be stored in iMtmData3 |
|
280 |
|
281 @internalTechnology |
|
282 */ |
|
283 EXPORT_C void TMsvEntry::SetMtmData3(TInt32 aMtmData) |
|
284 { |
|
285 iMtmData3 = aMtmData; |
|
286 } |
|
287 |
|
288 //********************************** |
|
289 // CMsvEntrySelection |
|
290 //********************************** |
|
291 |
|
292 EXPORT_C CMsvEntrySelection::CMsvEntrySelection() |
|
293 : CArrayFixFlat<TMsvId>(KMessageSelectionGranularity) |
|
294 /** Creates an empty array. */ |
|
295 { |
|
296 } |
|
297 |
|
298 |
|
299 EXPORT_C CMsvEntrySelection* CMsvEntrySelection::CopyL() const |
|
300 /** Creates a new CMsvEntrySelection object with the same contents as the current |
|
301 object. The client should delete the object when it is no longer required. |
|
302 |
|
303 @leave KErrNoMemory A memory allocation failed. |
|
304 @return New CMsvEntrySelection with same selection as current object */ |
|
305 { |
|
306 CMsvEntrySelection* newSelection = CopyLC(); |
|
307 CleanupStack::Pop(); |
|
308 return newSelection; |
|
309 } |
|
310 |
|
311 EXPORT_C CMsvEntrySelection* CMsvEntrySelection::CopyLC() const |
|
312 /** Creates a new CMsvEntrySelection object with the same contents as the current |
|
313 object. The client should delete the object when it is no longer required. |
|
314 |
|
315 The function leaves the new object on the cleanup stack. |
|
316 |
|
317 @leave KErrNoMemory A memory allocation failed. |
|
318 @return New CMsvEntrySelection with same selection as current object */ |
|
319 { |
|
320 CMsvEntrySelection* newSelection = new (ELeave) CMsvEntrySelection; |
|
321 CleanupStack::PushL(newSelection); |
|
322 if (Count()) |
|
323 { |
|
324 newSelection->ResizeL(Count(), KMsvNullIndexEntryId); |
|
325 Mem::Copy(newSelection->Back(0), Back(0), Count()*sizeof(TMsvId)); |
|
326 } |
|
327 return newSelection; |
|
328 } |
|
329 |
|
330 |
|
331 EXPORT_C TInt CMsvEntrySelection::Find(TMsvId aId) const |
|
332 /** Finds an item in the array by its entry ID. |
|
333 |
|
334 @param aId ID to find |
|
335 @return The index of the position of the entry in the array, or KErrNotFound |
|
336 if the selection does not contain the ID. */ |
|
337 { |
|
338 TInt count=Count(); |
|
339 if (count) |
|
340 { |
|
341 const TMsvId* ptr = End(0); |
|
342 while (count--) |
|
343 if (*(--ptr)==aId) |
|
344 break; |
|
345 return count; |
|
346 } |
|
347 else |
|
348 return KErrNotFound; |
|
349 } |
|
350 |
|
351 |
|
352 //********************************** |
|
353 // TMsvSelectionOrdering |
|
354 //********************************** |
|
355 |
|
356 EXPORT_C TMsvSelectionOrdering::TMsvSelectionOrdering() |
|
357 :iGrouping(0), iSortType(EMsvSortByNone) |
|
358 ,iSubjectSkipString(KDefaultSubjectSkipString) |
|
359 /** Default constructor. |
|
360 |
|
361 Creates a new object with no grouping, and sets the sorting to EMsvSortByNone. */ |
|
362 {} |
|
363 |
|
364 EXPORT_C TMsvSelectionOrdering::TMsvSelectionOrdering(TInt aGroupingKey, TMsvSorting aSorting, TBool aShowInvisible) |
|
365 : iGrouping(aGroupingKey), iSortType(aSorting) |
|
366 ,iSubjectSkipString(KDefaultSubjectSkipString) |
|
367 |
|
368 /** Creates a new object, sets the group, sort order, and show-invisibility options |
|
369 to those specified in the parameters. |
|
370 |
|
371 @param aGroupingKey A bitmask of grouping options. For the values to use, |
|
372 see TMsvGrouping. |
|
373 @param aSorting Sorting order. |
|
374 @param aShowInvisible Determines whether invisible entries are included in |
|
375 the selection */ |
|
376 { |
|
377 SetShowInvisibleEntries(aShowInvisible); |
|
378 } |
|
379 |
|
380 EXPORT_C void TMsvSelectionOrdering::InternalizeL(RReadStream& aStream) |
|
381 /** Reads an externalised object from the specified stream. |
|
382 |
|
383 @param aStream Stream from which to read */ |
|
384 { |
|
385 iGrouping = aStream.ReadInt32L(); |
|
386 iSortType = (TMsvSorting) aStream.ReadInt32L(); |
|
387 if (iSortType<EMsvSortByNone && iSortType>EMsvSortByDescriptionReverse) |
|
388 iSortType=EMsvSortByNone; |
|
389 aStream >> iSubjectSkipString; |
|
390 } |
|
391 |
|
392 EXPORT_C void TMsvSelectionOrdering::ExternalizeL(RWriteStream& aStream) const |
|
393 /** Writes the object into the specified stream. |
|
394 |
|
395 @param aStream Stream to which to write */ |
|
396 { |
|
397 aStream.WriteInt32L(iGrouping); |
|
398 aStream.WriteInt32L((TInt)iSortType); |
|
399 aStream << iSubjectSkipString; |
|
400 } |
|
401 |
|
402 EXPORT_C TBool TMsvSelectionOrdering::operator==(const TMsvSelectionOrdering& aOrdering) const |
|
403 /** Tests two TMsvSelectionOrdering objects for equality. |
|
404 |
|
405 Two TMsvSelectionOrdering objects are equal if the same grouping and sorting |
|
406 options have been set on each. |
|
407 |
|
408 @param aOrdering The object with which to compare |
|
409 @return ETrue if the objects are equal, else EFalse */ |
|
410 { |
|
411 return (aOrdering.iGrouping==iGrouping && aOrdering.iSortType==iSortType && iSubjectSkipString == aOrdering.iSubjectSkipString); |
|
412 // TInt size=sizeof(*this); |
|
413 // return !(Mem::Compare((TUint8*)&aOrdering, size, (TUint8*)this, size)); |
|
414 } |
|
415 |
|
416 EXPORT_C const TDesC& TMsvSelectionOrdering::SubjectSkipString() const |
|
417 /** Get the current subject skip string |
|
418 |
|
419 @return The current subject skip string*/ |
|
420 { |
|
421 return iSubjectSkipString; |
|
422 } |
|
423 |
|
424 EXPORT_C void TMsvSelectionOrdering::SetSubjectSkipString(const TDesC& aSubjectSkipString) |
|
425 /** Set the subject skip string up to maximum length of KMaxSubjectSkipStringLength |
|
426 |
|
427 @panic USER 11, if the length of the descriptor aSubjectSkipString is greater than |
|
428 KMaxSubjectSkipStringLength (defined in <msvstd.h>) */ |
|
429 { |
|
430 //Check whether SubjectSkipString is empty. If so set it to default |
|
431 if(aSubjectSkipString.Length() == 0) |
|
432 { |
|
433 iSubjectSkipString = KDefaultSubjectSkipString; |
|
434 } |
|
435 else |
|
436 { |
|
437 iSubjectSkipString = aSubjectSkipString; |
|
438 } |
|
439 |
|
440 } |
|
441 |
|
442 //********************************** |
|
443 // CMsvRecipient |
|
444 //********************************** |
|
445 |
|
446 |
|
447 EXPORT_C CMsvRecipient::CMsvRecipient() |
|
448 /** Protected base class default constructor. */ |
|
449 {} |
|
450 |
|
451 EXPORT_C void CMsvRecipient::InternalizeL(RReadStream& aStream) |
|
452 /** Internalises the object from a read stream. |
|
453 |
|
454 @param aStream The stream from which the object should be internalised. */ |
|
455 { |
|
456 iStatus = (TRecipientStatus)aStream.ReadInt32L(); |
|
457 iError = aStream.ReadInt32L(); |
|
458 iRetries = aStream.ReadInt32L(); |
|
459 TInt64 time; |
|
460 aStream >> time; |
|
461 iTime = time; |
|
462 } |
|
463 |
|
464 EXPORT_C void CMsvRecipient::ExternalizeL(RWriteStream& aStream) const |
|
465 /** Externalises the object to a write stream. |
|
466 |
|
467 @param aStream Stream to which the object should be externalised. */ |
|
468 { |
|
469 aStream.WriteInt32L((TInt)iStatus); |
|
470 aStream.WriteInt32L(iError); |
|
471 aStream.WriteInt32L(iRetries); |
|
472 aStream << iTime.Int64(); |
|
473 } |
|
474 |
|
475 //********************************** |
|
476 // CMsvEntryFilter |
|
477 //********************************** |
|
478 |
|
479 EXPORT_C CMsvEntryFilter* CMsvEntryFilter::NewLC() |
|
480 /** Allocates and constructs a new entry filter, and leaves the pointer on the |
|
481 cleanup stack. |
|
482 |
|
483 For default values, see the NewL() function. |
|
484 |
|
485 @return Pointer to the newly created entry filter. */ |
|
486 { |
|
487 CMsvEntryFilter* self = new(ELeave)CMsvEntryFilter(); |
|
488 CleanupStack::PushL(self); |
|
489 return self; |
|
490 } |
|
491 |
|
492 EXPORT_C CMsvEntryFilter* CMsvEntryFilter::NewL() |
|
493 /** Allocates and constructs a new entry filter. |
|
494 |
|
495 Default values are as follows: |
|
496 |
|
497 1. service: KMsvNullIndexEntryId |
|
498 |
|
499 2. MTM: KNullUid |
|
500 |
|
501 3. entry type: KNullUid |
|
502 |
|
503 4. last change date: no date |
|
504 |
|
505 5. sort order defaults to EMsvSortByNone |
|
506 |
|
507 These values mean that entries with any values for service, MTM, type and |
|
508 last change date will be returned, with no grouping or sort MTM. |
|
509 |
|
510 @return Pointer to the newly created entry filter. */ |
|
511 { |
|
512 CMsvEntryFilter* self = NewLC(); |
|
513 CleanupStack::Pop(); // self |
|
514 return self; |
|
515 } |
|
516 |
|
517 CMsvEntryFilter::CMsvEntryFilter() |
|
518 : iServiceId(KMsvNullIndexEntryId), iMtm(KNullUid), iType(KNullUid), iSortMtm(KNullUid) |
|
519 { |
|
520 } |
|
521 |
|
522 // |
|
523 // DLL entry point |
|
524 |