|
1 /* |
|
2 * Copyright (c) 2004 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: Provides methods for CAttendeeItem class. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "CAttendeeItem.h" |
|
22 #include <caluser.h> |
|
23 |
|
24 /// Unnamed namespace for local definitions |
|
25 namespace { |
|
26 |
|
27 // LOCAL CONSTANTS AND MACROS |
|
28 #ifdef _DEBUG |
|
29 _LIT( KPanicMsg, "CAttendeeItem" ); |
|
30 |
|
31 enum TPanicCode |
|
32 { |
|
33 KAttPanicNullPointer = 1, |
|
34 KAttPanicUnknownOperation |
|
35 }; |
|
36 |
|
37 void Panic( TPanicCode aReason ) |
|
38 { |
|
39 User::Panic( KPanicMsg, aReason ); |
|
40 } |
|
41 #endif |
|
42 } // namespace |
|
43 // ============================ MEMBER FUNCTIONS ============================== |
|
44 // ---------------------------------------------------------------------------- |
|
45 // CAttendeeItem::NewL |
|
46 // Two-phased constructor. |
|
47 // ---------------------------------------------------------------------------- |
|
48 // |
|
49 CAttendeeItem* CAttendeeItem::NewL( CCalAttendee* aCalAttendee ) |
|
50 { |
|
51 CAttendeeItem* self = NewLC( aCalAttendee ); |
|
52 CleanupStack::Pop(self); // self |
|
53 return self; |
|
54 } |
|
55 |
|
56 // --------------------------------------------------------- |
|
57 // CAttendeeItem::NewLC |
|
58 // --------------------------------------------------------- |
|
59 // |
|
60 CAttendeeItem* CAttendeeItem::NewLC( CCalAttendee* aCalAttendee ) |
|
61 { |
|
62 CAttendeeItem* self = new(ELeave)CAttendeeItem( aCalAttendee ); |
|
63 CleanupStack::PushL( self ); |
|
64 return self; |
|
65 } |
|
66 |
|
67 // ---------------------------------------------------------------------------- |
|
68 // CAttendeeItem::CAttendeeItem |
|
69 // C++ default constructor can NOT contain any code, that |
|
70 // might leave. |
|
71 // ---------------------------------------------------------------------------- |
|
72 // |
|
73 CAttendeeItem::CAttendeeItem( CCalAttendee* aCalAttendee ) : |
|
74 iContactID( KNullContactId ), |
|
75 iCalAttendee( aCalAttendee ), |
|
76 iOwnership( EFalse ), |
|
77 iOrganizerSatus( EFalse ) |
|
78 { |
|
79 } |
|
80 |
|
81 // --------------------------------------------------------- |
|
82 // CAttendeeItem::~CAttendeeItem |
|
83 // --------------------------------------------------------- |
|
84 // |
|
85 CAttendeeItem::~CAttendeeItem() |
|
86 { |
|
87 delete iContactTitle; |
|
88 if ( iOwnership ) |
|
89 { |
|
90 delete iCalAttendee; |
|
91 } |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------- |
|
95 // CAttendeeItem::ContactId |
|
96 // --------------------------------------------------------- |
|
97 // |
|
98 TContactItemId CAttendeeItem::ContactId() const |
|
99 { |
|
100 return iContactID; |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------- |
|
104 // CAttendeeItem::ContactTitle |
|
105 // --------------------------------------------------------- |
|
106 // |
|
107 HBufC* CAttendeeItem::ContactTitle() const |
|
108 { |
|
109 return iContactTitle; |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CAttendeeItem::AgnAttendee |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 CCalAttendee* CAttendeeItem::AgnAttendee() const |
|
117 { |
|
118 return iCalAttendee; |
|
119 } |
|
120 |
|
121 // --------------------------------------------------------- |
|
122 // CAttendeeItem::SetContactId |
|
123 // --------------------------------------------------------- |
|
124 // |
|
125 void CAttendeeItem::SetContactId( TContactItemId aId ) |
|
126 { |
|
127 iContactID = aId; |
|
128 } |
|
129 |
|
130 // --------------------------------------------------------- |
|
131 // CAttendeeItem::SetContactTitle |
|
132 // --------------------------------------------------------- |
|
133 // |
|
134 void CAttendeeItem::SetContactTitle( HBufC* aTitle ) |
|
135 { |
|
136 if ( iContactTitle ) |
|
137 { |
|
138 delete iContactTitle; |
|
139 iContactTitle = NULL; |
|
140 } |
|
141 iContactTitle = aTitle; |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------- |
|
145 // CAttendeeItem::SetOwnership |
|
146 // --------------------------------------------------------- |
|
147 // |
|
148 void CAttendeeItem::SetOwnership( TBool aOwnership ) |
|
149 { |
|
150 iOwnership = aOwnership; |
|
151 } |
|
152 |
|
153 // --------------------------------------------------------- |
|
154 // CAttendeeItem::Ownership |
|
155 // --------------------------------------------------------- |
|
156 // |
|
157 TBool CAttendeeItem::Ownership() const |
|
158 { |
|
159 return iOwnership; |
|
160 } |
|
161 |
|
162 // --------------------------------------------------------- |
|
163 // CAttendeeItem::SetAgnAttendee |
|
164 // --------------------------------------------------------- |
|
165 // |
|
166 void CAttendeeItem::SetAgnAttendee( CCalAttendee* aCalAttendee ) |
|
167 { |
|
168 __ASSERT_DEBUG( aCalAttendee, Panic( KAttPanicNullPointer ) ); |
|
169 if ( iOwnership && iCalAttendee ) |
|
170 { |
|
171 delete iCalAttendee; |
|
172 iCalAttendee = NULL; |
|
173 } |
|
174 |
|
175 iCalAttendee = aCalAttendee; |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------- |
|
179 // CAttendeeItem::SetAttendance |
|
180 // --------------------------------------------------------- |
|
181 // |
|
182 void CAttendeeItem::SetAttendanceL( TAttendance aAttendance ) |
|
183 { |
|
184 __ASSERT_DEBUG( iCalAttendee, Panic( KAttPanicNullPointer ) ); |
|
185 |
|
186 switch( aAttendance ) |
|
187 { |
|
188 case ERequire: |
|
189 { |
|
190 iCalAttendee->SetRoleL( CCalAttendee::EReqParticipant ); |
|
191 break; |
|
192 } |
|
193 case EOptional: |
|
194 { |
|
195 iCalAttendee->SetRoleL( CCalAttendee::EOptParticipant ); |
|
196 break; |
|
197 } |
|
198 /*case ENone: |
|
199 { |
|
200 iCalAttendee->SetRoleL( CCalAttendee::ENonParticipant ); |
|
201 break; |
|
202 } |
|
203 */ |
|
204 default: |
|
205 { |
|
206 iCalAttendee->SetRoleL( CCalAttendee::EReqParticipant ); |
|
207 break; |
|
208 } |
|
209 } |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------- |
|
213 // CAttendeeItem::Attendance |
|
214 // --------------------------------------------------------- |
|
215 // |
|
216 CAttendeeItem::TAttendance CAttendeeItem::AttendanceL() const |
|
217 { |
|
218 __ASSERT_DEBUG( iCalAttendee, Panic( KAttPanicNullPointer ) ); |
|
219 |
|
220 TAttendance attendance( ERequire ); |
|
221 |
|
222 switch( iCalAttendee->RoleL() ) |
|
223 { |
|
224 case CCalAttendee::EChair: |
|
225 { |
|
226 attendance = ERequire; |
|
227 break; |
|
228 } |
|
229 case CCalAttendee::EReqParticipant: |
|
230 { |
|
231 attendance = ERequire; |
|
232 break; |
|
233 } |
|
234 case CCalAttendee::EOptParticipant: |
|
235 { |
|
236 attendance = EOptional; |
|
237 break; |
|
238 } |
|
239 /*case CCalAttendee::ENonParticipant: |
|
240 { |
|
241 attendance = ENone; |
|
242 break; |
|
243 } |
|
244 */ |
|
245 default: |
|
246 { |
|
247 attendance = ERequire; |
|
248 break; |
|
249 } |
|
250 } |
|
251 return attendance; |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------- |
|
255 // CAttendeeItem::Compare |
|
256 // --------------------------------------------------------- |
|
257 // |
|
258 TInt CAttendeeItem::CompareL( const CAttendeeItem& aLhs, |
|
259 const CAttendeeItem& aRhs ) |
|
260 { |
|
261 TInt result( 0 ); |
|
262 |
|
263 result = CompareAttendancesL( aLhs, aRhs ); |
|
264 if ( result == 0 ) |
|
265 { |
|
266 result = CompareStatusL( aLhs, aRhs ); |
|
267 } |
|
268 return result; |
|
269 } |
|
270 |
|
271 // --------------------------------------------------------- |
|
272 // CAttendeeItem::CompareAttendances |
|
273 // --------------------------------------------------------- |
|
274 // |
|
275 TInt CAttendeeItem::CompareAttendancesL( const CAttendeeItem& aLhs, |
|
276 const CAttendeeItem& aRhs ) |
|
277 { |
|
278 __ASSERT_DEBUG( aLhs.iCalAttendee && aRhs.iCalAttendee, |
|
279 Panic( KAttPanicNullPointer ) ); |
|
280 TInt result( 0 ); |
|
281 |
|
282 if (( aLhs.AttendanceL() == aRhs.AttendanceL()) && |
|
283 (aRhs.IsOrganizer() == aLhs.IsOrganizer())) |
|
284 { |
|
285 result = 0; |
|
286 } |
|
287 else if ( ( aLhs.IsOrganizer() ) || |
|
288 ( aLhs.AttendanceL() == ERequire && !aRhs.IsOrganizer() )) |
|
289 { |
|
290 result = -1; |
|
291 } |
|
292 else |
|
293 { |
|
294 result = 1; |
|
295 } |
|
296 |
|
297 return result; |
|
298 } |
|
299 |
|
300 // --------------------------------------------------------- |
|
301 // CAttendeeItem::CompareStatus |
|
302 // --------------------------------------------------------- |
|
303 // |
|
304 TInt CAttendeeItem::CompareStatusL( const CAttendeeItem& aLhs, |
|
305 const CAttendeeItem& aRhs ) |
|
306 { |
|
307 __ASSERT_DEBUG( aLhs.iCalAttendee && aRhs.iCalAttendee, |
|
308 Panic( KAttPanicNullPointer ) ); |
|
309 |
|
310 TInt result( 0 ); |
|
311 |
|
312 if ( aLhs.iCalAttendee->StatusL() == aRhs.iCalAttendee->StatusL() ) |
|
313 { |
|
314 result = 0; |
|
315 } |
|
316 else if ( ( aLhs.iCalAttendee->StatusL() == CCalAttendee::EAccepted ) || |
|
317 ( aLhs.iCalAttendee->StatusL() == CCalAttendee::ETentative && |
|
318 aRhs.iCalAttendee->StatusL() != CCalAttendee::EAccepted ) || |
|
319 ( aLhs.iCalAttendee->StatusL() == CCalAttendee::EDeclined && |
|
320 ( aRhs.iCalAttendee->StatusL() != CCalAttendee::EAccepted && |
|
321 aRhs.iCalAttendee->StatusL() != CCalAttendee::ETentative ) ) |
|
322 ) |
|
323 { |
|
324 result = -1; |
|
325 } |
|
326 else |
|
327 { |
|
328 result = 1; |
|
329 } |
|
330 |
|
331 return result; |
|
332 } |
|
333 |
|
334 // --------------------------------------------------------- |
|
335 // CAttendeeItem::IsOrganizer |
|
336 // --------------------------------------------------------- |
|
337 // |
|
338 TBool CAttendeeItem::IsOrganizer() const |
|
339 { |
|
340 return iOrganizerSatus; |
|
341 } |
|
342 |
|
343 // --------------------------------------------------------- |
|
344 // CAttendeeItem::SetOrganizerStatus |
|
345 // --------------------------------------------------------- |
|
346 // |
|
347 void CAttendeeItem::SetOrganizerStatus(TBool aOrganizerStatus) |
|
348 { |
|
349 iOrganizerSatus = aOrganizerStatus; |
|
350 } |
|
351 |
|
352 // End of File |