|
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: ESMR Conflict popup implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "emailtrace.h" |
|
19 #include "cesmrconflictpopup.h" |
|
20 |
|
21 #include <AknInfoPopupNoteController.h> |
|
22 #include <StringLoader.h> |
|
23 #include <eikenv.h> |
|
24 |
|
25 #include "cesmrlayoutmgr.h" |
|
26 #include "mesmrcalentry.h" |
|
27 #include "mesmrmeetingrequestentry.h" |
|
28 #include <esmrgui.rsg> |
|
29 #include <avkon.rsg> |
|
30 |
|
31 // Unnamed namespace for local definitions |
|
32 namespace{ |
|
33 |
|
34 const TInt KTimeDelayBeforeShow(2000); // 2 Seconds |
|
35 const TInt KTimeForView(5000); // 5 Seconds |
|
36 const TInt KZero(0); |
|
37 const TInt KTimeStringLength(20); |
|
38 const TInt KMaxSummaryLength(25); |
|
39 |
|
40 _LIT( KNewLine, "\n"); |
|
41 _LIT( KMessageStart, "("); |
|
42 _LIT( KMessageEnd, ")"); |
|
43 _LIT( KStringCont, "...\n"); |
|
44 _LIT (KSpace , " " ); |
|
45 const TInt KFullTimeStringSize(256); |
|
46 |
|
47 }//namespace |
|
48 |
|
49 // ======== MEMBER FUNCTIONS ======== |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CESMRConflictPopup::NewL |
|
53 // --------------------------------------------------------------------------- |
|
54 // |
|
55 CESMRConflictPopup* CESMRConflictPopup::NewL( MESMRCalEntry& aEntry) |
|
56 { |
|
57 FUNC_LOG; |
|
58 CESMRConflictPopup* self = new (ELeave) CESMRConflictPopup(); |
|
59 CleanupStack::PushL( self ); |
|
60 self->ConstructL(aEntry); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 // --------------------------------------------------------------------------- |
|
66 // CESMRConflictPopup::CESMRConflictPopup |
|
67 // --------------------------------------------------------------------------- |
|
68 // |
|
69 CESMRConflictPopup::CESMRConflictPopup() |
|
70 { |
|
71 FUNC_LOG; |
|
72 //do nothing |
|
73 } |
|
74 |
|
75 // --------------------------------------------------------------------------- |
|
76 // CESMRConflictPopup::~CESMRConflictPopup |
|
77 // --------------------------------------------------------------------------- |
|
78 // |
|
79 CESMRConflictPopup::~CESMRConflictPopup() |
|
80 { |
|
81 FUNC_LOG; |
|
82 delete iNote; |
|
83 } |
|
84 |
|
85 // --------------------------------------------------------------------------- |
|
86 // CESMRConflictPopup::ConstructL |
|
87 // --------------------------------------------------------------------------- |
|
88 // |
|
89 void CESMRConflictPopup::ConstructL(MESMRCalEntry& aEntry) |
|
90 { |
|
91 FUNC_LOG; |
|
92 if ( MESMRCalEntry::EESMRCalEntryMeetingRequest == aEntry.Type() ) |
|
93 { |
|
94 iEntry = static_cast<MESMRMeetingRequestEntry*>(&aEntry); |
|
95 } |
|
96 else |
|
97 { |
|
98 User::Leave( KErrNotSupported ); |
|
99 } |
|
100 |
|
101 iNote = CAknInfoPopupNoteController::NewL(); |
|
102 |
|
103 InitializeL(); |
|
104 |
|
105 } |
|
106 |
|
107 // --------------------------------------------------------------------------- |
|
108 // CESMRConflictPopup::PrepareDisplayStringL |
|
109 // --------------------------------------------------------------------------- |
|
110 // |
|
111 void CESMRConflictPopup::PrepareDisplayStringL() |
|
112 { |
|
113 FUNC_LOG; |
|
114 RPointerArray<CCalEntry> entryArray; |
|
115 CleanupClosePushL( entryArray ); |
|
116 TInt ret = iEntry->FetchConflictingEntriesL( entryArray ); |
|
117 if( ret == KErrNotFound ) |
|
118 { |
|
119 User::Leave( KErrNotFound ); |
|
120 } |
|
121 |
|
122 TInt numEnteries = entryArray.Count(); |
|
123 TInt dispStrLength(KZero); |
|
124 TBuf <KFullTimeStringSize> meetingTitle ; |
|
125 TBuf <KFullTimeStringSize> meetingLocation ; |
|
126 TTime startTime ; |
|
127 TTime endTime ; |
|
128 |
|
129 if (numEnteries != KZero) |
|
130 {// there is atleast one entry |
|
131 // get the first conflicting entry and set the string for display |
|
132 meetingTitle = entryArray[KZero]->SummaryL(); |
|
133 meetingLocation = entryArray[KZero]->LocationL(); |
|
134 dispStrLength = meetingTitle.Length() + meetingLocation.Length(); |
|
135 startTime = entryArray[KZero]->StartTimeL().TimeLocalL(); |
|
136 endTime = entryArray[KZero]->EndTimeL().TimeLocalL(); |
|
137 } |
|
138 |
|
139 HBufC* stringHolder = |
|
140 StringLoader::LoadLC(R_QTN_MEET_REQ_CONFLICTS_WITH_LABEL); |
|
141 dispStrLength = stringHolder->Length() + meetingTitle.Length() |
|
142 + meetingLocation.Length() + KFullTimeStringSize; |
|
143 |
|
144 HBufC* timeFormatString = CCoeEnv::Static()->AllocReadResourceLC(R_QTN_TIME_USUAL_WITH_ZERO); |
|
145 |
|
146 TBuf<KTimeStringLength> startBuf; |
|
147 TBuf<KTimeStringLength> endBuf; |
|
148 |
|
149 startTime.FormatL( startBuf, *timeFormatString ); |
|
150 endTime.FormatL( endBuf, *timeFormatString ); |
|
151 |
|
152 CDesCArrayFlat* strings = new(ELeave) CDesCArrayFlat( 2 ); |
|
153 CleanupStack::PushL( strings ); |
|
154 strings->AppendL( startBuf ); //First string |
|
155 strings->AppendL( endBuf ); //Second string |
|
156 |
|
157 HBufC* finalTimeBuf = |
|
158 StringLoader::LoadL( |
|
159 R_QTN_MEET_REQ_TIME_SEPARATOR, |
|
160 *strings, |
|
161 CEikonEnv::Static() ); // codescanner::eikonenvstatic |
|
162 CleanupStack::PopAndDestroy( strings ); |
|
163 CleanupStack::PushL( finalTimeBuf ); |
|
164 |
|
165 HBufC* displayString = HBufC::NewLC(dispStrLength); |
|
166 displayString->Des().Append(stringHolder->Des()); |
|
167 displayString->Des().Append(KNewLine); |
|
168 displayString->Des().Append(finalTimeBuf->Des()); |
|
169 |
|
170 |
|
171 displayString->Des().Append(KMessageStart); |
|
172 // Check the length of meetingTitle |
|
173 // If its greater than some KMaxSummaryLength value then |
|
174 // truncate to some reasonable value & append KStringCont |
|
175 if ( meetingTitle.Length() > KMaxSummaryLength ) |
|
176 { |
|
177 displayString->Des().Append(meetingTitle.Ptr(),KMaxSummaryLength); |
|
178 displayString->Des().Append(KStringCont); |
|
179 } |
|
180 else |
|
181 { |
|
182 displayString->Des().Append(meetingTitle); |
|
183 displayString->Des().Append(KSpace); |
|
184 } |
|
185 |
|
186 displayString->Des().Append(meetingLocation); |
|
187 displayString->Des().Append(KMessageEnd); |
|
188 |
|
189 iNote->SetTextL(displayString->Des() ); |
|
190 |
|
191 CleanupStack::PopAndDestroy( displayString ); |
|
192 CleanupStack::PopAndDestroy( finalTimeBuf ); |
|
193 CleanupStack::PopAndDestroy( timeFormatString ); |
|
194 CleanupStack::PopAndDestroy( stringHolder ); |
|
195 CleanupStack::PopAndDestroy( &entryArray ); |
|
196 } |
|
197 |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CESMRConflictPopup::ShowPopup |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CESMRConflictPopup::ShowPopup() |
|
204 { |
|
205 FUNC_LOG; |
|
206 TRAPD( error, PrepareDisplayStringL()); |
|
207 if ( error != KErrNone ) |
|
208 { |
|
209 CEikonEnv::Static()-> // codescanner::eikonenvstatic |
|
210 HandleError(error); |
|
211 } |
|
212 iNote->SetPositionAndAlignment( CESMRLayoutManager::ConflictPopupPosition(), |
|
213 EHLeftVCenter ); |
|
214 iNote->ShowInfoPopupNote(); |
|
215 } |
|
216 |
|
217 |
|
218 // --------------------------------------------------------------------------- |
|
219 // CESMRConflictPopup::InitializeL |
|
220 // --------------------------------------------------------------------------- |
|
221 // |
|
222 void CESMRConflictPopup::InitializeL() |
|
223 { |
|
224 FUNC_LOG; |
|
225 iNote->SetTimeDelayBeforeShow(KTimeDelayBeforeShow); // 2 Seconds |
|
226 iNote->SetTimePopupInView(KTimeForView); // 5 Seconds |
|
227 } |
|
228 |
|
229 // EOF |
|
230 |