|
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 for meeting request info popup |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "CMRInfoPopup.h" |
|
23 #include "MRViewersPanic.h" |
|
24 #include "MREntryConsultant.h" |
|
25 #include "CMRStringFormatter.h" |
|
26 #include <meetingrequestviewersuires.rsg> |
|
27 #include <CMRMailboxUtils.h> |
|
28 #include <calentry.h> //CCalEntry (Calendar entry API V2) |
|
29 #include <caluser.h> //caluser and attendee |
|
30 #include <AknInfoPopupNoteController.h> |
|
31 #include <stringloader.h> |
|
32 #include <eikenv.h> |
|
33 |
|
34 // CONSTANTS |
|
35 /// Unnamed namespace for local definitions |
|
36 namespace { |
|
37 |
|
38 _LIT( KPanicMsg, "CMRInfoPopup" ); |
|
39 |
|
40 void Panic( TPanicCode aReason ) |
|
41 { |
|
42 User::Panic( KPanicMsg, aReason ); |
|
43 } |
|
44 |
|
45 // Avkon takes milliseconds as a parameter, but timers use microseconds, |
|
46 // therefore to must avoid overflow the maximum time is KMaxInt / 1000. |
|
47 const TInt KMaxMilliseconds = KMaxTInt / 1000; |
|
48 const TInt KBufferSize = 512; |
|
49 |
|
50 } // namespace |
|
51 |
|
52 // ============================ MEMBER FUNCTIONS =============================== |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CMRInfoPopup::NewL |
|
56 // Two-phased constructor. |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 CMRInfoPopup* CMRInfoPopup::NewL( |
|
60 CEikonEnv* aEnv, |
|
61 CMRMailboxUtils& aMBoxUtils, |
|
62 const CCalEntry& aEntry, |
|
63 TBool aViewMode ) |
|
64 { |
|
65 CMRInfoPopup* self = |
|
66 new( ELeave ) CMRInfoPopup( aEnv, aMBoxUtils, aViewMode ); |
|
67 |
|
68 CleanupStack::PushL( self ); |
|
69 self->ConstructL( aEntry ); |
|
70 CleanupStack::Pop(); |
|
71 |
|
72 return self; |
|
73 } |
|
74 |
|
75 // ----------------------------------------------------------------------------- |
|
76 // CMRInfoPopup::CMRInfoPopup |
|
77 // C++ default constructor can NOT contain any code, that |
|
78 // might leave. |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 CMRInfoPopup::CMRInfoPopup( |
|
82 CEikonEnv* aEnv, |
|
83 CMRMailboxUtils& aMBoxUtils, |
|
84 TBool aViewMode ) |
|
85 : iEnv( aEnv ), |
|
86 iMBoxUtils( aMBoxUtils ), |
|
87 iViewMode( aViewMode ), |
|
88 iIsValid( ETrue ), |
|
89 iIsSent( EFalse ), |
|
90 iRowIndex( 0 ) |
|
91 { |
|
92 } |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CMRInfoPopup::ConstructL |
|
96 // Symbian 2nd phase constructor can leave. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CMRInfoPopup::ConstructL( const CCalEntry& aEntry ) |
|
100 { |
|
101 iBuffer.CreateL( KBufferSize ); |
|
102 |
|
103 iStringFormatter = CMRStringFormatter::NewL( *iEnv ); |
|
104 |
|
105 iNoteController = CAknInfoPopupNoteController::NewL(); |
|
106 // no delay: |
|
107 iNoteController->SetTimeDelayBeforeShow( 0 ); |
|
108 // according to spec info popup is shown all the time in MR Viewers, |
|
109 // when we give KMaxMilliseconds it will be shown for ~35 hours: |
|
110 iNoteController->SetTimePopupInView( KMaxMilliseconds ); |
|
111 |
|
112 RefreshTextL( aEntry, 0 ); // row index 0 used at startup |
|
113 } |
|
114 |
|
115 // Destructor |
|
116 CMRInfoPopup::~CMRInfoPopup() |
|
117 { |
|
118 delete iStringFormatter; |
|
119 delete iNoteController; |
|
120 iBuffer.Close(); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CMRInfoPopup::ShowInfoPopupL |
|
125 // |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 void CMRInfoPopup::ShowInfoPopupL() |
|
129 { |
|
130 iNoteController->ShowInfoPopupNote(); |
|
131 } |
|
132 |
|
133 // ----------------------------------------------------------------------------- |
|
134 // CMRInfoPopup::HideInfoPopup |
|
135 // |
|
136 // ----------------------------------------------------------------------------- |
|
137 // |
|
138 void CMRInfoPopup::HideInfoPopup() |
|
139 { |
|
140 iNoteController->HideInfoPopupNote(); |
|
141 } |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CMRInfoPopup::SetMeetingValidity |
|
145 // |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 void CMRInfoPopup::SetMeetingValidity( TBool aIsValid ) |
|
149 { |
|
150 iIsValid = aIsValid; |
|
151 } |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // CMRInfoPopup::SetSendingStatus |
|
155 // |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CMRInfoPopup::SetSendingStatus( TBool aIsSent ) |
|
159 { |
|
160 iIsSent = aIsSent; |
|
161 } |
|
162 |
|
163 // ----------------------------------------------------------------------------- |
|
164 // CMRInfoPopup::RefreshTextL |
|
165 // |
|
166 // ----------------------------------------------------------------------------- |
|
167 // |
|
168 void CMRInfoPopup::RefreshTextL( const CCalEntry& aEntry, TInt aRowIndex ) |
|
169 { |
|
170 __ASSERT_DEBUG( aRowIndex == 0 || aRowIndex == 1, |
|
171 Panic( EIllegalParamValue ) ); |
|
172 |
|
173 iRowIndex = aRowIndex; |
|
174 // update data in iBuffer and in note controller, info popup may be |
|
175 // currently visible or not |
|
176 if ( iRowIndex == 0 ) |
|
177 { |
|
178 FillWithMeetingInfoL( aEntry ); |
|
179 } |
|
180 else |
|
181 { |
|
182 if ( iViewMode ) |
|
183 { |
|
184 FillWithViewerAttendeeInfoL( aEntry ); |
|
185 } |
|
186 else |
|
187 { |
|
188 FillWithEditorAttendeeInfoL( aEntry ); |
|
189 } |
|
190 } |
|
191 iNoteController->SetTextL( TextL() ); |
|
192 ShowInfoPopupL(); |
|
193 } |
|
194 |
|
195 const TDesC& CMRInfoPopup::TextL() |
|
196 { |
|
197 return iBuffer; |
|
198 } |
|
199 |
|
200 void CMRInfoPopup::FillWithMeetingInfoL( const CCalEntry& aEntry ) |
|
201 { |
|
202 iBuffer.Zero(); |
|
203 if ( MREntryConsultant::IsRepeatingMeetingL( aEntry ) ) |
|
204 { |
|
205 StringLoader::Load( iBuffer, R_QTN_CALE_INFOPOPUP_RECURRING, iEnv ); |
|
206 iBuffer.Append( EKeyLineFeed ); |
|
207 } |
|
208 |
|
209 HBufC* timeString( NULL ); |
|
210 // TODO: check day span this when UI spec is corrected |
|
211 // if ( MREntryConsultant::SpansManyDaysL( aEntry.StartTimeL(), |
|
212 // aEntry.EndTimeL() ) ) |
|
213 timeString = iStringFormatter->WhenStringLC( aEntry.StartTimeL(), |
|
214 aEntry.EndTimeL() ); |
|
215 iBuffer.Append( *timeString ); |
|
216 CleanupStack::PopAndDestroy( timeString ); |
|
217 } |
|
218 |
|
219 void CMRInfoPopup::FillWithViewerAttendeeInfoL( const CCalEntry& aEntry ) |
|
220 { |
|
221 iBuffer.Zero(); |
|
222 TInt resource( 0 ); |
|
223 CCalAttendee* thisAtt = iMBoxUtils.ThisAttendeeL( aEntry ); |
|
224 |
|
225 if ( aEntry.StatusL() == CCalEntry::ECancelled ) |
|
226 { |
|
227 resource = R_QTN_CALE_STATUS_CANCELLED; |
|
228 } |
|
229 else if ( MREntryConsultant::IsEntryOutOfDateL( aEntry ) || |
|
230 !iIsValid ) |
|
231 { |
|
232 resource = R_QTN_CALE_STATUS_OUT_OF_DATE; |
|
233 } |
|
234 else if ( thisAtt ) |
|
235 { |
|
236 switch ( thisAtt->StatusL() ) |
|
237 { |
|
238 case CCalAttendee::ENeedsAction: |
|
239 { |
|
240 resource = R_QTN_CALE_STATUS_PLEASE_RESPOND; |
|
241 break; |
|
242 } |
|
243 case CCalAttendee::EAccepted: // fall through |
|
244 case CCalAttendee::EConfirmed: |
|
245 { |
|
246 resource = R_QTN_CALE_STATUS_ACCEPTED; |
|
247 break; |
|
248 } |
|
249 case CCalAttendee::ETentative: |
|
250 { |
|
251 resource = R_QTN_CALE_STATUS_TENTATIVE; |
|
252 break; |
|
253 } |
|
254 case CCalAttendee::EDeclined: |
|
255 { |
|
256 resource = R_QTN_CALE_STATUS_DECLINED; |
|
257 break; |
|
258 } |
|
259 default: |
|
260 { |
|
261 break; |
|
262 } |
|
263 } |
|
264 } |
|
265 if ( resource != 0 ) |
|
266 { |
|
267 StringLoader::Load( iBuffer, resource, iEnv ); |
|
268 } |
|
269 } |
|
270 |
|
271 void CMRInfoPopup::FillWithEditorAttendeeInfoL( const CCalEntry& aEntry ) |
|
272 { |
|
273 iBuffer.Zero(); |
|
274 |
|
275 if ( iIsSent ) |
|
276 { |
|
277 RPointerArray<CCalAttendee>& attendees = aEntry.AttendeesL(); |
|
278 TInt count( attendees.Count() ); |
|
279 TInt countAccepted( 0 ); |
|
280 TInt countTentative( 0 ); |
|
281 TInt countDeclined( 0 ); |
|
282 TInt countNeedsAction( 0 ); |
|
283 for ( TInt i( 0 ); i < count; ++i ) |
|
284 { |
|
285 switch ( attendees[i]->StatusL() ) |
|
286 { |
|
287 case CCalAttendee::EAccepted: // fall through |
|
288 case CCalAttendee::EConfirmed: |
|
289 { |
|
290 countAccepted++; |
|
291 break; |
|
292 } |
|
293 case CCalAttendee::ETentative: |
|
294 { |
|
295 countTentative++; |
|
296 break; |
|
297 } |
|
298 case CCalAttendee::EDeclined: |
|
299 { |
|
300 countDeclined++; |
|
301 break; |
|
302 } |
|
303 case CCalAttendee::ENeedsAction: |
|
304 { |
|
305 countNeedsAction++; |
|
306 break; |
|
307 } |
|
308 default: |
|
309 { |
|
310 break; |
|
311 } |
|
312 } |
|
313 |
|
314 } |
|
315 if ( countAccepted > 0 ) |
|
316 { |
|
317 HBufC* accepts = StringLoader::LoadLC( |
|
318 R_QTN_CALE_INFOPOPUP_ACCEPTED, countAccepted, iEnv ); |
|
319 iBuffer.Append( *accepts ); |
|
320 CleanupStack::PopAndDestroy( accepts ); |
|
321 iBuffer.Append( EKeyLineFeed ); |
|
322 } |
|
323 if ( countDeclined > 0 ) |
|
324 { |
|
325 HBufC* declines = StringLoader::LoadLC( |
|
326 R_QTN_CALE_INFOPOPUP_DECLINED, countDeclined, iEnv ); |
|
327 iBuffer.Append( *declines ); |
|
328 CleanupStack::PopAndDestroy( declines ); |
|
329 iBuffer.Append( EKeyLineFeed ); |
|
330 } |
|
331 if ( countTentative > 0 ) |
|
332 { |
|
333 HBufC* tentatives = StringLoader::LoadLC( |
|
334 R_QTN_CALE_INFOPOPUP_TENTATIVE, countTentative, iEnv ); |
|
335 iBuffer.Append( *tentatives ); |
|
336 CleanupStack::PopAndDestroy( tentatives ); |
|
337 iBuffer.Append( EKeyLineFeed ); |
|
338 } |
|
339 if ( countNeedsAction > 0 ) |
|
340 { |
|
341 HBufC* noresponses = StringLoader::LoadLC( |
|
342 R_QTN_CALE_INFOPOPUP_NO_RESPONSE, countNeedsAction, iEnv ); |
|
343 iBuffer.Append( *noresponses ); |
|
344 CleanupStack::PopAndDestroy( noresponses ); |
|
345 iBuffer.Append( EKeyLineFeed ); |
|
346 } |
|
347 } |
|
348 else |
|
349 { |
|
350 StringLoader::Load( iBuffer, R_QTN_CALE_INFOPOPUP_NOT_SENT, iEnv ); |
|
351 } |
|
352 } |
|
353 |
|
354 |
|
355 // End of File |
|
356 |