|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of base class for meeting request data fillers |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CMRDataFillerBase.h" |
|
23 #include "MMRModelInterface.h" |
|
24 #include "MRViewersPanic.h" |
|
25 #include "CMRStringFormatter.h" |
|
26 #include "MREntryConsultant.h" |
|
27 #include <e32std.h> |
|
28 #include <msvids.h> |
|
29 #include <coemain.h> // CCoeEnv |
|
30 #include <stringloader.h> // StringLoader |
|
31 #include <avkon.rsg> // resouce identifiers |
|
32 #include <crichbio.h> // CRichBio |
|
33 #include <calentry.h> // Calendar entry API V2 |
|
34 #include <calrrule.h> |
|
35 #include <meetingrequestviewersuires.rsg>// Resource strings for meeting request |
|
36 #include <stringloader.h> // resource string loading utils |
|
37 #include <calalarm.h> // CCalAlarm |
|
38 #include <cmrmailboxutils.h> |
|
39 |
|
40 // CONSTANTS |
|
41 /// Unnamed namespace for local definitions |
|
42 namespace { |
|
43 |
|
44 _LIT( KPanicMsg, "~CMRDataFillerBase" ); |
|
45 |
|
46 void Panic( TPanicCode aReason ) |
|
47 { |
|
48 User::Panic( KPanicMsg, aReason ); |
|
49 } |
|
50 |
|
51 } // namespace |
|
52 |
|
53 |
|
54 // ============================ MEMBER FUNCTIONS =============================== |
|
55 |
|
56 CMRDataFillerBase::~CMRDataFillerBase() |
|
57 { |
|
58 delete iStringFormatter; |
|
59 } |
|
60 |
|
61 void CMRDataFillerBase::AddItemL( |
|
62 CRichBio& aViewer, |
|
63 TInt aLabelRes, |
|
64 const TDesC& aValue ) |
|
65 { |
|
66 // Empty fields are not shown. |
|
67 if ( aValue.Length() ) |
|
68 { |
|
69 aViewer.AddItemL( *StringLoader::LoadLC( aLabelRes, &iCoeEnv ), |
|
70 aValue ); |
|
71 CleanupStack::PopAndDestroy(); // (label text) |
|
72 } |
|
73 } |
|
74 |
|
75 void CMRDataFillerBase::AddItemL( |
|
76 CRichBio& aViewer, |
|
77 TInt aLabelRes, |
|
78 TInt aValueRes ) |
|
79 { |
|
80 aViewer.AddItemL( *StringLoader::LoadLC( aLabelRes, &iCoeEnv ), |
|
81 *StringLoader::LoadLC( aValueRes, &iCoeEnv ) ); |
|
82 CleanupStack::PopAndDestroy(2); // (label and value text) |
|
83 } |
|
84 |
|
85 // ----------------------------------------------------------------------------- |
|
86 // ?classname::?classname |
|
87 // C++ default constructor can NOT contain any code, that |
|
88 // might leave. |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 CMRDataFillerBase::CMRDataFillerBase( |
|
92 CRichBio& aRichBio, |
|
93 MMRModelInterface& aModel, |
|
94 CCoeEnv& aCoeEnv, |
|
95 CMRMailboxUtils& aUtils, |
|
96 MAgnEntryUi::TAgnEntryUiInParams& aParams ) |
|
97 : iCoeEnv( aCoeEnv ), |
|
98 iModel( aModel ), |
|
99 iRichBio( aRichBio ), |
|
100 iUtils( aUtils ), |
|
101 iParams( aParams ) |
|
102 { |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // ?classname::ConstructL |
|
107 // Symbian 2nd phase constructor can leave. |
|
108 // ----------------------------------------------------------------------------- |
|
109 // |
|
110 void CMRDataFillerBase::ConstructL() |
|
111 { |
|
112 iStringFormatter = CMRStringFormatter::NewL( iCoeEnv ); |
|
113 } |
|
114 |
|
115 void CMRDataFillerBase::FillViewerWithDataL() |
|
116 { |
|
117 iEntry = iModel.CombinedEntry(); |
|
118 __ASSERT_DEBUG( iEntry, Panic( ECombinedCalEntryNull ) ); |
|
119 |
|
120 // call templated method |
|
121 DoFillViewerL(); |
|
122 } |
|
123 |
|
124 void CMRDataFillerBase::RefreshViewerL() |
|
125 { |
|
126 iRichBio.Reset(); |
|
127 FillViewerWithDataL(); |
|
128 } |
|
129 |
|
130 TBool CMRDataFillerBase::MeetingOnSameDayL() |
|
131 { |
|
132 return !MREntryConsultant::SpansManyDaysL( iEntry->StartTimeL(), |
|
133 iEntry->EndTimeL() ); |
|
134 } |
|
135 |
|
136 void CMRDataFillerBase::FillOrganiserDataL() |
|
137 { |
|
138 AddItemL( iRichBio, |
|
139 R_QTN_MAIL_MTG_ORGANISER, |
|
140 iEntry->OrganizerL()->Address() ); |
|
141 } |
|
142 |
|
143 void CMRDataFillerBase::FillWhenDataL() |
|
144 { |
|
145 HBufC* string = iStringFormatter->WhenStringLC( iEntry->StartTimeL(), |
|
146 iEntry->EndTimeL() ); |
|
147 AddItemL( iRichBio, R_QTN_MAIL_MTG_DATE, *string ); |
|
148 CleanupStack::PopAndDestroy( string ); |
|
149 } |
|
150 |
|
151 void CMRDataFillerBase::FillStartTimeDataL() |
|
152 { |
|
153 HBufC* string = iStringFormatter->DateStringLC( iEntry->StartTimeL() ); |
|
154 AddItemL( iRichBio, R_QTN_SM_CAL_STARTTIME, *string ); |
|
155 CleanupStack::PopAndDestroy( string ); |
|
156 } |
|
157 |
|
158 void CMRDataFillerBase::FillEndTimeDataL() |
|
159 { |
|
160 HBufC* string = iStringFormatter->DateStringLC( iEntry->EndTimeL() ); |
|
161 AddItemL( iRichBio, R_QTN_SM_CAL_ENDTIME, *string ); |
|
162 CleanupStack::PopAndDestroy( string ); |
|
163 } |
|
164 |
|
165 void CMRDataFillerBase::FillLocationDataL() |
|
166 { |
|
167 AddItemL( iRichBio,R_QTN_SM_CAL_LOCATION,iEntry->LocationL()); |
|
168 } |
|
169 |
|
170 void CMRDataFillerBase::FillDescriptionDataL() |
|
171 { |
|
172 AddItemL( iRichBio,R_QTN_SM_CAL_DESCRIPTION,iEntry->DescriptionL()); |
|
173 } |
|
174 |
|
175 TInt CMRDataFillerBase::GetAttendeeStatusL( const CCalAttendee& aAttendee ) |
|
176 { |
|
177 TInt retVal( 0 ); |
|
178 |
|
179 CCalAttendee::TCalStatus status = aAttendee.StatusL(); |
|
180 |
|
181 switch( status ) |
|
182 { |
|
183 case CCalAttendee::ENeedsAction: |
|
184 { |
|
185 retVal = R_QTN_MAIL_MTG_PLS_RESPOND; |
|
186 break; |
|
187 } |
|
188 case CCalAttendee::EAccepted: // fall through |
|
189 case CCalAttendee::EConfirmed: |
|
190 { |
|
191 retVal = R_QTN_MAIL_MTG_ACCEPTED; |
|
192 break; |
|
193 } |
|
194 case CCalAttendee::ETentative: |
|
195 { |
|
196 retVal = R_QTN_MAIL_MTG_TENTATIVE; |
|
197 break; |
|
198 } |
|
199 case CCalAttendee::EDeclined: |
|
200 { |
|
201 retVal = R_QTN_MAIL_MTG_DECLINE; |
|
202 break; |
|
203 } |
|
204 default: |
|
205 { |
|
206 break; |
|
207 } |
|
208 } |
|
209 |
|
210 return retVal; |
|
211 } |
|
212 |
|
213 void CMRDataFillerBase::FillStatusDataL() |
|
214 { |
|
215 CCalAttendee* attendee = iUtils.ThisAttendeeL( *iEntry ); |
|
216 if ( attendee ) |
|
217 { |
|
218 TInt retVal = GetAttendeeStatusL( *attendee ); |
|
219 if ( retVal != 0 ) |
|
220 { |
|
221 AddItemL( iRichBio, R_QTN_MAIL_MTG_STATUS, retVal ); |
|
222 } |
|
223 } |
|
224 } |
|
225 |
|
226 TInt CMRDataFillerBase::GetAttendanceStatusL( const CCalAttendee& aAttendee ) |
|
227 { |
|
228 TInt retVal( 0 ); |
|
229 |
|
230 CCalAttendee::TCalRole role = aAttendee.RoleL(); |
|
231 |
|
232 switch( role ) |
|
233 { |
|
234 case CCalAttendee::EReqParticipant: |
|
235 { |
|
236 retVal = R_QTN_MAIL_MTG_REQUIRED; |
|
237 break; |
|
238 } |
|
239 case CCalAttendee::EOptParticipant: |
|
240 { |
|
241 retVal = R_QTN_MAIL_MTG_OPTIONAL; |
|
242 break; |
|
243 } |
|
244 case CCalAttendee::ENonParticipant: |
|
245 { |
|
246 retVal = R_QTN_MAIL_MTG_OPTIONAL; |
|
247 break; |
|
248 } |
|
249 case CCalAttendee::EChair: |
|
250 { |
|
251 retVal = R_QTN_MAIL_MTG_REQUIRED; |
|
252 break; |
|
253 } |
|
254 default: |
|
255 { |
|
256 break; |
|
257 } |
|
258 } |
|
259 return retVal; |
|
260 } |
|
261 |
|
262 |
|
263 void CMRDataFillerBase::FillAttendanceDataL() |
|
264 { |
|
265 CCalAttendee* attendee = iUtils.ThisAttendeeL( *iEntry ); |
|
266 if ( attendee ) |
|
267 { |
|
268 TInt retVal = GetAttendanceStatusL( *attendee ); |
|
269 if ( retVal != 0 ) |
|
270 { |
|
271 AddItemL( iRichBio, R_QTN_MAIL_MTG_ATTENDANCE, retVal ); |
|
272 } |
|
273 } |
|
274 } |
|
275 |
|
276 void CMRDataFillerBase::FillAlarmTimeDataL() |
|
277 { |
|
278 CCalAlarm* alarm = iEntry->AlarmL(); // ownership transferred |
|
279 if ( alarm ) |
|
280 { |
|
281 CleanupStack::PushL( alarm ); |
|
282 TTime alarmTime = iEntry->StartTimeL().TimeLocalL() - |
|
283 alarm->TimeOffset(); |
|
284 HBufC* string = iStringFormatter->TimeStringLC( alarmTime ); |
|
285 AddItemL( iRichBio, R_QTN_SM_CAL_ALARMTIME, *string ); |
|
286 CleanupStack::PopAndDestroy( 2, alarm ); // string, alarm |
|
287 } |
|
288 } |
|
289 |
|
290 void CMRDataFillerBase::FillAlarmDateDataL() |
|
291 { |
|
292 CCalAlarm* alarm = iEntry->AlarmL(); // ownership transferred |
|
293 if ( alarm ) |
|
294 { |
|
295 CleanupStack::PushL( alarm ); |
|
296 TTime alarmTime = iEntry->StartTimeL().TimeLocalL() - |
|
297 alarm->TimeOffset(); |
|
298 HBufC* string = iStringFormatter->DateStringLC( alarmTime ); |
|
299 AddItemL( iRichBio, R_QTN_SM_CAL_ALARMDATE, *string ); |
|
300 CleanupStack::PopAndDestroy( 2, alarm ); // string, alarm |
|
301 } |
|
302 } |
|
303 |
|
304 TInt CMRDataFillerBase::GetRepeatingEntryRuleL() |
|
305 { |
|
306 TCalRRule calRule; |
|
307 |
|
308 TInt retVal( 0 ); |
|
309 |
|
310 if ( iEntry->GetRRuleL( calRule ) ) |
|
311 { |
|
312 TCalRRule::TType repeatType( calRule.Type() ); |
|
313 |
|
314 switch ( repeatType ) |
|
315 { |
|
316 case TCalRRule::EDaily: |
|
317 { |
|
318 retVal = R_QTN_SM_CAL_RPT_DAILY; |
|
319 break; |
|
320 } |
|
321 case TCalRRule::EWeekly: |
|
322 { |
|
323 retVal = R_QTN_SM_CAL_RPT_WEEKLY; |
|
324 break; |
|
325 } |
|
326 case TCalRRule::EMonthly: |
|
327 { |
|
328 retVal = R_QTN_SM_CAL_RPT_MONTHLY; |
|
329 break; |
|
330 } |
|
331 case TCalRRule::EYearly: |
|
332 { |
|
333 retVal = R_QTN_SM_CAL_RPT_YEARLY; |
|
334 break; |
|
335 } |
|
336 default: |
|
337 { |
|
338 retVal = R_QTN_SM_CAL_RPT_DAILY; |
|
339 break; |
|
340 } |
|
341 } |
|
342 } |
|
343 return retVal; |
|
344 } |
|
345 |
|
346 void CMRDataFillerBase::FillRepeatRuleDataL() |
|
347 { |
|
348 TInt retVal = GetRepeatingEntryRuleL(); |
|
349 if ( retVal ) |
|
350 { |
|
351 AddItemL( iRichBio,R_QTN_SM_CAL_REPEAT, retVal ); |
|
352 } |
|
353 } |
|
354 |
|
355 void CMRDataFillerBase::FillRepeatUntilDataL() |
|
356 { |
|
357 TCalRRule calRule; |
|
358 if ( iEntry->GetRRuleL( calRule ) ) |
|
359 { |
|
360 HBufC* string = iStringFormatter->DateStringLC( calRule.Until() ); |
|
361 AddItemL( iRichBio, R_QTN_SM_CAL_REPEAT_UNTIL, *string ); |
|
362 CleanupStack::PopAndDestroy( string ); |
|
363 } |
|
364 } |
|
365 |
|
366 void CMRDataFillerBase::FillSynchronisationDataL() |
|
367 { |
|
368 CCalEntry::TReplicationStatus replicationStatus; |
|
369 |
|
370 replicationStatus = iEntry->ReplicationStatusL(); |
|
371 |
|
372 TInt replicationVal; |
|
373 |
|
374 switch( replicationStatus ) |
|
375 { |
|
376 case CCalEntry::EOpen: |
|
377 { |
|
378 replicationVal = R_QTN_SM_CAL_CONF_PUBLIC; |
|
379 break; |
|
380 } |
|
381 case CCalEntry::EPrivate: |
|
382 { |
|
383 replicationVal = R_QTN_SM_CAL_CONF_PRIVATE; |
|
384 break; |
|
385 } |
|
386 case CCalEntry::ERestricted: |
|
387 { |
|
388 replicationVal = R_QTN_SM_CAL_CONF_NO_SYNC; |
|
389 break; |
|
390 } |
|
391 default: |
|
392 { |
|
393 replicationVal = R_QTN_SM_CAL_CONF_PUBLIC; |
|
394 } |
|
395 } |
|
396 AddItemL( iRichBio,R_QTN_SM_CAL_CONFIDENTIALITY, replicationVal ); |
|
397 } |
|
398 |
|
399 // End of File |
|
400 |