|
1 // Copyright (c) 1997-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 "agmattendee.h" |
|
17 |
|
18 #include <s32stor.h> |
|
19 |
|
20 // |
|
21 // CAgnAttendee |
|
22 |
|
23 CAgnAttendee::CAgnAttendee() |
|
24 { |
|
25 } |
|
26 |
|
27 CAgnAttendee* CAgnAttendee::NewL(RReadStream& aStream) |
|
28 { |
|
29 CAgnAttendee* self = new(ELeave)CAgnAttendee(); |
|
30 CleanupStack::PushL(self); |
|
31 self->InternalizeL(aStream); |
|
32 CleanupStack::Pop(self); |
|
33 return self; |
|
34 } |
|
35 |
|
36 EXPORT_C CAgnAttendee* CAgnAttendee::NewL(const TDesC& aAddress, const TDesC& aSentBy) |
|
37 /** |
|
38 @internalAll |
|
39 */ |
|
40 { |
|
41 CAgnAttendee* self = new(ELeave)CAgnAttendee(); |
|
42 CleanupStack::PushL(self); |
|
43 self->ConstructL(aAddress, aSentBy); |
|
44 CleanupStack::Pop(self); |
|
45 return self; |
|
46 } |
|
47 |
|
48 EXPORT_C CAgnAttendee* CAgnAttendee::CloneL() const |
|
49 /** |
|
50 @internalAll |
|
51 */ |
|
52 { |
|
53 CAgnAttendee* attendee = new (ELeave) CAgnAttendee(); |
|
54 CleanupStack::PushL(attendee); |
|
55 attendee->CopyL(*this); |
|
56 CleanupStack::Pop(attendee); |
|
57 return attendee; |
|
58 } |
|
59 |
|
60 void CAgnAttendee::ConstructL(const TDesC& aAddress, const TDesC& aSentBy) |
|
61 { |
|
62 iAddress = aAddress.AllocL(); |
|
63 iSentBy = aSentBy.AllocL(); |
|
64 iCommonName = KNullDesC().AllocL(); |
|
65 } |
|
66 |
|
67 CAgnAttendee::~CAgnAttendee() |
|
68 { |
|
69 delete iAddress; |
|
70 delete iCommonName; |
|
71 delete iSentBy; |
|
72 } |
|
73 |
|
74 |
|
75 EXPORT_C void CAgnAttendee::SetRole(TAgnRole aRole) |
|
76 /** Sets the role of the attendee. |
|
77 |
|
78 @internalAll |
|
79 @param aRole The attendee's role. */ |
|
80 { |
|
81 switch(aRole) |
|
82 { |
|
83 case EAttendee: |
|
84 iCalRole = CCalAttendee::EReqParticipant; |
|
85 break; |
|
86 case EOrganizer: |
|
87 // Do nothing. New Organizer person will be created and handled by CCalEntry |
|
88 break; |
|
89 case EOwner: |
|
90 iCalRole = CCalAttendee::EChair; |
|
91 break; |
|
92 case EDelegate: |
|
93 iCalRole = CCalAttendee::EReqParticipant; |
|
94 break; |
|
95 default: |
|
96 break; |
|
97 } |
|
98 } |
|
99 |
|
100 EXPORT_C void CAgnAttendee::SetResponseRequested(TBool aRsvp) |
|
101 /** Sets whether a response is requested from the attendee. |
|
102 |
|
103 @internalAll |
|
104 @param aRsvp ETrue if a response is requested, EFalse if a response is not |
|
105 requested. */ |
|
106 { |
|
107 iRsvp = aRsvp; |
|
108 } |
|
109 |
|
110 EXPORT_C void CAgnAttendee::SetCommonNameL(const TDesC& aCommonName) |
|
111 /** |
|
112 @internalAll |
|
113 */ |
|
114 { |
|
115 delete iCommonName; |
|
116 iCommonName = NULL; |
|
117 iCommonName = aCommonName.AllocL(); |
|
118 } |
|
119 |
|
120 EXPORT_C void CAgnAttendee::SetCalRoleL(const CCalAttendee::TCalRole aRole) |
|
121 /** |
|
122 @internalAll |
|
123 */ |
|
124 { |
|
125 iCalRole = aRole; |
|
126 switch(aRole) |
|
127 { |
|
128 case CCalAttendee::EChair: |
|
129 case CCalAttendee::EReqParticipant: |
|
130 case CCalAttendee::EOptParticipant: |
|
131 case CCalAttendee::ENonParticipant: |
|
132 case CCalAttendee::EVCalAttendee: |
|
133 case CCalAttendee::EVCalDelegate: |
|
134 case CCalAttendee::EVCalOwner: |
|
135 break; |
|
136 default: |
|
137 User::Leave(KErrNotFound); |
|
138 break; |
|
139 } |
|
140 } |
|
141 |
|
142 EXPORT_C void CAgnAttendee::SetCalStatus(const CCalAttendee::TCalStatus aStatus) |
|
143 /** |
|
144 @internalAll |
|
145 */ |
|
146 { |
|
147 iCalStatus = aStatus; |
|
148 } |
|
149 |
|
150 |
|
151 // This code should use the chevron operator to externalise |
|
152 // iAddress to save space - but cannot be changed since |
|
153 // it would break file compatability with AppEngines5.1 |
|
154 void CAgnAttendee::ExternalizeL(RWriteStream& aStream) const |
|
155 { |
|
156 aStream.WriteUint8L(iRsvp); |
|
157 aStream.WriteUint8L(iCalRole); |
|
158 aStream.WriteUint8L(iCalStatus); |
|
159 aStream.WriteUint8L(iExpect); |
|
160 |
|
161 TInt size = 0; |
|
162 if (iAddress) |
|
163 { |
|
164 size = iAddress->Length(); |
|
165 aStream.WriteUint32L(size); |
|
166 aStream.WriteL(iAddress->Des(), size); |
|
167 } |
|
168 else |
|
169 { |
|
170 aStream.WriteUint32L(size); |
|
171 } |
|
172 |
|
173 size = 0; |
|
174 |
|
175 if (iCommonName) |
|
176 { |
|
177 size = iCommonName->Length(); |
|
178 aStream.WriteUint32L(size); |
|
179 aStream.WriteL(iCommonName->Des(), size); |
|
180 } |
|
181 else |
|
182 { |
|
183 aStream.WriteUint32L(size); |
|
184 } |
|
185 |
|
186 size = 0; |
|
187 |
|
188 if (iSentBy) |
|
189 { |
|
190 size = iSentBy->Length(); |
|
191 aStream.WriteUint32L(size); |
|
192 aStream.WriteL(iSentBy->Des(), size); |
|
193 } |
|
194 else |
|
195 { |
|
196 aStream.WriteUint32L(size); |
|
197 } |
|
198 } |
|
199 |
|
200 EXPORT_C void CAgnAttendee::SetVCalExpect(CCalAttendee::TVCalExpect aExpect) |
|
201 { |
|
202 iExpect = aExpect; |
|
203 } |
|
204 |
|
205 EXPORT_C CCalAttendee::TVCalExpect CAgnAttendee::VCalExpect() const |
|
206 { |
|
207 return iExpect; |
|
208 } |
|
209 |
|
210 void CAgnAttendee::InternalizeL(RReadStream& aStream) |
|
211 { |
|
212 iRsvp = aStream.ReadUint8L(); |
|
213 iCalRole = static_cast<CCalAttendee::TCalRole>(aStream.ReadUint8L()); |
|
214 iCalStatus = static_cast<CCalAttendee::TCalStatus>(aStream.ReadUint8L()); |
|
215 iExpect = static_cast<CCalAttendee::TVCalExpect>(aStream.ReadUint8L()); |
|
216 |
|
217 // Delete any possible existing data |
|
218 delete iAddress; |
|
219 iAddress = NULL; |
|
220 |
|
221 delete iCommonName; |
|
222 iCommonName = NULL; |
|
223 |
|
224 delete iSentBy; |
|
225 iSentBy = NULL; |
|
226 |
|
227 // read in Address |
|
228 TInt size = aStream.ReadUint32L(); |
|
229 iAddress = HBufC::NewL(size); |
|
230 TPtr bufPtr = iAddress->Des(); |
|
231 aStream.ReadL(bufPtr,size); |
|
232 |
|
233 size = aStream.ReadUint32L(); |
|
234 iCommonName = HBufC::NewL(size); |
|
235 TPtr bufPtr2 = iCommonName->Des(); |
|
236 aStream.ReadL(bufPtr2,size); |
|
237 |
|
238 size = aStream.ReadUint32L(); |
|
239 iSentBy = HBufC::NewL(size); |
|
240 TPtr bufPtr3 = iSentBy->Des(); |
|
241 aStream.ReadL(bufPtr3,size); |
|
242 } |
|
243 |
|
244 void CAgnAttendee::CopyL(const CAgnAttendee& aSource) |
|
245 /** Copies all the details from the source into this attendee. |
|
246 |
|
247 @param aSource Pointer to the source attendee. */ |
|
248 { |
|
249 iRsvp = aSource.ResponseRequested(); |
|
250 iCalRole = aSource.CalRole(); |
|
251 iCalStatus = aSource.CalStatus(); |
|
252 iExpect = aSource.VCalExpect(); |
|
253 |
|
254 // Delete any address that already exists |
|
255 delete iAddress; |
|
256 iAddress = NULL; |
|
257 iAddress = aSource.Address().AllocL(); |
|
258 |
|
259 delete iCommonName; |
|
260 iCommonName = NULL; |
|
261 iCommonName = aSource.CommonName().AllocL(); |
|
262 |
|
263 delete iSentBy; |
|
264 iSentBy = NULL; |
|
265 iSentBy = aSource.SentBy().AllocL(); |
|
266 } |
|
267 |
|
268 EXPORT_C const TDesC& CAgnAttendee::Address() const |
|
269 /** |
|
270 @internalAll |
|
271 */ |
|
272 { |
|
273 __ASSERT_DEBUG(iAddress,User::Invariant()); |
|
274 return *iAddress; |
|
275 } |
|
276 |
|
277 EXPORT_C const TDesC& CAgnAttendee::CommonName() const |
|
278 /** |
|
279 @internalAll |
|
280 */ |
|
281 { |
|
282 __ASSERT_DEBUG(iCommonName,User::Invariant()); |
|
283 return *iCommonName; |
|
284 } |
|
285 |
|
286 EXPORT_C const TDesC& CAgnAttendee::SentBy() const |
|
287 /** |
|
288 @internalAll |
|
289 */ |
|
290 { |
|
291 __ASSERT_DEBUG(iSentBy,User::Invariant()); |
|
292 return *iSentBy; |
|
293 } |
|
294 |
|
295 |
|
296 EXPORT_C TBool CAgnAttendee::ResponseRequested() const |
|
297 /** Tests whether a response has been requested from the attendee. |
|
298 |
|
299 @internalAll |
|
300 @return ETrue if a response is requested, EFalse if a response is not requested. */ |
|
301 { |
|
302 return iRsvp; |
|
303 } |
|
304 |
|
305 EXPORT_C CCalAttendee::TCalRole CAgnAttendee::CalRole() const |
|
306 /** |
|
307 The role of the attendee to a meeting (e.g. chair, required participant, optional participant). |
|
308 @internalAll |
|
309 */ |
|
310 { |
|
311 return iCalRole; |
|
312 } |
|
313 |
|
314 EXPORT_C CCalAttendee::TCalStatus CAgnAttendee::CalStatus() const |
|
315 /** |
|
316 The status of the attendee to a meeting (e.g. tentative, declined, accepted). |
|
317 @internalAll |
|
318 */ |
|
319 { |
|
320 return iCalStatus; |
|
321 } |
|
322 |