|
1 // Copyright (c) 2004-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 "csendastestmessage.h" |
|
17 |
|
18 #include <msvstore.h> |
|
19 |
|
20 #include "csendastestaddress.h" |
|
21 |
|
22 const TUid KUidSendAsTestMessageStream = {0x10204289}; |
|
23 const TInt KSendAsTestMessageVersion = 1; |
|
24 |
|
25 EXPORT_C CSendAsTestMessage* CSendAsTestMessage::NewL() |
|
26 { |
|
27 CSendAsTestMessage* self = new (ELeave) CSendAsTestMessage(); |
|
28 CleanupStack::PushL(self); |
|
29 self->ConstructL(); |
|
30 CleanupStack::Pop(self); |
|
31 return self; |
|
32 } |
|
33 |
|
34 EXPORT_C CSendAsTestMessage::~CSendAsTestMessage() |
|
35 { |
|
36 iAddresses.ResetAndDestroy(); |
|
37 delete iSubject; |
|
38 } |
|
39 |
|
40 CSendAsTestMessage::CSendAsTestMessage() |
|
41 : CBase() |
|
42 { |
|
43 } |
|
44 |
|
45 void CSendAsTestMessage::ConstructL() |
|
46 { |
|
47 } |
|
48 |
|
49 EXPORT_C const RPointerArray<CSendAsTestAddress>& CSendAsTestMessage::Addresses() const |
|
50 { |
|
51 return iAddresses; |
|
52 } |
|
53 |
|
54 EXPORT_C RPointerArray<CSendAsTestAddress>& CSendAsTestMessage::Addresses() |
|
55 { |
|
56 return iAddresses; |
|
57 } |
|
58 |
|
59 EXPORT_C void CSendAsTestMessage::SetSubjectL(const TDesC& aSubject) |
|
60 { |
|
61 HBufC* temp = aSubject.AllocL(); |
|
62 delete iSubject; |
|
63 iSubject = temp; |
|
64 } |
|
65 |
|
66 EXPORT_C const TDesC& CSendAsTestMessage::Subject() const |
|
67 { |
|
68 return iSubject == NULL ? KNullDesC() : *iSubject; |
|
69 } |
|
70 |
|
71 EXPORT_C void CSendAsTestMessage::SetBioTypeL(const TUid aBioType) |
|
72 { |
|
73 iBioType = aBioType; |
|
74 } |
|
75 |
|
76 EXPORT_C TUid CSendAsTestMessage::BioType() const |
|
77 { |
|
78 return iBioType; |
|
79 } |
|
80 |
|
81 EXPORT_C void CSendAsTestMessage::RestoreL(CMsvStore& aStore) |
|
82 { |
|
83 RMsvReadStream in; |
|
84 in.OpenLC(aStore, KUidSendAsTestMessageStream); |
|
85 InternalizeL(in); |
|
86 CleanupStack::PopAndDestroy(&in); |
|
87 } |
|
88 |
|
89 EXPORT_C void CSendAsTestMessage::StoreL(CMsvStore& aStore) const |
|
90 { |
|
91 RMsvWriteStream out; |
|
92 out.AssignLC(aStore, KUidSendAsTestMessageStream); |
|
93 ExternalizeL(out); |
|
94 out.CommitL(); |
|
95 CleanupStack::PopAndDestroy(&out); |
|
96 } |
|
97 |
|
98 void CSendAsTestMessage::InternalizeL(RReadStream& aStream) |
|
99 { |
|
100 aStream.ReadInt16L(); //version. Not used yet |
|
101 |
|
102 iAddresses.ResetAndDestroy(); |
|
103 TInt count = aStream.ReadInt32L(); |
|
104 while(count--) |
|
105 { |
|
106 CSendAsTestAddress* addressee = CSendAsTestAddress::NewL(); |
|
107 CleanupStack::PushL(addressee); |
|
108 addressee->InternalizeL(aStream); |
|
109 iAddresses.AppendL(addressee); |
|
110 CleanupStack::Pop(addressee); |
|
111 } |
|
112 HBufC* subject = HBufC::NewL(aStream, KMaxTInt); |
|
113 delete iSubject; |
|
114 iSubject = subject; |
|
115 aStream >> iBioType; |
|
116 } |
|
117 |
|
118 void CSendAsTestMessage::ExternalizeL(RWriteStream& aStream) const |
|
119 { |
|
120 aStream.WriteInt16L(KSendAsTestMessageVersion); |
|
121 |
|
122 TInt count = iAddresses.Count(); |
|
123 aStream.WriteInt32L(count); |
|
124 |
|
125 for (TInt i=0; i<count; ++i) |
|
126 iAddresses[i]->ExternalizeL(aStream); |
|
127 |
|
128 aStream << Subject(); |
|
129 aStream << iBioType; |
|
130 } |