|
1 /* |
|
2 * Copyright (c) 2008 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: Customization manager |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "BMDefaultManager.h" |
|
19 #include "BMBubbleImageManager.h" |
|
20 #include "BMBubbleHeader.h" |
|
21 #include "BMCallStatusIndiBig.h" |
|
22 #include "BMCallStatusIndiSmall.h" |
|
23 #include "BMCallStatusAnimBig.h" |
|
24 #include "BMCallStatusAnimSmall.h" |
|
25 #include "BMNumberTypeIcon.h" |
|
26 #include "BMPanic.h" |
|
27 #include <telbubblecallimage.h> |
|
28 |
|
29 // max amounts per type |
|
30 const TInt KBubbleMaxCallStatusIndiBig = 2; |
|
31 const TInt KBubbleMaxCallStatusIndiSmall = 7; |
|
32 const TInt KBubbleMaxCallStatusAnimBig = 2; |
|
33 const TInt KBubbleMaxCallStatusAnimSmall = 1; |
|
34 const TInt KBubbleMaxNumberTypeIcon = 2; |
|
35 const TInt KBubbleMaxCallerImageDrawer = 1; |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // C++ constructor |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CBubbleDefaultManager::CBubbleDefaultManager( CBubbleManager& aBubbleManager ) |
|
42 : iBubbleManager( aBubbleManager ) |
|
43 { |
|
44 } |
|
45 |
|
46 |
|
47 // --------------------------------------------------------------------------- |
|
48 // ConstructL |
|
49 // --------------------------------------------------------------------------- |
|
50 // |
|
51 void CBubbleDefaultManager::ConstructL() |
|
52 { |
|
53 iMaxAmounts.Append( KBubbleMaxCallStatusIndiBig ); |
|
54 iMaxAmounts.Append( KBubbleMaxCallStatusIndiSmall ); |
|
55 iMaxAmounts.Append( KBubbleMaxCallStatusAnimBig ); |
|
56 iMaxAmounts.Append( KBubbleMaxCallStatusAnimSmall ); |
|
57 iMaxAmounts.Append( KBubbleMaxNumberTypeIcon ); |
|
58 iMaxAmounts.Append( KBubbleMaxCallerImageDrawer ); |
|
59 |
|
60 const TInt kDifferentElements = iMaxAmounts.Count(); |
|
61 |
|
62 for ( TInt i = 0 ; i < kDifferentElements ; i++ ) |
|
63 { |
|
64 iAvailabilities.Append( 0 ); |
|
65 } |
|
66 |
|
67 // Create main array |
|
68 iElements = new( ELeave ) |
|
69 CArrayPtrFlat<CSingleElement>( kDifferentElements ); |
|
70 iElements->SetReserveL( kDifferentElements ); |
|
71 |
|
72 // Create arrays inside the main array and add them to the main array |
|
73 TInt resource = 0; |
|
74 for ( resource = 0 ; resource < kDifferentElements ; resource++ ) |
|
75 { |
|
76 CSingleElement* single = new( ELeave ) |
|
77 CSingleElement( iMaxAmounts[resource] ); |
|
78 CleanupStack::PushL( single ); |
|
79 single->SetReserveL( iMaxAmounts[resource] ); |
|
80 iElements->AppendL( single ); |
|
81 CleanupStack::Pop( single ); |
|
82 } |
|
83 |
|
84 // Create implementations to individual arrays: |
|
85 for ( resource = 0 ; resource < kDifferentElements ; resource++ ) |
|
86 { |
|
87 TInt maxCellAmount = iMaxAmounts[resource]; |
|
88 CSingleElement* single = iElements->At( resource ); |
|
89 switch( resource ) |
|
90 { |
|
91 case EBMDefaultCallStatusIndiBig: |
|
92 { |
|
93 for ( TInt i = 0 ; i < maxCellAmount ; i++ ) |
|
94 { |
|
95 CBubbleCallStatusIndiBig* indiControl = |
|
96 CBubbleCallStatusIndiBig::NewL( |
|
97 iBubbleManager.ImageManager() ); |
|
98 CleanupStack::PushL( indiControl ); |
|
99 indiControl->SetContainerWindowL( iBubbleManager ); |
|
100 indiControl->SetParent( &iBubbleManager ); |
|
101 CTelBubbleCustomElement* indiElem = |
|
102 CTelBubbleCustomElement::NewL( indiControl, |
|
103 CTelBubbleCustomElement::EBigCallIndicator ); |
|
104 CleanupStack::PushL( indiElem ); |
|
105 single->AppendL( indiElem ); |
|
106 CleanupStack::Pop(2,indiControl); |
|
107 } |
|
108 break; |
|
109 } |
|
110 |
|
111 case EBMDefaultCallStatusIndiSmall: |
|
112 { |
|
113 for ( TInt i = 0 ; i < maxCellAmount ; i++ ) |
|
114 { |
|
115 CBubbleCallStatusIndiSmall* indiControl = |
|
116 CBubbleCallStatusIndiSmall::NewL( |
|
117 iBubbleManager.ImageManager() ); |
|
118 CleanupStack::PushL( indiControl ); |
|
119 indiControl->SetContainerWindowL( iBubbleManager ); |
|
120 indiControl->SetParent( &iBubbleManager ); |
|
121 CTelBubbleCustomElement* indiElem = |
|
122 CTelBubbleCustomElement::NewL( indiControl, |
|
123 CTelBubbleCustomElement::ESmallCallIndicator ); |
|
124 CleanupStack::PushL( indiElem ); |
|
125 single->AppendL( indiElem ); |
|
126 CleanupStack::Pop(2,indiControl); |
|
127 } |
|
128 break; |
|
129 } |
|
130 |
|
131 case EBMDefaultCallStatusAnimBig: |
|
132 { |
|
133 for ( TInt i = 0 ; i < maxCellAmount ; i++ ) |
|
134 { |
|
135 CBubbleCallStatusAnimBig* animControl = |
|
136 CBubbleCallStatusAnimBig::NewL( |
|
137 iBubbleManager.ImageManager() ); |
|
138 CleanupStack::PushL( animControl ); |
|
139 animControl->SetContainerWindowL( iBubbleManager ); |
|
140 animControl->SetParent( &iBubbleManager ); |
|
141 CTelBubbleCustomElement* animElem = |
|
142 CTelBubbleCustomElement::NewL( animControl, |
|
143 CTelBubbleCustomElement::EBigCallIndicator ); |
|
144 CleanupStack::PushL( animElem ); |
|
145 single->AppendL( animElem ); |
|
146 CleanupStack::Pop(2,animControl); |
|
147 } |
|
148 break; |
|
149 } |
|
150 |
|
151 case EBMDefaultCallStatusAnimSmall: |
|
152 { |
|
153 for ( TInt i = 0 ; i < maxCellAmount ; i++ ) |
|
154 { |
|
155 CBubbleCallStatusAnimSmall* animControl = |
|
156 CBubbleCallStatusAnimSmall::NewL( |
|
157 iBubbleManager.ImageManager() ); |
|
158 CleanupStack::PushL( animControl ); |
|
159 animControl->SetContainerWindowL( iBubbleManager ); |
|
160 animControl->SetParent( &iBubbleManager ); |
|
161 CTelBubbleCustomElement* animElem = |
|
162 CTelBubbleCustomElement::NewL( animControl, |
|
163 CTelBubbleCustomElement::ESmallCallIndicator ); |
|
164 CleanupStack::PushL( animElem ); |
|
165 single->AppendL( animElem ); |
|
166 CleanupStack::Pop(2,animControl); |
|
167 } |
|
168 break; |
|
169 } |
|
170 |
|
171 case EBMDefaultNumberTypeIcon: |
|
172 { |
|
173 for ( TInt i = 0 ; i < maxCellAmount ; i++ ) |
|
174 { |
|
175 CBubbleNumberTypeIcon* numberTypeIcon = |
|
176 CBubbleNumberTypeIcon::NewL( |
|
177 iBubbleManager.ImageManager() ); |
|
178 CleanupStack::PushL( numberTypeIcon ); |
|
179 numberTypeIcon->SetContainerWindowL( iBubbleManager ); |
|
180 numberTypeIcon->SetParent( &iBubbleManager ); |
|
181 CTelBubbleCustomElement* numberTypeIconElem = |
|
182 CTelBubbleCustomElement::NewL( numberTypeIcon, |
|
183 CTelBubbleCustomElement::EBigCallIndicator ); |
|
184 CleanupStack::PushL( numberTypeIconElem ); |
|
185 single->AppendL( numberTypeIconElem ); |
|
186 CleanupStack::Pop( 2, numberTypeIcon ); |
|
187 } |
|
188 break; |
|
189 } |
|
190 |
|
191 case EBMDefaultCallImageControl: |
|
192 { |
|
193 for ( TInt i = 0 ; i < maxCellAmount ; i++ ) |
|
194 { |
|
195 CTelBubbleCallImage* image = |
|
196 CTelBubbleCallImage::NewL(); |
|
197 CleanupStack::PushL( image ); |
|
198 image->SetContainerWindowL( iBubbleManager ); |
|
199 image->SetParent( &iBubbleManager ); |
|
200 CTelBubbleCustomElement* imageElem = |
|
201 CTelBubbleCustomElement::NewL( image, |
|
202 CTelBubbleCustomElement::ECallImage ); |
|
203 CleanupStack::PushL( imageElem ); |
|
204 single->AppendL( imageElem ); |
|
205 CleanupStack::Pop(2,image); |
|
206 } |
|
207 break; |
|
208 } |
|
209 |
|
210 default: |
|
211 Panic( EBMPanicUnhandledSwitchCase ); |
|
212 } |
|
213 } |
|
214 } |
|
215 |
|
216 // --------------------------------------------------------------------------- |
|
217 // NewL |
|
218 // --------------------------------------------------------------------------- |
|
219 // |
|
220 CBubbleDefaultManager* CBubbleDefaultManager::NewL( |
|
221 CBubbleManager& aBubbleManager ) |
|
222 { |
|
223 CBubbleDefaultManager* self = |
|
224 new( ELeave ) CBubbleDefaultManager( aBubbleManager ); |
|
225 CleanupStack::PushL( self ); |
|
226 self->ConstructL(); |
|
227 CleanupStack::Pop( self ); |
|
228 return self; |
|
229 } |
|
230 |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // Destructor |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 CBubbleDefaultManager::~CBubbleDefaultManager() |
|
237 { |
|
238 if ( iElements ) |
|
239 { |
|
240 for ( TInt i = 0 ; i < iElements->Count() ; i++ ) |
|
241 { |
|
242 if ( iElements->At( i ) ) |
|
243 { |
|
244 iElements->At( i )->ResetAndDestroy(); |
|
245 } |
|
246 } |
|
247 iElements->ResetAndDestroy(); |
|
248 delete iElements; |
|
249 } |
|
250 |
|
251 iAvailabilities.Close(); |
|
252 iMaxAmounts.Close(); |
|
253 } |
|
254 |
|
255 // --------------------------------------------------------------------------- |
|
256 // ReserveCallIndicatorElement |
|
257 // --------------------------------------------------------------------------- |
|
258 // |
|
259 CTelBubbleCustomElement* CBubbleDefaultManager::ReserveBigCallIndicatorElement( |
|
260 const CBubbleHeader& aHeader ) |
|
261 { |
|
262 CTelBubbleCustomElement* element; |
|
263 CBubbleManager::TPhoneCallState state = aHeader.CallState(); |
|
264 |
|
265 if ( state == CBubbleManager::EOutgoing || |
|
266 state == CBubbleManager::EAlertToDisconnected ) |
|
267 { |
|
268 // Image |
|
269 element = ReserveElement( EBMDefaultCallStatusIndiBig ); |
|
270 CBubbleCallStatusIndi* indi = |
|
271 static_cast<CBubbleCallStatusIndi*> ( element->Control() ); |
|
272 indi->ReadBubbleHeader( aHeader ); |
|
273 } |
|
274 else |
|
275 { |
|
276 // Animation |
|
277 element = ReserveElement( EBMDefaultCallStatusAnimBig ); |
|
278 CBubbleCallStatusAnim* anim = |
|
279 static_cast<CBubbleCallStatusAnim*> ( element->Control() ); |
|
280 anim->ReadBubbleHeader( aHeader ); |
|
281 } |
|
282 |
|
283 return element; |
|
284 } |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // ReserveSmallCallIndicatorElement |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 CTelBubbleCustomElement* CBubbleDefaultManager::ReserveSmallCallIndicatorElement( |
|
291 const CBubbleHeader& aHeader ) |
|
292 { |
|
293 CTelBubbleCustomElement* element; |
|
294 CBubbleManager::TPhoneCallState state = aHeader.CallState(); |
|
295 |
|
296 if( state == CBubbleManager::EOutgoing || |
|
297 state == CBubbleManager::EWaiting || |
|
298 state == CBubbleManager::EAlerting ) |
|
299 { |
|
300 // Show animation |
|
301 element = ReserveElement( EBMDefaultCallStatusAnimSmall ); |
|
302 CBubbleCallStatusAnim* anim = |
|
303 static_cast<CBubbleCallStatusAnim*> ( element->Control() ); |
|
304 anim->ReadBubbleHeader( aHeader ); |
|
305 } |
|
306 else |
|
307 { |
|
308 // Show image |
|
309 element = ReserveElement( EBMDefaultCallStatusIndiSmall ); |
|
310 CBubbleCallStatusIndi* indi = |
|
311 static_cast<CBubbleCallStatusIndi*> ( element->Control() ); |
|
312 indi->ReadBubbleHeader( aHeader ); |
|
313 } |
|
314 |
|
315 return element; |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // ReserveNumberTypeIconElement |
|
320 // --------------------------------------------------------------------------- |
|
321 // |
|
322 CTelBubbleCustomElement* CBubbleDefaultManager::ReserveNumberTypeIconElement( |
|
323 const CBubbleHeader& aHeader ) |
|
324 { |
|
325 CTelBubbleCustomElement* element = |
|
326 ReserveElement( EBMDefaultNumberTypeIcon ); |
|
327 |
|
328 CBubbleNumberTypeIcon* icon = |
|
329 static_cast<CBubbleNumberTypeIcon*> ( element->Control() ); |
|
330 |
|
331 icon->ReadBubbleHeader( aHeader ); |
|
332 |
|
333 return element; |
|
334 } |
|
335 |
|
336 // --------------------------------------------------------------------------- |
|
337 // ReserveCallerImageElement |
|
338 // --------------------------------------------------------------------------- |
|
339 // |
|
340 CTelBubbleCustomElement* CBubbleDefaultManager::ReserveCallImageElement( |
|
341 const CBubbleHeader& /*aHeader*/ ) |
|
342 { |
|
343 return ReserveElement( EBMDefaultCallImageControl ); |
|
344 } |
|
345 |
|
346 // --------------------------------------------------------------------------- |
|
347 // ReserveElement |
|
348 // --------------------------------------------------------------------------- |
|
349 // |
|
350 CTelBubbleCustomElement* CBubbleDefaultManager::ReserveElement( |
|
351 TBubbleDefaultElements aType ) |
|
352 { |
|
353 CTelBubbleCustomElement* element = NULL; |
|
354 TUint amount = iElements->At( aType )->Count(); |
|
355 // 1 mean is reserved and 0 free slot |
|
356 TUint& available = iAvailabilities[aType]; |
|
357 TUint bit = 1; // start from first bit |
|
358 for ( TUint slot = 0 ; slot < amount ; slot++ ) |
|
359 { |
|
360 // if flag is one the seat is taken... |
|
361 if ( available&bit ) |
|
362 { |
|
363 bit = bit<<1; //move to next bit of for next round |
|
364 continue; |
|
365 } |
|
366 |
|
367 // so we found a free slot |
|
368 element = iElements->At( aType )->At( slot ); |
|
369 if ( element != NULL ) |
|
370 { |
|
371 available |= bit; // set the corrensponding bit |
|
372 // for reserved indicator |
|
373 } |
|
374 break; |
|
375 } |
|
376 __ASSERT_DEBUG( element != NULL , |
|
377 Panic( EBMPanicCustomization ) ); |
|
378 return element; |
|
379 } |
|
380 |
|
381 // --------------------------------------------------------------------------- |
|
382 // ReleaseElement |
|
383 // --------------------------------------------------------------------------- |
|
384 // |
|
385 void CBubbleDefaultManager::ReleaseElement( |
|
386 CTelBubbleCustomElement*& aElement ) |
|
387 { |
|
388 if ( aElement == NULL ) |
|
389 { |
|
390 return; |
|
391 } |
|
392 |
|
393 for ( TInt i = 0 ; i < iElements->Count() ; i++ ) |
|
394 { |
|
395 CSingleElement* single = iElements->At( i ); |
|
396 TUint amount = single->Count(); |
|
397 TUint& available = iAvailabilities[i]; // 1 mean is reserved |
|
398 // and 0 free slot |
|
399 TUint bit = 1; // start from first bit |
|
400 for ( TUint slot = 0 ; slot < amount ; slot++ ) |
|
401 { |
|
402 if ( single->At( slot ) == aElement ) |
|
403 { |
|
404 __ASSERT_DEBUG( available&bit, |
|
405 Panic( EBMPanicCustomization ) ); |
|
406 available &= ~bit; // zero the corrensponding bit |
|
407 // for freed indicator |
|
408 aElement = NULL; |
|
409 break; |
|
410 } |
|
411 bit = bit<<1; //move to next bit of for next round |
|
412 } |
|
413 } |
|
414 } |
|
415 |