|
1 /* |
|
2 * Copyright (c) 2007-2009 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: MR user utility class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "emailtrace.h" |
|
20 #include "cesmrcaluserutil.h" |
|
21 //<cmail> |
|
22 #include "esmrdef.h" |
|
23 //</cmail> |
|
24 #include <calentry.h> |
|
25 #include <caluser.h> |
|
26 |
|
27 // ======== MEMBER FUNCTIONS ======== |
|
28 |
|
29 // --------------------------------------------------------------------------- |
|
30 // CESMRCalUserUtil::CESMRCalUserUtil |
|
31 // --------------------------------------------------------------------------- |
|
32 // |
|
33 inline CESMRCalUserUtil::CESMRCalUserUtil( |
|
34 CCalEntry& aEntry ) |
|
35 : iEntry( aEntry ) |
|
36 { |
|
37 FUNC_LOG; |
|
38 //do nothing |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // CESMRCalUserUtil::~CESMRCalUserUtil |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 EXPORT_C CESMRCalUserUtil::~CESMRCalUserUtil() |
|
46 { |
|
47 FUNC_LOG; |
|
48 //do nothing |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CESMRCalUserUtil::NewL |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 EXPORT_C CESMRCalUserUtil* CESMRCalUserUtil::NewL( |
|
56 CCalEntry& aEntry ) |
|
57 { |
|
58 FUNC_LOG; |
|
59 CESMRCalUserUtil* self = NewLC( aEntry ); |
|
60 CleanupStack::Pop( self ); |
|
61 return self; |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CESMRCalUserUtil::NewLC |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 EXPORT_C CESMRCalUserUtil* CESMRCalUserUtil::NewLC( |
|
69 CCalEntry& aEntry ) |
|
70 { |
|
71 FUNC_LOG; |
|
72 CESMRCalUserUtil* self = new (ELeave) CESMRCalUserUtil( aEntry ); |
|
73 CleanupStack::PushL( self ); |
|
74 self->ConstructL(); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CESMRCalUserUtil::ConstructL |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 void CESMRCalUserUtil::ConstructL() |
|
83 { |
|
84 FUNC_LOG; |
|
85 //do nothing |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CESMRCalUserUtil::GetAttendeesL |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C void CESMRCalUserUtil::GetAttendeesL( |
|
93 RArray<CCalAttendee*>& aAttendeeArray, |
|
94 TUint aFilterFlags ) const |
|
95 { |
|
96 FUNC_LOG; |
|
97 |
|
98 aAttendeeArray.Reset(); |
|
99 RPointerArray<CCalAttendee>& attendees = iEntry.AttendeesL(); |
|
100 |
|
101 TBool includeRequired( EESMRRoleRequiredAttendee & aFilterFlags); |
|
102 TBool includeOptional( EESMRRoleOptionalAttendee & aFilterFlags); |
|
103 |
|
104 TInt attendeeCount( attendees.Count() ); |
|
105 for (TInt i(0); i < attendeeCount; ++i ) |
|
106 { |
|
107 CCalAttendee* attendee = attendees[i]; |
|
108 CCalAttendee::TCalRole role( |
|
109 attendee->RoleL() ); |
|
110 |
|
111 TPtrC cn( attendee->CommonName() ); |
|
112 TPtrC ad( attendee->Address() ); |
|
113 |
|
114 if ( includeRequired && |
|
115 CCalAttendee::EReqParticipant == role ) |
|
116 { |
|
117 aAttendeeArray.Append(attendee); |
|
118 } |
|
119 else if ( includeRequired && |
|
120 CCalAttendee::EChair == role ) |
|
121 { |
|
122 aAttendeeArray.Append(attendee); |
|
123 } |
|
124 else if ( includeOptional && |
|
125 CCalAttendee::EOptParticipant == role ) |
|
126 { |
|
127 aAttendeeArray.Append(attendee); |
|
128 } |
|
129 } |
|
130 |
|
131 } |
|
132 |
|
133 // --------------------------------------------------------------------------- |
|
134 // CESMRCalUserUtil::PhoneOwnerAttendeeRoleL |
|
135 // --------------------------------------------------------------------------- |
|
136 // |
|
137 EXPORT_C TESMRRole CESMRCalUserUtil::PhoneOwnerRoleL() const |
|
138 { |
|
139 FUNC_LOG; |
|
140 |
|
141 TESMRRole role = EESMRRoleUndef; |
|
142 CCalUser* phoneOwner = iEntry.PhoneOwnerL(); |
|
143 RPointerArray<CCalAttendee>& attendees = iEntry.AttendeesL(); |
|
144 |
|
145 if ( phoneOwner ) |
|
146 { |
|
147 CCalUser* organizer = iEntry.OrganizerL(); |
|
148 |
|
149 if( phoneOwner && phoneOwner == organizer ) |
|
150 { |
|
151 role = EESMRRoleOrganizer; |
|
152 } |
|
153 else |
|
154 { |
|
155 CCalAttendee* thisAttendee = NULL; |
|
156 TInt attendeeCount( attendees.Count() ); |
|
157 for ( TInt i(0); (i < attendeeCount) && !thisAttendee; ++i ) |
|
158 { |
|
159 if ( phoneOwner && phoneOwner == attendees[i] ) |
|
160 { |
|
161 thisAttendee = attendees[i]; |
|
162 } |
|
163 } |
|
164 |
|
165 if ( thisAttendee ) |
|
166 { |
|
167 switch( thisAttendee->RoleL() ) |
|
168 { |
|
169 case CCalAttendee::EChair://fallthrough |
|
170 case CCalAttendee::EReqParticipant: |
|
171 { |
|
172 role = EESMRRoleRequiredAttendee; |
|
173 } |
|
174 break; |
|
175 case CCalAttendee::EOptParticipant: |
|
176 { |
|
177 role = EESMRRoleOptionalAttendee; |
|
178 } |
|
179 break; |
|
180 case CCalAttendee::ENonParticipant: |
|
181 { |
|
182 role = EESMRRoleNonParticipant; |
|
183 } |
|
184 break; |
|
185 default: |
|
186 { |
|
187 role = EESMRRoleUndef; |
|
188 } |
|
189 break; |
|
190 } |
|
191 } |
|
192 } |
|
193 } |
|
194 |
|
195 return role; |
|
196 } |
|
197 |
|
198 // EOF |
|
199 |