|
1 /* |
|
2 * Copyright (c) 2002 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: |
|
15 * Adaptor to EventList, copies data from model listbox |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <eikenv.h> |
|
22 |
|
23 #include <Logs.rsg> |
|
24 #include <AknUtils.h> // AknTextUtils |
|
25 |
|
26 #include "CLogsCtAdapter.h" |
|
27 #include "MLogsSharedData.h" |
|
28 |
|
29 #include "MLogsCallStatus.h" |
|
30 |
|
31 // EXTERNAL DATA STRUCTURES |
|
32 |
|
33 // EXTERNAL FUNCTION PROTOTYPES |
|
34 |
|
35 // CONSTANTS |
|
36 _LIT(KFormat,"%02d%c%02d%c%02d"); |
|
37 _LIT(KActiveCallIcon,"0"); |
|
38 _LIT(KLastCallIcon,"1"); |
|
39 _LIT(KDialledCallIcon,"2"); |
|
40 _LIT(KReceivedCallIcon,"3"); |
|
41 _LIT(KAllCallIcon,"4"); |
|
42 _LIT(KTab,"\t"); |
|
43 const TInt KTimeLen = 20; //Same as in CCtControlContainer.cpp |
|
44 const TInt KMaxValueOfTheTimer = 359999; |
|
45 const TInt KCtAdapterMdcaCount = 4; |
|
46 _LIT(KPanicMsg,"CLogsCtAdapter"); |
|
47 // MACROS |
|
48 |
|
49 // LOCAL CONSTANTS AND MACROS |
|
50 |
|
51 // MODULE DATA STRUCTURES |
|
52 |
|
53 // LOCAL FUNCTION PROTOTYPES |
|
54 |
|
55 |
|
56 |
|
57 // ---------------------------------------------------------------------------- |
|
58 // LanguageConversionAndAppend |
|
59 // |
|
60 // Static |
|
61 // ---------------------------------------------------------------------------- |
|
62 // |
|
63 TInt LanguageConversionAndAppend( |
|
64 HBufC* aBuffer, |
|
65 TDes& aDestDes ) |
|
66 { |
|
67 TPtr ptr = aBuffer->Des(); |
|
68 |
|
69 AknTextUtils::LanguageSpecificNumberConversion(ptr); |
|
70 if( ptr.Length() > aDestDes.MaxLength() ) |
|
71 { |
|
72 aDestDes.Append( ptr.Left( aDestDes.MaxLength() ) ); |
|
73 return KErrOverflow; |
|
74 } |
|
75 aDestDes.Append( ptr ); |
|
76 return KErrNone; |
|
77 } |
|
78 |
|
79 // ================= MEMBER FUNCTIONS ======================= |
|
80 |
|
81 // ---------------------------------------------------------------------------- |
|
82 // CLogsCtAdapter::NewL |
|
83 // ---------------------------------------------------------------------------- |
|
84 // |
|
85 CLogsCtAdapter* CLogsCtAdapter::NewL( |
|
86 MLogsSharedData* aSharedData, |
|
87 const TAlsEnum& aSelectedAlsLine, |
|
88 MLogsCallStatus& aCallStatus ) |
|
89 { |
|
90 CLogsCtAdapter* self = new( ELeave ) |
|
91 CLogsCtAdapter( |
|
92 aSharedData, |
|
93 aSelectedAlsLine, |
|
94 aCallStatus); |
|
95 CleanupStack::PushL( self ); |
|
96 self->ConstructL(); |
|
97 CleanupStack::Pop(self); |
|
98 return self; |
|
99 } |
|
100 |
|
101 |
|
102 // ---------------------------------------------------------------------------- |
|
103 // CLogsCtAdapter::CLogsCtAdapter |
|
104 // ---------------------------------------------------------------------------- |
|
105 // |
|
106 CLogsCtAdapter::CLogsCtAdapter( |
|
107 MLogsSharedData* aSharedData, |
|
108 const TAlsEnum& aSelectedAlsLine, |
|
109 MLogsCallStatus& aCallStatus) : |
|
110 iSharedData( aSharedData ), |
|
111 iSelectedAlsLine( aSelectedAlsLine ), |
|
112 iCallStatus( aCallStatus ) |
|
113 { |
|
114 } |
|
115 |
|
116 |
|
117 // ---------------------------------------------------------------------------- |
|
118 // CLogsCtAdapter::ConstructL |
|
119 // ---------------------------------------------------------------------------- |
|
120 // |
|
121 void CLogsCtAdapter::ConstructL() |
|
122 { |
|
123 CEikonEnv* env = CEikonEnv::Static(); |
|
124 |
|
125 iActiveCallText = env->AllocReadResourceL( R_AOCCT_ACTIVE_CALL_TIMER_TEXT ); |
|
126 iLastCallText = env->AllocReadResourceL( R_AOCCT_LAST_CALL_TIMER_TEXT ); |
|
127 iDialledCallsText = env->AllocReadResourceL( R_AOCCT_DIALLED_CALLS_TIMER_TEXT ); |
|
128 iReceivedCallsText = env->AllocReadResourceL( R_AOCCT_RECEIVED_CALLS_TIMER_TEXT ); |
|
129 iAllCallsText = env->AllocReadResourceL( R_AOCCT_ALL_CALLS_TIMER_TEXT ); |
|
130 iActiveCallTime = HBufC::NewL (KTimeLen); |
|
131 iLastCallTime = HBufC::NewL (KTimeLen); |
|
132 iDialledCallsTime = HBufC::NewL (KTimeLen); |
|
133 iReceivedCallsTime = HBufC::NewL (KTimeLen); |
|
134 iAllCallsTime = HBufC::NewL (KTimeLen); |
|
135 |
|
136 //These need to have non-zero initial values |
|
137 iPreviousActiveTime = KErrNotFound; |
|
138 iPreviousAllCallsTime = KErrNotFound; |
|
139 |
|
140 //Local variation setting for showing/not showing active call duration |
|
141 iShowCallDurationLogs = iSharedData->ShowCallDurationLogsL(); |
|
142 } |
|
143 |
|
144 |
|
145 // ---------------------------------------------------------------------------- |
|
146 // CLogsCtAdapter::~CLogsCtAdapter |
|
147 // ---------------------------------------------------------------------------- |
|
148 // |
|
149 CLogsCtAdapter::~CLogsCtAdapter() |
|
150 { |
|
151 delete iActiveCallText; |
|
152 delete iLastCallText; |
|
153 delete iDialledCallsText; |
|
154 delete iReceivedCallsText; |
|
155 delete iAllCallsText; |
|
156 delete iActiveCallTime; |
|
157 delete iLastCallTime; |
|
158 delete iDialledCallsTime; |
|
159 delete iReceivedCallsTime; |
|
160 delete iAllCallsTime; |
|
161 |
|
162 } |
|
163 |
|
164 |
|
165 // ---------------------------------------------------------------------------- |
|
166 // CLogsCtAdapter::MdcaCount |
|
167 // ---------------------------------------------------------------------------- |
|
168 // |
|
169 TInt CLogsCtAdapter::MdcaCount () const |
|
170 { |
|
171 return KCtAdapterMdcaCount; |
|
172 } |
|
173 |
|
174 |
|
175 // ---------------------------------------------------------------------------- |
|
176 // CLogsCtAdapter::MdcaPoint |
|
177 // ---------------------------------------------------------------------------- |
|
178 // |
|
179 TPtrC16 CLogsCtAdapter::MdcaPoint( TInt aIndex ) const |
|
180 { |
|
181 TDes& des = CONST_CAST( TBuf<KLogsCtAdapterLen>&, |
|
182 iBuffer ); |
|
183 des.Zero(); |
|
184 switch( aIndex ) |
|
185 { // "0\tFirstLine\tSecondLine" |
|
186 case 0: |
|
187 { |
|
188 TBool activeCall( EFalse ); |
|
189 iCallStatus.CallIsActive( activeCall ); |
|
190 |
|
191 //Local variation / active call duration: |
|
192 //Show active call duration only if active call is ongoing and we are also requested to |
|
193 // show the active call duration. Otherwise we show only the last ended call's duration |
|
194 // also in cases in which we are in midst of one or more active call. |
|
195 if( activeCall && iShowCallDurationLogs ) |
|
196 { // Call is active and we are requested to show active call duration |
|
197 des.Append( KActiveCallIcon ); |
|
198 des.Append( KTab ); |
|
199 des.Append( *iActiveCallText ); |
|
200 des.Append( KTab ); |
|
201 LanguageConversionAndAppend( iActiveCallTime, des ); |
|
202 } |
|
203 else |
|
204 { |
|
205 des.Append( KLastCallIcon ); |
|
206 des.Append( KTab ); |
|
207 des.Append( *iLastCallText ); |
|
208 des.Append( KTab ); |
|
209 LanguageConversionAndAppend( iLastCallTime, des ); |
|
210 } |
|
211 break; |
|
212 } |
|
213 case 1: |
|
214 des.Append( KDialledCallIcon ); |
|
215 des.Append( KTab ); |
|
216 des.Append( *iDialledCallsText ); |
|
217 des.Append( KTab ); |
|
218 LanguageConversionAndAppend( iDialledCallsTime, des ); |
|
219 break; |
|
220 case 2: |
|
221 des.Append( KReceivedCallIcon ); |
|
222 des.Append( KTab ); |
|
223 des.Append( *iReceivedCallsText ); |
|
224 des.Append( KTab ); |
|
225 LanguageConversionAndAppend( iReceivedCallsTime, des ); |
|
226 break; |
|
227 case 3: |
|
228 des.Append( KAllCallIcon ); |
|
229 des.Append( KTab ); |
|
230 des.Append( *iAllCallsText ); |
|
231 des.Append( KTab ); |
|
232 LanguageConversionAndAppend( iAllCallsTime, des ); |
|
233 break; |
|
234 default: |
|
235 User::Panic(KPanicMsg, KErrCorrupt); |
|
236 break; |
|
237 } |
|
238 |
|
239 return iBuffer; |
|
240 } |
|
241 |
|
242 // ---------------------------------------------------------------------------- |
|
243 // CLogsCtAdapter::UpdateDataL |
|
244 // ---------------------------------------------------------------------------- |
|
245 // |
|
246 TBool CLogsCtAdapter::UpdateDataL() |
|
247 { |
|
248 TBool retVal = ETrue; //By default indicate that a timer value has changed |
|
249 |
|
250 TInt activeTime( ActiveTime() ); //Note! This retrieves only cellular call duration |
|
251 TInt allCallstime( iSharedData->AllCallsTimer( iSelectedAlsLine, EVoipIncluded) ); |
|
252 |
|
253 //Format time to time strings |
|
254 ToTimeFormat( activeTime, iActiveCallTime ); //Duration of active on-going call. NOTE! Only voice call supported |
|
255 // as we don't get anywhere information of ongoing voip call status. |
|
256 |
|
257 ToTimeFormat( iSharedData->LastCallTimer( //Duration of last already ended call (voice or voip) |
|
258 iSelectedAlsLine, EVoipIncluded ), iLastCallTime ); |
|
259 ToTimeFormat( iSharedData->DialledCallsTimer( |
|
260 iSelectedAlsLine, EVoipIncluded ), iDialledCallsTime ); |
|
261 ToTimeFormat( iSharedData->ReceivedCallsTimer( |
|
262 iSelectedAlsLine, EVoipIncluded ), iReceivedCallsTime ); |
|
263 ToTimeFormat( allCallstime, iAllCallsTime ); |
|
264 |
|
265 //Check has any value changed. If active or all calls time has changed from previous call, |
|
266 // then return true, otherwise false. KErrNotFound needed as initial values of members. |
|
267 if( activeTime == iPreviousActiveTime && allCallstime == iPreviousAllCallsTime ) |
|
268 { |
|
269 retVal = EFalse; //No value has changed after previous call of this function. |
|
270 } |
|
271 |
|
272 iPreviousActiveTime = activeTime; |
|
273 iPreviousAllCallsTime = allCallstime; |
|
274 return retVal; |
|
275 } |
|
276 |
|
277 TInt CLogsCtAdapter::ActiveTime() |
|
278 { |
|
279 TTimeIntervalSeconds secondsInterval; |
|
280 if( iCallStatus.ActiveCallDuration( secondsInterval ) ) //This retrieves only cellular call duration, see |
|
281 { // CLogsCallStatus in CLogsMMECallStatus.cpp |
|
282 return 0; |
|
283 } |
|
284 return secondsInterval.Int(); |
|
285 } |
|
286 |
|
287 // ---------------------------------------------------------------------------- |
|
288 // CLogsCtAdapter::ToTimeFormat |
|
289 // |
|
290 // Converts seconds to proper time format |
|
291 // ---------------------------------------------------------------------------- |
|
292 // |
|
293 void CLogsCtAdapter::ToTimeFormat( |
|
294 TInt aSeconds, |
|
295 HBufC* aText ) |
|
296 { |
|
297 TLocale locale; |
|
298 |
|
299 if( aSeconds > KMaxValueOfTheTimer ) |
|
300 { |
|
301 TInt HowManyTimes( aSeconds / KMaxValueOfTheTimer ); |
|
302 aSeconds = aSeconds - HowManyTimes * KMaxValueOfTheTimer; |
|
303 } |
|
304 |
|
305 TInt seconds( aSeconds % 60 ); |
|
306 TInt hours( aSeconds / 3600 ); |
|
307 TInt minutes( ( aSeconds - hours * 3600 ) / 60 ); |
|
308 TInt hoursSeparator = locale.TimeSeparator( 1 ); |
|
309 TInt minuteSeparator = locale.TimeSeparator( 2 ); |
|
310 |
|
311 /// Localization of the time |
|
312 TPtr ptr = aText->Des(); |
|
313 |
|
314 ptr.Format( KFormat, hours, hoursSeparator, minutes, minuteSeparator, seconds ); |
|
315 |
|
316 } |
|
317 |
|
318 |
|
319 // ---------------------------------------------------------------------------- |
|
320 // CLogsCtAdapter::LastCallTimeStringL |
|
321 // |
|
322 // Functions to provide formatted call time strings for container (called from CCtControlContainer) |
|
323 // No need to call UpdateDataL() to get up-to-date values |
|
324 // ---------------------------------------------------------------------------- |
|
325 // |
|
326 TInt CLogsCtAdapter::LastCallTimeStringL( |
|
327 TDes& aDes, |
|
328 const TAlsEnum& aSelectedLine, |
|
329 const TVoipEnum aVoip ) |
|
330 { |
|
331 HBufC* buf = HBufC::NewLC( KTimeLen ); |
|
332 ToTimeFormat( iSharedData->LastCallTimer( aSelectedLine, aVoip ), buf ); //Duration of last already ended call. |
|
333 TInt ret = LanguageConversionAndAppend( buf, aDes ); |
|
334 CleanupStack::PopAndDestroy( buf ); |
|
335 return ret; |
|
336 } |
|
337 |
|
338 // ---------------------------------------------------------------------------- |
|
339 // CLogsCtAdapter::ReceivedCallsTimeStringL |
|
340 // ---------------------------------------------------------------------------- |
|
341 // |
|
342 TInt CLogsCtAdapter::ReceivedCallsTimeStringL( |
|
343 TDes& aDes, |
|
344 const TAlsEnum& aSelectedLine, |
|
345 const TVoipEnum aVoip ) |
|
346 { |
|
347 HBufC* buf = HBufC::NewLC( KTimeLen ); |
|
348 ToTimeFormat( iSharedData->ReceivedCallsTimer( aSelectedLine, aVoip ), buf ); |
|
349 TInt ret = LanguageConversionAndAppend( buf, aDes ); |
|
350 CleanupStack::PopAndDestroy( buf ); |
|
351 return ret; |
|
352 } |
|
353 |
|
354 // ---------------------------------------------------------------------------- |
|
355 // CLogsCtAdapter::DialledCallsTimeStringL |
|
356 // ---------------------------------------------------------------------------- |
|
357 // |
|
358 TInt CLogsCtAdapter::DialledCallsTimeStringL( |
|
359 TDes& aDes, |
|
360 const TAlsEnum& aSelectedLine, |
|
361 const TVoipEnum aVoip ) |
|
362 { |
|
363 HBufC* buf = HBufC::NewLC( KTimeLen ); |
|
364 ToTimeFormat( iSharedData->DialledCallsTimer( aSelectedLine, aVoip ), buf ); |
|
365 TInt ret = LanguageConversionAndAppend( buf, aDes ); |
|
366 CleanupStack::PopAndDestroy( buf ); |
|
367 return ret; |
|
368 } |
|
369 |
|
370 // ---------------------------------------------------------------------------- |
|
371 // CLogsCtAdapter::AllCallsTimeStringL |
|
372 // ---------------------------------------------------------------------------- |
|
373 // |
|
374 TInt CLogsCtAdapter::AllCallsTimeStringL( |
|
375 TDes& aDes, |
|
376 const TAlsEnum& aSelectedLine, |
|
377 const TVoipEnum aVoip ) |
|
378 { |
|
379 HBufC* buf = HBufC::NewLC( KTimeLen ); |
|
380 ToTimeFormat( iSharedData->AllCallsTimer( aSelectedLine, aVoip ), buf ); |
|
381 TInt ret = LanguageConversionAndAppend( buf, aDes ); |
|
382 CleanupStack::PopAndDestroy( buf ); |
|
383 return ret; |
|
384 } |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 // End of File |