|
1 /* |
|
2 * Copyright (c) 2002 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 "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: SAN message history entry |
|
15 * |
|
16 */ |
|
17 |
|
18 #include <SyncMLHistory.h> |
|
19 #include <SyncMLAlertInfo.h> |
|
20 #include <nsmlconstants.h> |
|
21 |
|
22 // --------------------------------------------------------- |
|
23 // CSyncMLHistoryPushMsg::InternalizeL(RReadStream& aStream) |
|
24 // Creates entry from given stream |
|
25 // --------------------------------------------------------- |
|
26 void CSyncMLHistoryPushMsg::InternalizeL(RReadStream& aStream) |
|
27 { |
|
28 |
|
29 CSyncMLHistoryEntry::InternalizeL(aStream); |
|
30 |
|
31 TPckgBuf<TTime> time(iTimeStamp); |
|
32 aStream >> time; |
|
33 iResultCode = aStream.ReadInt32L(); |
|
34 iRcvCount = aStream.ReadInt32L(); |
|
35 |
|
36 aStream >> iDigest; |
|
37 |
|
38 TInt count = aStream.ReadInt32L(); |
|
39 |
|
40 for (TInt i = 0; i < count; i++) |
|
41 { |
|
42 CSmlAlertInfo* info = CSmlAlertInfo::NewLC(); |
|
43 info->InternalizeL(aStream); |
|
44 iAlerts.AppendL(info); |
|
45 CleanupStack::Pop(); |
|
46 } |
|
47 } |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CSyncMLHistoryPushMsg::NewL() |
|
51 // Two phase constructor |
|
52 // --------------------------------------------------------- |
|
53 EXPORT_C CSyncMLHistoryPushMsg* CSyncMLHistoryPushMsg::NewL() |
|
54 { |
|
55 return new (ELeave) CSyncMLHistoryPushMsg; |
|
56 } |
|
57 |
|
58 // --------------------------------------------------------- |
|
59 // CSyncMLHistoryPushMsg::NewL() |
|
60 // Destructor |
|
61 // --------------------------------------------------------- |
|
62 EXPORT_C CSyncMLHistoryPushMsg::~CSyncMLHistoryPushMsg() |
|
63 { |
|
64 iAlerts.ResetAndDestroy(); |
|
65 iAlerts.Close(); |
|
66 } |
|
67 |
|
68 // --------------------------------------------------------- |
|
69 // CSyncMLHistoryPushMsg::ExternalizeL(RWriteStream& aStream) const |
|
70 // Writes entry to given stream |
|
71 // --------------------------------------------------------- |
|
72 EXPORT_C void CSyncMLHistoryPushMsg::ExternalizeL(RWriteStream& aStream) const |
|
73 { |
|
74 CSyncMLHistoryEntry::ExternalizeL(aStream); |
|
75 |
|
76 |
|
77 TPckgBuf<TTime> time(iTimeStamp); |
|
78 aStream << time; |
|
79 aStream.WriteInt32L(iResultCode); |
|
80 aStream.WriteInt32L(iRcvCount); |
|
81 aStream << iDigest; |
|
82 |
|
83 TInt count = iAlerts.Count(); |
|
84 aStream.WriteInt32L( count ); |
|
85 |
|
86 for (TInt i = 0; i < count; i++) |
|
87 { |
|
88 iAlerts[i]->ExternalizeL(aStream); |
|
89 } |
|
90 } |
|
91 |
|
92 // --------------------------------------------------------- |
|
93 // CSyncMLHistoryPushMsg::Profile() const |
|
94 // Returns profile id |
|
95 // --------------------------------------------------------- |
|
96 EXPORT_C TSmlProfileId CSyncMLHistoryPushMsg::Profile() const |
|
97 { |
|
98 TSmlProfileId profileId = KNSmlNullId; |
|
99 |
|
100 TInt count = iAlerts.Count(); |
|
101 |
|
102 for (TInt i = 0; i < count; i++) |
|
103 { |
|
104 if ( ( profileId = iAlerts[i]->Profile() ) != KNSmlNullId ) |
|
105 break; |
|
106 } |
|
107 return profileId; |
|
108 } |
|
109 |
|
110 // --------------------------------------------------------- |
|
111 // CSyncMLHistoryPushMsg::TimeStamp() const |
|
112 // Returns entry creation time |
|
113 // --------------------------------------------------------- |
|
114 EXPORT_C TTime CSyncMLHistoryPushMsg::TimeStamp() const |
|
115 { |
|
116 return iTimeStamp; |
|
117 } |
|
118 |
|
119 // --------------------------------------------------------- |
|
120 // CSyncMLHistoryPushMsg::ResultCode() const |
|
121 // Returns the set result code |
|
122 // --------------------------------------------------------- |
|
123 EXPORT_C TInt CSyncMLHistoryPushMsg::ResultCode() const |
|
124 { |
|
125 return iResultCode; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------- |
|
129 // CSyncMLHistoryPushMsg::ReceivedCount() const |
|
130 // Returns receive count |
|
131 // --------------------------------------------------------- |
|
132 EXPORT_C TInt CSyncMLHistoryPushMsg::ReceivedCount() const |
|
133 { |
|
134 return iRcvCount; |
|
135 } |
|
136 |
|
137 // --------------------------------------------------------- |
|
138 // CSyncMLHistoryPushMsg::MsgDigest() const |
|
139 // Returns the set digest |
|
140 // --------------------------------------------------------- |
|
141 EXPORT_C const TDesC8& CSyncMLHistoryPushMsg::MsgDigest() const |
|
142 { |
|
143 return iDigest; |
|
144 } |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // CSyncMLHistoryPushMsg::AlertCount() const |
|
148 // Returns the count of alerts stored in entry |
|
149 // --------------------------------------------------------- |
|
150 EXPORT_C TInt CSyncMLHistoryPushMsg::AlertCount() const |
|
151 { |
|
152 return iAlerts.Count(); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------- |
|
156 // CSyncMLHistoryPushMsg::Alert(TInt aIndex) const |
|
157 // Returns the alert from specified index |
|
158 // --------------------------------------------------------- |
|
159 EXPORT_C const CSmlAlertInfo& CSyncMLHistoryPushMsg::Alert(TInt aIndex) const |
|
160 { |
|
161 return *(iAlerts[aIndex]); |
|
162 } |
|
163 |
|
164 // --------------------------------------------------------- |
|
165 // CSyncMLHistoryPushMsg::IncReceivedCount() |
|
166 // Increments receive count |
|
167 // --------------------------------------------------------- |
|
168 EXPORT_C void CSyncMLHistoryPushMsg::IncReceivedCount() |
|
169 { |
|
170 iRcvCount++; |
|
171 } |
|
172 |
|
173 // --------------------------------------------------------- |
|
174 // CSyncMLHistoryPushMsg::SetMsgDigest(const TDesC8& aMsgDigest) |
|
175 // Sets digest |
|
176 // --------------------------------------------------------- |
|
177 EXPORT_C void CSyncMLHistoryPushMsg::SetMsgDigest(const TDesC8& aMsgDigest) |
|
178 { |
|
179 iDigest.Zero(); |
|
180 iDigest.Copy(aMsgDigest); |
|
181 } |
|
182 |
|
183 // --------------------------------------------------------- |
|
184 // CSyncMLHistoryPushMsg::AddAlertsL(RPointerArray<CSmlAlertInfo>& aAlertInfoArray) |
|
185 // Adds alerts to entry |
|
186 // Ownership of CSmlAlertInfo objects is transferred. |
|
187 // --------------------------------------------------------- |
|
188 EXPORT_C void CSyncMLHistoryPushMsg::AddAlertsL(RPointerArray<CSmlAlertInfo>& aAlertInfoArray) |
|
189 { |
|
190 ResetAlerts(); |
|
191 |
|
192 while ( aAlertInfoArray.Count() ) |
|
193 { |
|
194 CSmlAlertInfo* temp = aAlertInfoArray[0]; |
|
195 iAlerts.AppendL( temp ); |
|
196 aAlertInfoArray.Remove(0); |
|
197 } |
|
198 |
|
199 } |
|
200 |
|
201 // --------------------------------------------------------- |
|
202 // CSyncMLHistoryPushMsg::ResetAlerts() |
|
203 // Deletes alerts from entry |
|
204 // --------------------------------------------------------- |
|
205 EXPORT_C void CSyncMLHistoryPushMsg::ResetAlerts() |
|
206 { |
|
207 iAlerts.ResetAndDestroy(); |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------- |
|
211 // CSyncMLHistoryPushMsgSetResultCode(TInt aResultCode) |
|
212 // Sets result code |
|
213 // --------------------------------------------------------- |
|
214 EXPORT_C void CSyncMLHistoryPushMsg::SetResultCode(TInt aResultCode) |
|
215 { |
|
216 iResultCode = aResultCode; |
|
217 } |
|
218 |
|
219 // --------------------------------------------------------- |
|
220 // CSyncMLHistoryPushMsg::CSyncMLHistoryPushMsg() |
|
221 // Constructor |
|
222 // --------------------------------------------------------- |
|
223 CSyncMLHistoryPushMsg::CSyncMLHistoryPushMsg() |
|
224 : CSyncMLHistoryEntry(KUidSmlHistoryEntryPushMsg), iResultCode(KErrNone), iRcvCount(0), iAlerts(4) |
|
225 { |
|
226 iTimeStamp.UniversalTime(); |
|
227 } |
|
228 |
|
229 //End of File |