|
1 /* |
|
2 * Copyright (c) 2007 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: Implementation of class CMessageHeader |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <CMsvAttachment.h> |
|
20 #include <senduiconsts.h> |
|
21 |
|
22 #include "messageheader.h" |
|
23 |
|
24 |
|
25 // --------------------------------------------------------------------------- |
|
26 // Two-phased constructor. |
|
27 // --------------------------------------------------------------------------- |
|
28 EXPORT_C CMessageHeader* CMessageHeader::NewL() |
|
29 { |
|
30 CMessageHeader* self = new(ELeave) CMessageHeader(); |
|
31 return self; |
|
32 } |
|
33 |
|
34 // --------------------------------------------------------------------------- |
|
35 // Destructor |
|
36 // --------------------------------------------------------------------------- |
|
37 CMessageHeader::~CMessageHeader() |
|
38 { |
|
39 delete iSubject; |
|
40 delete iFrom; |
|
41 delete iMtmAsString; |
|
42 delete iPriAsString; |
|
43 } |
|
44 |
|
45 // --------------------------------------------------------------------------- |
|
46 // C++ constructor. |
|
47 // --------------------------------------------------------------------------- |
|
48 CMessageHeader::CMessageHeader(): |
|
49 iMtm(TUid(TUid::Null())), |
|
50 iMessageID(-1) |
|
51 { |
|
52 } |
|
53 |
|
54 // --------------------------------------------------------------------------- |
|
55 // Sets the unread flag |
|
56 // --------------------------------------------------------------------------- |
|
57 EXPORT_C void CMessageHeader::SetUnreadFlag(const TBool aUnread) |
|
58 { |
|
59 iUnread = aUnread; |
|
60 } |
|
61 |
|
62 // --------------------------------------------------------------------------- |
|
63 // Gets the unread flag |
|
64 // --------------------------------------------------------------------------- |
|
65 EXPORT_C void CMessageHeader::GetUnreadFlag(TBool& aUnread) const |
|
66 { |
|
67 aUnread = iUnread; |
|
68 } |
|
69 |
|
70 // --------------------------------------------------------------------------- |
|
71 // Gets the unread flag |
|
72 // --------------------------------------------------------------------------- |
|
73 EXPORT_C TBool CMessageHeader::UnreadFlag() const |
|
74 { |
|
75 return ( iUnread ? ETrue : EFalse ); |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // Sets the attachment flag |
|
80 // --------------------------------------------------------------------------- |
|
81 EXPORT_C void CMessageHeader::SetAttachFlag(const TBool aAttachment) |
|
82 { |
|
83 iAttachment = aAttachment; |
|
84 } |
|
85 |
|
86 // --------------------------------------------------------------------------- |
|
87 // Gets the attachment flag |
|
88 // --------------------------------------------------------------------------- |
|
89 EXPORT_C void CMessageHeader::GetAttachFlag(TBool& aAttachment) const |
|
90 { |
|
91 aAttachment = iAttachment ; |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // Gets the attachment flag |
|
96 // --------------------------------------------------------------------------- |
|
97 EXPORT_C TBool CMessageHeader::AttachFlag() const |
|
98 { |
|
99 return ( iAttachment ? ETrue : EFalse ); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Sets the priority flag |
|
104 // --------------------------------------------------------------------------- |
|
105 EXPORT_C void CMessageHeader::SetPriorityFlag(const TMsvPriority aPriority) |
|
106 { |
|
107 iPriority = aPriority; |
|
108 delete iPriAsString; |
|
109 iPriAsString = NULL; |
|
110 |
|
111 switch ( iPriority ) |
|
112 { |
|
113 case EMsvHighPriority: |
|
114 iPriAsString = KPriorityHigh.operator()().Alloc(); |
|
115 break; |
|
116 |
|
117 case EMsvLowPriority: |
|
118 iPriAsString = KPriorityLow.operator()().Alloc(); |
|
119 break; |
|
120 |
|
121 case EMsvMediumPriority: |
|
122 default: |
|
123 iPriAsString = KPriorityMedium.operator()().Alloc(); |
|
124 } |
|
125 } |
|
126 |
|
127 // --------------------------------------------------------------------------- |
|
128 // Gets the priority flag |
|
129 // --------------------------------------------------------------------------- |
|
130 EXPORT_C void CMessageHeader::GetPriorityFlag(TMsvPriority& aPriority) const |
|
131 { |
|
132 aPriority = iPriority; |
|
133 } |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // Gets the priority |
|
137 // --------------------------------------------------------------------------- |
|
138 EXPORT_C TPtrC CMessageHeader::Priority() const |
|
139 { |
|
140 return iPriAsString ? TPtrC( *iPriAsString ) : TPtrC(); |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // Sets the mtm id |
|
145 // --------------------------------------------------------------------------- |
|
146 EXPORT_C void CMessageHeader::SetMtmId(const TUid aMtm) |
|
147 { |
|
148 iMtm = aMtm; |
|
149 |
|
150 if ( iMtmAsString ) |
|
151 delete iMtmAsString; |
|
152 |
|
153 iMtmAsString = NULL; |
|
154 |
|
155 if ( iMtm == KSenduiMtmSmsUid ) |
|
156 { |
|
157 iMtmAsString = KMessageTypeSMS.operator()().Alloc(); |
|
158 } |
|
159 else if ( iMtm == KSenduiMtmMmsUid ) |
|
160 { |
|
161 iMtmAsString = KMessageTypeMMS.operator()().Alloc(); |
|
162 } |
|
163 else |
|
164 { |
|
165 iMtmAsString = KUnknown.operator()().Alloc(); |
|
166 } |
|
167 } |
|
168 |
|
169 // --------------------------------------------------------------------------- |
|
170 // Gets the mtm id |
|
171 // --------------------------------------------------------------------------- |
|
172 EXPORT_C void CMessageHeader::GetMtmId(TUid& aMtm) const |
|
173 { |
|
174 aMtm = iMtm; |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // Gets the mtm |
|
179 // --------------------------------------------------------------------------- |
|
180 EXPORT_C TPtrC CMessageHeader::Mtm() const |
|
181 { |
|
182 return iMtmAsString ? TPtrC( *iMtmAsString ) : TPtrC(); |
|
183 } |
|
184 |
|
185 // --------------------------------------------------------------------------- |
|
186 // Sets the messge id |
|
187 // --------------------------------------------------------------------------- |
|
188 EXPORT_C void CMessageHeader::SetMessageId(const TMsvId aMessageID) |
|
189 { |
|
190 iMessageID = aMessageID; |
|
191 } |
|
192 |
|
193 // --------------------------------------------------------------------------- |
|
194 // Gets the messge id |
|
195 // --------------------------------------------------------------------------- |
|
196 EXPORT_C void CMessageHeader::GetMessageId(TMsvId& aMessageID) const |
|
197 { |
|
198 aMessageID = iMessageID; |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------------------------- |
|
202 // returns the messge id |
|
203 // --------------------------------------------------------------------------- |
|
204 EXPORT_C TMsvId CMessageHeader::MessageId() const |
|
205 { |
|
206 return iMessageID; |
|
207 } |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // Sets the time |
|
211 // --------------------------------------------------------------------------- |
|
212 EXPORT_C void CMessageHeader::SetTime(const TTime& aTime) |
|
213 { |
|
214 TDateTime tmp; |
|
215 tmp = aTime.DateTime(); |
|
216 iTime = tmp; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------------------------- |
|
220 // Gets the time |
|
221 // --------------------------------------------------------------------------- |
|
222 EXPORT_C void CMessageHeader::GetTime(TTime& aTime) const |
|
223 { |
|
224 TDateTime tmp; |
|
225 tmp = iTime.DateTime(); |
|
226 aTime = tmp; |
|
227 } |
|
228 |
|
229 // --------------------------------------------------------------------------- |
|
230 // Gets the time |
|
231 // --------------------------------------------------------------------------- |
|
232 EXPORT_C const TTime& CMessageHeader::Time() const |
|
233 { |
|
234 return iTime; |
|
235 } |
|
236 |
|
237 // --------------------------------------------------------------------------- |
|
238 // Sets the sender address |
|
239 // --------------------------------------------------------------------------- |
|
240 EXPORT_C void CMessageHeader::SetFromL(const TDesC& aFrom) |
|
241 { |
|
242 if( iFrom ) |
|
243 { |
|
244 delete iFrom; |
|
245 iFrom = NULL; |
|
246 } |
|
247 iFrom = aFrom.AllocL(); |
|
248 } |
|
249 |
|
250 // --------------------------------------------------------------------------- |
|
251 // Gets the sender address |
|
252 // --------------------------------------------------------------------------- |
|
253 EXPORT_C const TPtrC CMessageHeader::From() const |
|
254 { |
|
255 return iFrom ? TPtrC( *iFrom ) : TPtrC(); |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // Sets the subject |
|
260 // --------------------------------------------------------------------------- |
|
261 EXPORT_C void CMessageHeader::SetSubjectL(const TDesC& aSubject) |
|
262 { |
|
263 if( iSubject ) |
|
264 { |
|
265 delete iSubject; |
|
266 iSubject = NULL; |
|
267 } |
|
268 iSubject = aSubject.AllocL(); |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------------------------- |
|
272 // Gets the subject |
|
273 // --------------------------------------------------------------------------- |
|
274 EXPORT_C const TPtrC CMessageHeader::Subject() const |
|
275 { |
|
276 return iSubject ? TPtrC( *iSubject ) : TPtrC(); |
|
277 } |
|
278 |
|
279 |
|
280 // --------------------------------------------------------------------------- |
|
281 // Two-phased constructor. |
|
282 // --------------------------------------------------------------------------- |
|
283 EXPORT_C CRecipientList* CRecipientList::CRecipientList::NewL() |
|
284 { |
|
285 CRecipientList* self = new (ELeave) CRecipientList; |
|
286 CleanupStack::PushL(self); |
|
287 self->ConstructL(); |
|
288 CleanupStack::Pop(self); |
|
289 return self; |
|
290 } |
|
291 |
|
292 // --------------------------------------------------------------------------- |
|
293 // Destructor. |
|
294 // --------------------------------------------------------------------------- |
|
295 CRecipientList::~CRecipientList() |
|
296 { |
|
297 if ( iRecipients ) |
|
298 iRecipients->Reset(); |
|
299 |
|
300 delete iRecipients; |
|
301 iRecipientType.Close(); |
|
302 } |
|
303 |
|
304 // --------------------------------------------------------------------------- |
|
305 // Constructor |
|
306 // --------------------------------------------------------------------------- |
|
307 CRecipientList::CRecipientList() |
|
308 { |
|
309 } |
|
310 |
|
311 // --------------------------------------------------------------------------- |
|
312 // SYmbian Constructor |
|
313 // --------------------------------------------------------------------------- |
|
314 void CRecipientList::ConstructL() |
|
315 { |
|
316 iRecipients = new (ELeave) CDesCArrayFlat(KArrayGranularity); |
|
317 } |
|
318 |
|
319 // --------------------------------------------------------------------------- |
|
320 // Appends the recipient type |
|
321 // --------------------------------------------------------------------------- |
|
322 EXPORT_C void CRecipientList::AppendL(TMsvRecipientType aValue, const TDesC& aPtr) |
|
323 { |
|
324 iRecipientType.AppendL(aValue); |
|
325 TRAPD(err, iRecipients->AppendL(aPtr)); |
|
326 if (err != KErrNone) |
|
327 { |
|
328 iRecipientType.Remove(iRecipientType.Count() - 1); |
|
329 User::Leave(err); |
|
330 } |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // Gives the number of recipients |
|
335 // --------------------------------------------------------------------------- |
|
336 EXPORT_C TInt CRecipientList::Count() const |
|
337 { |
|
338 return iRecipients->Count(); |
|
339 } |
|
340 |
|
341 // --------------------------------------------------------------------------- |
|
342 // Gives the recipient type |
|
343 // --------------------------------------------------------------------------- |
|
344 EXPORT_C TMsvRecipientType CRecipientList::Type(TInt aPos) const |
|
345 { |
|
346 return iRecipientType[aPos]; |
|
347 } |
|
348 |
|
349 // --------------------------------------------------------------------------- |
|
350 // Gives recipient address |
|
351 // --------------------------------------------------------------------------- |
|
352 EXPORT_C const TDesC& CRecipientList::operator[](TInt aIndex) const |
|
353 { |
|
354 HBufC16* temp=(*(HBufC16**)iRecipients->At(aIndex)); |
|
355 return *temp; |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // Resets the recipient list |
|
360 // --------------------------------------------------------------------------- |
|
361 EXPORT_C void CRecipientList::Reset() |
|
362 { |
|
363 iRecipients->Reset(); |
|
364 iRecipientType.Reset(); |
|
365 } |
|
366 |
|
367 |
|
368 // --------------------------------------------------------------------------- |
|
369 // Two Phase Constructor |
|
370 // --------------------------------------------------------------------------- |
|
371 EXPORT_C CFilterParamInfo* CFilterParamInfo::NewL() |
|
372 { |
|
373 return new(ELeave) CFilterParamInfo; |
|
374 } |
|
375 |
|
376 // --------------------------------------------------------------------------- |
|
377 // Destructor |
|
378 // --------------------------------------------------------------------------- |
|
379 CFilterParamInfo::~CFilterParamInfo() |
|
380 { |
|
381 Reset(); |
|
382 } |
|
383 |
|
384 // --------------------------------------------------------------------------- |
|
385 // Constructor |
|
386 // --------------------------------------------------------------------------- |
|
387 CFilterParamInfo::CFilterParamInfo() |
|
388 { |
|
389 |
|
390 } |
|
391 |
|
392 // --------------------------------------------------------------------------- |
|
393 // Sets the sender address as a filter |
|
394 // --------------------------------------------------------------------------- |
|
395 EXPORT_C void CFilterParamInfo::AddFromL( const TDesC& aFrom ) |
|
396 { |
|
397 if( !iFromArray ) |
|
398 { |
|
399 iFromArray = new (ELeave) CDesCArraySeg( KArrayGranularity ); |
|
400 } |
|
401 |
|
402 if ( aFrom.Length() ) |
|
403 { |
|
404 iFromArray->AppendL( aFrom ); |
|
405 iFilter |= EFilterFrom; |
|
406 } |
|
407 } |
|
408 |
|
409 // --------------------------------------------------------------------------- |
|
410 // Gets the sender address as a filter |
|
411 // --------------------------------------------------------------------------- |
|
412 EXPORT_C const CDesCArray* CFilterParamInfo::From() const |
|
413 { |
|
414 return iFromArray; |
|
415 } |
|
416 |
|
417 |
|
418 // --------------------------------------------------------------------------- |
|
419 // Sets the mtm as a filter |
|
420 // --------------------------------------------------------------------------- |
|
421 EXPORT_C TInt CFilterParamInfo::AddMtmL( const TDesC& aMtm ) |
|
422 { |
|
423 if ( aMtm.CompareF( KMessageTypeSMS ) == 0 || aMtm.CompareF( KMessageTypeMMS ) == 0 ) |
|
424 { |
|
425 } |
|
426 else |
|
427 { |
|
428 return KErrNotSupported; |
|
429 } |
|
430 |
|
431 if( !iMtmArray ) |
|
432 { |
|
433 iMtmArray = new (ELeave) CDesCArraySeg( KArrayGranularity ); |
|
434 } |
|
435 |
|
436 if ( aMtm.Length() ) |
|
437 { |
|
438 iMtmArray->AppendL( aMtm ); |
|
439 iFilter |= EFilterMtm; |
|
440 } |
|
441 return KErrNone; |
|
442 } |
|
443 |
|
444 // --------------------------------------------------------------------------- |
|
445 // Gets the mtm array |
|
446 // --------------------------------------------------------------------------- |
|
447 EXPORT_C const CDesCArray* CFilterParamInfo::Mtm() const |
|
448 { |
|
449 return iMtmArray; |
|
450 } |
|
451 |
|
452 // --------------------------------------------------------------------------- |
|
453 // Sets subject filter |
|
454 // --------------------------------------------------------------------------- |
|
455 EXPORT_C void CFilterParamInfo::SetSubjectL( const TDesC& aSubject ) |
|
456 { |
|
457 if ( iSubject ) |
|
458 { |
|
459 delete iSubject; |
|
460 iSubject = NULL; |
|
461 iFilter ^= ( iFilter & EFilterSubject ); |
|
462 } |
|
463 |
|
464 if ( aSubject.Length() ) |
|
465 { |
|
466 iSubject = HBufC::NewL( aSubject.Length() ); |
|
467 iSubject->Des().Copy( aSubject ); |
|
468 iFilter |= EFilterSubject; |
|
469 } |
|
470 } |
|
471 |
|
472 // --------------------------------------------------------------------------- |
|
473 // Gets the filter for subject of message |
|
474 // --------------------------------------------------------------------------- |
|
475 EXPORT_C TPtrC CFilterParamInfo::Subject() const |
|
476 { |
|
477 return iSubject ? TPtrC( *iSubject ) : TPtrC(); |
|
478 } |
|
479 |
|
480 // --------------------------------------------------------------------------- |
|
481 // Sets the sorting order |
|
482 // --------------------------------------------------------------------------- |
|
483 EXPORT_C void CFilterParamInfo::SetSortType( const TMsvSorting aSortType ) |
|
484 { |
|
485 iSortType = aSortType; |
|
486 } |
|
487 |
|
488 |
|
489 // --------------------------------------------------------------------------- |
|
490 // Gets the sorting order |
|
491 // --------------------------------------------------------------------------- |
|
492 EXPORT_C TMsvSorting CFilterParamInfo::SortType() const |
|
493 { |
|
494 return iSortType; |
|
495 } |
|
496 |
|
497 |
|
498 // --------------------------------------------------------------------------- |
|
499 // Sets the message id as filter |
|
500 // --------------------------------------------------------------------------- |
|
501 EXPORT_C void CFilterParamInfo::SetMessageIdFilter( const TMsvId aMessageId ) |
|
502 { |
|
503 iFilter ^= ( iFilter & EFilterId ); |
|
504 |
|
505 if( aMessageId != 0) |
|
506 { |
|
507 iMessageId = aMessageId; |
|
508 iFilter |= EFilterId; |
|
509 } |
|
510 } |
|
511 |
|
512 // --------------------------------------------------------------------------- |
|
513 // Gets the message id as filter |
|
514 // --------------------------------------------------------------------------- |
|
515 EXPORT_C TMsvId CFilterParamInfo::MessageId() const |
|
516 { |
|
517 return iMessageId; |
|
518 } |
|
519 |
|
520 |
|
521 // --------------------------------------------------------------------------- |
|
522 // Sets the starting date for date range as a filter |
|
523 // --------------------------------------------------------------------------- |
|
524 EXPORT_C void CFilterParamInfo::SetStartDateFilter( const TTime& aStartDate ) |
|
525 { |
|
526 iFilter ^= ( iFilter & EFilterStartDate ); |
|
527 |
|
528 |
|
529 if ( aStartDate.Int64() > 0 ) |
|
530 { |
|
531 iStartDate = aStartDate; |
|
532 iFilter |= EFilterStartDate; |
|
533 } |
|
534 } |
|
535 |
|
536 |
|
537 // --------------------------------------------------------------------------- |
|
538 // Gets the starting date for date range as a filter |
|
539 // --------------------------------------------------------------------------- |
|
540 EXPORT_C const TTime& CFilterParamInfo::StartDate() const |
|
541 { |
|
542 return iStartDate; |
|
543 } |
|
544 |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // Sets the ending date for date range as a filter |
|
548 // --------------------------------------------------------------------------- |
|
549 EXPORT_C void CFilterParamInfo::SetEndDate( const TTime& aEndDate ) |
|
550 { |
|
551 iFilter ^= ( iFilter & EFilterEndDate ); |
|
552 |
|
553 if ( aEndDate.Int64() > 0 ) |
|
554 { |
|
555 iEndDate = aEndDate; |
|
556 iFilter |= EFilterEndDate; |
|
557 } |
|
558 } |
|
559 |
|
560 |
|
561 // --------------------------------------------------------------------------- |
|
562 // Gets the ending date for date range as a filter |
|
563 // --------------------------------------------------------------------------- |
|
564 EXPORT_C const TTime& CFilterParamInfo::EndDate() const |
|
565 { |
|
566 return iEndDate; |
|
567 } |
|
568 |
|
569 // --------------------------------------------------------------------------- |
|
570 // Gives the iFilter |
|
571 // --------------------------------------------------------------------------- |
|
572 EXPORT_C TInt CFilterParamInfo::Filter() const |
|
573 { |
|
574 return iFilter; |
|
575 } |
|
576 |
|
577 |
|
578 // --------------------------------------------------------------------------- |
|
579 // Resets the filterinfo object |
|
580 // --------------------------------------------------------------------------- |
|
581 EXPORT_C void CFilterParamInfo::Reset() |
|
582 { |
|
583 if ( iFromArray ) |
|
584 { |
|
585 iFromArray->Reset(); |
|
586 } |
|
587 |
|
588 if ( iMtmArray ) |
|
589 { |
|
590 iMtmArray->Reset(); |
|
591 } |
|
592 |
|
593 delete iFromArray; |
|
594 iFromArray = NULL; |
|
595 delete iMtmArray; |
|
596 iMtmArray = NULL; |
|
597 delete iSubject; |
|
598 iSubject = NULL; |
|
599 iFilter = 0; |
|
600 } |
|
601 |
|
602 CFilterParamInfo& CFilterParamInfo::operator=( const CFilterParamInfo& aFilterParamInfo ) |
|
603 { |
|
604 if ( iFromArray ) |
|
605 { |
|
606 iFromArray->Reset(); |
|
607 delete iFromArray; |
|
608 iFromArray = NULL; |
|
609 } |
|
610 |
|
611 if ( aFilterParamInfo.iFromArray ) |
|
612 { |
|
613 TInt count = aFilterParamInfo.iFromArray->Count(); |
|
614 for( TInt index = 0; index < count; index++ ) |
|
615 { |
|
616 AddFromL((*(aFilterParamInfo.iFromArray))[index]); |
|
617 } |
|
618 } |
|
619 |
|
620 if ( iMtmArray ) |
|
621 { |
|
622 iMtmArray->Reset(); |
|
623 delete iMtmArray; |
|
624 iMtmArray = NULL; |
|
625 } |
|
626 |
|
627 if ( aFilterParamInfo.iMtmArray ) |
|
628 { |
|
629 TInt count = aFilterParamInfo.iMtmArray->Count(); |
|
630 for( TInt index = 0; index < count; index++ ) |
|
631 { |
|
632 AddMtmL((*(aFilterParamInfo.iMtmArray))[index]); |
|
633 } |
|
634 } |
|
635 |
|
636 delete iSubject; |
|
637 iSubject = NULL; |
|
638 if( aFilterParamInfo.iSubject ) |
|
639 { |
|
640 iSubject = aFilterParamInfo.Subject().AllocL(); |
|
641 } |
|
642 |
|
643 iSortType = aFilterParamInfo.iSortType; |
|
644 |
|
645 iMessageId = aFilterParamInfo.iMessageId; |
|
646 |
|
647 iStartDate = aFilterParamInfo.iStartDate; |
|
648 |
|
649 iEndDate = aFilterParamInfo.iEndDate; |
|
650 |
|
651 iFilter = aFilterParamInfo.iFilter; |
|
652 |
|
653 return *this; |
|
654 } |
|
655 |
|
656 |
|
657 |
|
658 // --------------------------------------------------------------------------- |
|
659 // Two Phase constructor |
|
660 // --------------------------------------------------------------------------- |
|
661 EXPORT_C CSendMessageParams* CSendMessageParams::NewL() |
|
662 { |
|
663 return new(ELeave) CSendMessageParams; |
|
664 } |
|
665 |
|
666 |
|
667 // --------------------------------------------------------------------------- |
|
668 // Destructor |
|
669 // --------------------------------------------------------------------------- |
|
670 CSendMessageParams::~CSendMessageParams() |
|
671 { |
|
672 if ( iRecipientArray ) |
|
673 { |
|
674 iRecipientArray->Reset(); |
|
675 } |
|
676 |
|
677 if ( iAttachmentArray ) |
|
678 { |
|
679 iAttachmentArray->ResetAndDestroy(); |
|
680 } |
|
681 |
|
682 delete iRecipientArray; |
|
683 delete iAttachmentArray; |
|
684 delete iSubject; |
|
685 delete iBodyText; |
|
686 } |
|
687 |
|
688 // --------------------------------------------------------------------------- |
|
689 // Constructor |
|
690 // --------------------------------------------------------------------------- |
|
691 CSendMessageParams::CSendMessageParams() |
|
692 { |
|
693 } |
|
694 |
|
695 |
|
696 // --------------------------------------------------------------------------- |
|
697 // Adds Recipient |
|
698 // --------------------------------------------------------------------------- |
|
699 EXPORT_C void CSendMessageParams::AddRecipientL( const TDesC& aRecipient, TMsvRecipientType aType ) |
|
700 { |
|
701 if ( !iRecipientArray ) |
|
702 { |
|
703 iRecipientArray = CRecipientList::NewL(); |
|
704 } |
|
705 |
|
706 if ( aRecipient.Length() ) |
|
707 { |
|
708 iRecipientArray->AppendL( aType, aRecipient ); |
|
709 } |
|
710 } |
|
711 |
|
712 // --------------------------------------------------------------------------- |
|
713 // Gets the Recipient arrary |
|
714 // --------------------------------------------------------------------------- |
|
715 EXPORT_C const CRecipientList* CSendMessageParams::RecipientArray() const |
|
716 { |
|
717 return iRecipientArray; |
|
718 } |
|
719 |
|
720 |
|
721 // --------------------------------------------------------------------------- |
|
722 // Adds attachment |
|
723 // --------------------------------------------------------------------------- |
|
724 EXPORT_C void CSendMessageParams::AddAttachmentL( CMsvAttachment* aAttachment ) |
|
725 { |
|
726 if ( !iAttachmentArray ) |
|
727 { |
|
728 iAttachmentArray = new (ELeave) CArrayPtrSeg<CMsvAttachment>( KArrayGranularity ); |
|
729 } |
|
730 |
|
731 if ( aAttachment ) |
|
732 { |
|
733 iAttachmentArray->AppendL( aAttachment ); |
|
734 } |
|
735 } |
|
736 |
|
737 // --------------------------------------------------------------------------- |
|
738 // Gets the array of attachment information |
|
739 // --------------------------------------------------------------------------- |
|
740 EXPORT_C const CArrayPtr<CMsvAttachment>* CSendMessageParams::AttachmentArray() |
|
741 { |
|
742 return iAttachmentArray; |
|
743 } |
|
744 |
|
745 // --------------------------------------------------------------------------- |
|
746 // Sets the subject for message |
|
747 // --------------------------------------------------------------------------- |
|
748 EXPORT_C void CSendMessageParams::SetSubjectL( const TDesC& aSubject ) |
|
749 { |
|
750 if ( iSubject ) |
|
751 { |
|
752 delete iSubject; |
|
753 iSubject = NULL; |
|
754 } |
|
755 |
|
756 if ( aSubject.Length() ) |
|
757 { |
|
758 iSubject = HBufC::NewL( aSubject.Length() ); |
|
759 iSubject->Des().Copy( aSubject ); |
|
760 } |
|
761 } |
|
762 |
|
763 // --------------------------------------------------------------------------- |
|
764 // Gets the subject for message |
|
765 // --------------------------------------------------------------------------- |
|
766 EXPORT_C const TPtrC CSendMessageParams::Subject() const |
|
767 { |
|
768 return iSubject ? TPtrC( *iSubject ) : TPtrC(); |
|
769 } |
|
770 |
|
771 |
|
772 // --------------------------------------------------------------------------- |
|
773 // Sets the body for message |
|
774 // --------------------------------------------------------------------------- |
|
775 EXPORT_C void CSendMessageParams::SetBodyTextL( const TDesC& aMsg ) |
|
776 { |
|
777 if ( iBodyText ) |
|
778 { |
|
779 delete iBodyText; |
|
780 iBodyText = NULL; |
|
781 } |
|
782 |
|
783 if ( aMsg.Length() ) |
|
784 { |
|
785 iBodyText = HBufC::NewL( aMsg.Length() ); |
|
786 iBodyText->Des().Copy( aMsg ); |
|
787 } |
|
788 } |
|
789 |
|
790 // --------------------------------------------------------------------------- |
|
791 // Appends the message to existing bodytext |
|
792 // --------------------------------------------------------------------------- |
|
793 void CSendMessageParams::AppendBodyTextL( const TDesC& aMsg ) |
|
794 { |
|
795 if ( aMsg.Length() ) |
|
796 { |
|
797 HBufC* tmpMsgBody = HBufC::NewL( aMsg.Length() + BodyText().Length() ); |
|
798 CleanupStack::PushL( tmpMsgBody ); |
|
799 tmpMsgBody->Des().Copy( BodyText() ); |
|
800 tmpMsgBody->Des().Append( aMsg ); |
|
801 delete iBodyText; |
|
802 iBodyText = tmpMsgBody; |
|
803 CleanupStack::Pop( tmpMsgBody ); |
|
804 } |
|
805 } |
|
806 |
|
807 // --------------------------------------------------------------------------- |
|
808 // Gets the body for message |
|
809 // --------------------------------------------------------------------------- |
|
810 EXPORT_C const TPtrC CSendMessageParams::BodyText() const |
|
811 { |
|
812 return iBodyText ? TPtrC( *iBodyText ) : TPtrC(); |
|
813 } |
|
814 |
|
815 // --------------------------------------------------------------------------- |
|
816 // Sets the templateid |
|
817 // --------------------------------------------------------------------------- |
|
818 EXPORT_C void CSendMessageParams::SetTemplateId( const TMsvId aTemplateId ) |
|
819 { |
|
820 iTemplateId = aTemplateId; |
|
821 } |
|
822 |
|
823 // --------------------------------------------------------------------------- |
|
824 // Gets the templateid |
|
825 // --------------------------------------------------------------------------- |
|
826 EXPORT_C TMsvId CSendMessageParams::TemplateId() const |
|
827 { |
|
828 return iTemplateId; |
|
829 } |
|
830 |
|
831 // --------------------------------------------------------------------------- |
|
832 // Sets paramter to launch editor depends on argument value |
|
833 // --------------------------------------------------------------------------- |
|
834 EXPORT_C void CSendMessageParams::SetLaunchEditor( const TBool aLaunchEditor ) |
|
835 { |
|
836 iLaunchEditor = aLaunchEditor; |
|
837 } |
|
838 |
|
839 // --------------------------------------------------------------------------- |
|
840 // Gets the LaunchEditor value |
|
841 // --------------------------------------------------------------------------- |
|
842 EXPORT_C TBool CSendMessageParams::LaunchEditor() const |
|
843 { |
|
844 return iLaunchEditor; |
|
845 } |
|
846 |
|
847 // --------------------------------------------------------------------------- |
|
848 // Sets the message type |
|
849 // --------------------------------------------------------------------------- |
|
850 EXPORT_C TInt CSendMessageParams::SetMessageTypeL( const TDesC& aMessageType ) |
|
851 { |
|
852 if ( aMessageType.CompareF( KMessageTypeSMS ) == 0 ) |
|
853 { |
|
854 iMessageType = KSenduiMtmSmsUid; |
|
855 } |
|
856 else if ( aMessageType.CompareF( KMessageTypeMMS ) == 0 ) |
|
857 { |
|
858 iMessageType = KSenduiMtmMmsUid; |
|
859 } |
|
860 else |
|
861 { |
|
862 return KErrNotSupported; |
|
863 } |
|
864 return KErrNone; |
|
865 } |
|
866 |
|
867 // --------------------------------------------------------------------------- |
|
868 // Gets the message type |
|
869 // --------------------------------------------------------------------------- |
|
870 EXPORT_C TUid CSendMessageParams::MessageType() const |
|
871 { |
|
872 return iMessageType; |
|
873 } |
|
874 |
|
875 CSendMessageParams& CSendMessageParams::operator=(const CSendMessageParams& aSendMessageParams ) |
|
876 { |
|
877 iMessageType = aSendMessageParams.iMessageType; |
|
878 |
|
879 iTemplateId = aSendMessageParams.iTemplateId; |
|
880 |
|
881 iLaunchEditor = aSendMessageParams.iLaunchEditor; |
|
882 |
|
883 delete iSubject; |
|
884 iSubject = NULL; |
|
885 if( aSendMessageParams.iSubject ) |
|
886 { |
|
887 iSubject = aSendMessageParams.Subject().AllocL(); |
|
888 } |
|
889 |
|
890 delete iBodyText; |
|
891 iBodyText = NULL; |
|
892 if( aSendMessageParams.iBodyText ) |
|
893 { |
|
894 iBodyText = aSendMessageParams.BodyText().AllocL(); |
|
895 } |
|
896 |
|
897 if ( iRecipientArray ) |
|
898 { |
|
899 iRecipientArray->Reset(); |
|
900 delete iRecipientArray; |
|
901 iRecipientArray = NULL; |
|
902 } |
|
903 |
|
904 if( aSendMessageParams.iRecipientArray ) |
|
905 { |
|
906 TInt count = aSendMessageParams.iRecipientArray->Count(); |
|
907 for(TInt index = 0; index < count; index++) |
|
908 { |
|
909 AddRecipientL( (*(aSendMessageParams.iRecipientArray))[index], |
|
910 aSendMessageParams.iRecipientArray->Type(index) ); |
|
911 } |
|
912 } |
|
913 |
|
914 if ( iAttachmentArray ) |
|
915 { |
|
916 iAttachmentArray->ResetAndDestroy(); |
|
917 delete iAttachmentArray; |
|
918 iAttachmentArray = NULL; |
|
919 } |
|
920 |
|
921 if ( aSendMessageParams.iAttachmentArray ) |
|
922 { |
|
923 TInt count = aSendMessageParams.iAttachmentArray->Count(); |
|
924 for(TInt index = 0; index < count; index++) |
|
925 { |
|
926 CMsvAttachment* element = aSendMessageParams.iAttachmentArray->At( index ); |
|
927 CMsvAttachment* newElement = CMsvAttachment::NewL( *element ); |
|
928 CleanupStack::PushL( newElement ); |
|
929 AddAttachmentL( newElement ); |
|
930 CleanupStack::Pop( newElement ); |
|
931 } |
|
932 } |
|
933 |
|
934 return *this; |
|
935 } |
|
936 |
|
937 /** |
|
938 * Two Phase Constructor |
|
939 */ |
|
940 EXPORT_C CMessageAttachInfo* CMessageAttachInfo::NewL() |
|
941 { |
|
942 return new(ELeave) CMessageAttachInfo; |
|
943 } |
|
944 |
|
945 /** |
|
946 * Constructor |
|
947 */ |
|
948 CMessageAttachInfo::CMessageAttachInfo() |
|
949 { |
|
950 } |
|
951 |
|
952 /** |
|
953 * Destructor |
|
954 */ |
|
955 CMessageAttachInfo::~CMessageAttachInfo() |
|
956 { |
|
957 delete iName; |
|
958 delete iMimeType; |
|
959 } |
|
960 |
|
961 /** |
|
962 * Sets the Attachment Name |
|
963 * @param aName Attachment Name |
|
964 * @return void |
|
965 */ |
|
966 EXPORT_C void CMessageAttachInfo::SetNameL(const TDesC& aName) |
|
967 { |
|
968 if( iName ) |
|
969 { |
|
970 delete iName; |
|
971 iName = NULL; |
|
972 } |
|
973 iName = aName.AllocL(); |
|
974 } |
|
975 |
|
976 /** |
|
977 * Gets the Attachment Name |
|
978 * @return TPtrC Attachment Name |
|
979 */ |
|
980 EXPORT_C const TPtrC CMessageAttachInfo::Name() const |
|
981 { |
|
982 return iName ? TPtrC( *iName ) : TPtrC(); |
|
983 } |
|
984 |
|
985 /** |
|
986 * Sets the File handle |
|
987 * @param aFile File handle |
|
988 * @return void |
|
989 */ |
|
990 EXPORT_C void CMessageAttachInfo::SetFileHandle( RFile aFile) |
|
991 { |
|
992 iFile = aFile; |
|
993 } |
|
994 |
|
995 /** |
|
996 * Gets the File handle |
|
997 * @return RFile File handle |
|
998 */ |
|
999 EXPORT_C RFile CMessageAttachInfo::FileHandle() const |
|
1000 { |
|
1001 return iFile; |
|
1002 } |
|
1003 |
|
1004 /** |
|
1005 * Sets the File size |
|
1006 * @param aSize File size |
|
1007 * @return void |
|
1008 */ |
|
1009 EXPORT_C void CMessageAttachInfo::SetSize( TInt32 aSize) |
|
1010 { |
|
1011 iSize = aSize; |
|
1012 } |
|
1013 |
|
1014 /** |
|
1015 * Gets the File size |
|
1016 * @return File size |
|
1017 */ |
|
1018 EXPORT_C TInt32 CMessageAttachInfo::Size() const |
|
1019 { |
|
1020 return iSize; |
|
1021 } |
|
1022 |
|
1023 /** |
|
1024 * Sets the Mime type |
|
1025 * @param aMimeType Mime type |
|
1026 * @return void |
|
1027 */ |
|
1028 EXPORT_C void CMessageAttachInfo::SetMimeTypeL(const TDesC& aMimeType) |
|
1029 { |
|
1030 if( iMimeType ) |
|
1031 { |
|
1032 delete iMimeType; |
|
1033 iMimeType = NULL; |
|
1034 } |
|
1035 iMimeType = aMimeType.AllocL(); |
|
1036 } |
|
1037 |
|
1038 /** |
|
1039 * Gets the Mime type |
|
1040 * @return TPtrC Mime type |
|
1041 */ |
|
1042 EXPORT_C const TPtrC CMessageAttachInfo::MimeType() const |
|
1043 { |
|
1044 return iMimeType ? TPtrC( *iMimeType ) : TPtrC(); |
|
1045 } |
|
1046 |
|
1047 |
|
1048 |
|
1049 /** |
|
1050 * Two Phase Constructor |
|
1051 */ |
|
1052 EXPORT_C CMessageDetailInfo* CMessageDetailInfo::NewL() |
|
1053 { |
|
1054 return new(ELeave) CMessageDetailInfo; |
|
1055 } |
|
1056 |
|
1057 /** |
|
1058 * Constructor |
|
1059 */ |
|
1060 CMessageDetailInfo::CMessageDetailInfo() |
|
1061 { |
|
1062 } |
|
1063 |
|
1064 /** |
|
1065 * Destructor |
|
1066 */ |
|
1067 CMessageDetailInfo::~CMessageDetailInfo() |
|
1068 { |
|
1069 if ( iRecipientList ) |
|
1070 iRecipientList->Reset(); |
|
1071 |
|
1072 if ( iAttachEntries ) |
|
1073 iAttachEntries->ResetAndDestroy(); |
|
1074 |
|
1075 delete iBodyText; |
|
1076 delete iFrom; |
|
1077 delete iRecipientList; |
|
1078 delete iAttachEntries; |
|
1079 } |
|
1080 |
|
1081 /** |
|
1082 * Adds Recipient |
|
1083 * @param aRecipient recipient address |
|
1084 * @param aType recipient type |
|
1085 */ |
|
1086 EXPORT_C void CMessageDetailInfo::AddRecipientL( const TDesC& aRecipient, TMsvRecipientType aType ) |
|
1087 { |
|
1088 if ( !iRecipientList ) |
|
1089 { |
|
1090 iRecipientList = CRecipientList::NewL(); |
|
1091 } |
|
1092 |
|
1093 if ( aRecipient.Length() ) |
|
1094 { |
|
1095 iRecipientList->AppendL( aType, aRecipient ); |
|
1096 } |
|
1097 } |
|
1098 |
|
1099 /** |
|
1100 * Gives the receipient array |
|
1101 * @return CRecipientList* |
|
1102 */ |
|
1103 EXPORT_C const CRecipientList* CMessageDetailInfo::RecipientArray() const |
|
1104 { |
|
1105 return iRecipientList; |
|
1106 } |
|
1107 |
|
1108 /** |
|
1109 * Sets the sender address |
|
1110 * @param aFrom Sender address |
|
1111 * @return void |
|
1112 */ |
|
1113 EXPORT_C void CMessageDetailInfo::SetFromL(const TDesC& aFrom) |
|
1114 { |
|
1115 if( iFrom ) |
|
1116 { |
|
1117 delete iFrom; |
|
1118 iFrom = NULL; |
|
1119 } |
|
1120 |
|
1121 iFrom = aFrom.AllocL(); |
|
1122 } |
|
1123 |
|
1124 /** |
|
1125 * Gets the sender address |
|
1126 * @return TPtrC Sender address |
|
1127 */ |
|
1128 EXPORT_C const TPtrC CMessageDetailInfo::From() const |
|
1129 { |
|
1130 return iFrom ? TPtrC( *iFrom ) : TPtrC(); |
|
1131 } |
|
1132 |
|
1133 /** |
|
1134 * Sets the body for message |
|
1135 * @param aMsg Body for message |
|
1136 */ |
|
1137 EXPORT_C void CMessageDetailInfo::SetBodyTextL( const TDesC& aMsg ) |
|
1138 { |
|
1139 if( iBodyText ) |
|
1140 { |
|
1141 delete iBodyText; |
|
1142 iBodyText = NULL; |
|
1143 } |
|
1144 |
|
1145 iBodyText = aMsg.AllocL(); |
|
1146 } |
|
1147 |
|
1148 /** |
|
1149 * Gets the body text |
|
1150 * @return TPtrC |
|
1151 */ |
|
1152 EXPORT_C const TPtrC CMessageDetailInfo::BodyText() const |
|
1153 { |
|
1154 return iBodyText ? TPtrC( *iBodyText ) : TPtrC(); |
|
1155 } |
|
1156 |
|
1157 /** |
|
1158 * Sets the message id |
|
1159 * @param aMessageID Message ID |
|
1160 * @return void |
|
1161 */ |
|
1162 EXPORT_C void CMessageDetailInfo::SetMessageId(const TMsvId aMessageId) |
|
1163 { |
|
1164 iMessageId = aMessageId; |
|
1165 } |
|
1166 |
|
1167 /** |
|
1168 * Gets the message id |
|
1169 * @return TMsvId Message ID |
|
1170 */ |
|
1171 EXPORT_C TMsvId CMessageDetailInfo::MessageId() const |
|
1172 { |
|
1173 return iMessageId; |
|
1174 } |
|
1175 |
|
1176 /** |
|
1177 * Adds attachment |
|
1178 * @param aAttachment attachment information |
|
1179 */ |
|
1180 EXPORT_C void CMessageDetailInfo::AddAttachmentInfoL( CMessageAttachInfo* aAttachment ) |
|
1181 { |
|
1182 if ( !iAttachEntries ) |
|
1183 { |
|
1184 iAttachEntries = new (ELeave) CArrayPtrSeg<CMessageAttachInfo>( KArrayGranularity ); |
|
1185 } |
|
1186 |
|
1187 if ( aAttachment ) |
|
1188 { |
|
1189 iAttachEntries->AppendL( aAttachment ); |
|
1190 } |
|
1191 } |
|
1192 |
|
1193 /** |
|
1194 * Gives the attachment array |
|
1195 * @return CArrayPtr<CMsvAttachment>* |
|
1196 */ |
|
1197 EXPORT_C const CArrayPtr<CMessageAttachInfo>* CMessageDetailInfo::AttachmentInfoArray() |
|
1198 { |
|
1199 return iAttachEntries; |
|
1200 } |
|
1201 |