|
1 /* |
|
2 * Copyright (c) 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: Wraps bubble into one class. |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "telbrandingbubble.h" |
|
19 #include "telbrandingcallindicator.h" |
|
20 #include "telbrandingserverhandler.h" |
|
21 #include "telbrandingimage.h" |
|
22 |
|
23 #include <telbubbleextensionobserver.h> |
|
24 #include <telbubbleextensiondata.h> |
|
25 #include <telbubblecustomelement.h> |
|
26 #include <telbubbleimage.h> |
|
27 |
|
28 // ======== CONSTANTS ======== |
|
29 _LIT8( KBrandImageId, "bubble_manager_brand_image" ); |
|
30 _LIT8( KCallIndicatorImageId, "bubble_manager_call_indicator_image" ); |
|
31 |
|
32 |
|
33 // ======== LOCAL FUNCTIONS ======== |
|
34 |
|
35 // ======== MEMBER FUNCTIONS ======== |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CTelBrandingBubble::CTelBrandingBubble |
|
39 // --------------------------------------------------------------------------- |
|
40 // |
|
41 CTelBrandingBubble::CTelBrandingBubble( MTelBubbleExtensionData& aCallData ) : |
|
42 iCallData( aCallData ) |
|
43 { |
|
44 |
|
45 } |
|
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // CTelBrandingBubble::ConstructL |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 void CTelBrandingBubble::ConstructL( |
|
53 CTelBrandingServerHandler& aServer ) |
|
54 { |
|
55 // Branded call indication |
|
56 TRAP_IGNORE( |
|
57 CreateCallIndicationElementL( |
|
58 aServer, |
|
59 CTelBubbleCustomElement::ESmallCallIndicator ); |
|
60 |
|
61 CreateCallIndicationElementL( |
|
62 aServer, |
|
63 CTelBubbleCustomElement::EBigCallIndicator ); |
|
64 ) |
|
65 |
|
66 if( !iElements.Count() ) |
|
67 { |
|
68 // Basic brand image |
|
69 TRAP_IGNORE( AddBrandingImageWithPriorityL( |
|
70 KBrandImageId, |
|
71 aServer, |
|
72 CTelBubbleCustomElement::EBrandImage ); |
|
73 ) |
|
74 } |
|
75 |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------------------------- |
|
79 // CTelBrandingBubble::NewLC |
|
80 // --------------------------------------------------------------------------- |
|
81 // |
|
82 CTelBrandingBubble* CTelBrandingBubble::NewLC( |
|
83 MTelBubbleExtensionData& aCallData, |
|
84 CTelBrandingServerHandler& aServer ) |
|
85 { |
|
86 CTelBrandingBubble* self = new( ELeave ) CTelBrandingBubble( aCallData ); |
|
87 CleanupStack::PushL( self ); |
|
88 self->ConstructL( aServer ); |
|
89 return self; |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CTelBrandingBubble::~CTelBrandingBubble |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 CTelBrandingBubble::~CTelBrandingBubble() |
|
98 { |
|
99 iElements.ResetAndDestroy(); |
|
100 iElements.Close(); |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // CTelBrandingBubble::CreateCallIndicationElementL |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 void CTelBrandingBubble::CreateCallIndicationElementL( |
|
108 CTelBrandingServerHandler& aServer, |
|
109 CTelBubbleCustomElement::TElementType aType ) |
|
110 { |
|
111 CFbsBitmap* bitmap = NULL; |
|
112 CFbsBitmap* mask = NULL; |
|
113 |
|
114 // Call indicator |
|
115 aServer.GetBrandIconL( |
|
116 KCallIndicatorImageId, |
|
117 bitmap, |
|
118 mask ); |
|
119 |
|
120 CEikImage* image = new(ELeave) CEikImage; |
|
121 image->SetPicture( bitmap, mask ); |
|
122 CleanupStack::PushL( image ); |
|
123 |
|
124 CTelBrandingCallIndicator* indicator = |
|
125 CTelBrandingCallIndicator::NewL( iCallData, image ); |
|
126 |
|
127 CleanupStack::Pop( image ); |
|
128 CleanupStack::PushL( indicator ); |
|
129 |
|
130 CTelBubbleCustomElement* customElement = |
|
131 CTelBubbleCustomElement::NewL( indicator, aType ); |
|
132 |
|
133 CleanupStack::Pop( indicator ); |
|
134 |
|
135 AddElementToArrayL( customElement ); |
|
136 } |
|
137 |
|
138 // --------------------------------------------------------------------------- |
|
139 // CTelBrandingBubble::AddBrandingImageWithPriorityL |
|
140 // --------------------------------------------------------------------------- |
|
141 // |
|
142 void CTelBrandingBubble::AddBrandingImageWithPriorityL( |
|
143 const TDesC8& aImageType, |
|
144 CTelBrandingServerHandler& aServer, |
|
145 CTelBubbleCustomElement::TElementType aType ) |
|
146 { |
|
147 CTelBrandingImage* image = |
|
148 CTelBrandingImage::NewLC(); |
|
149 |
|
150 CFbsBitmap* bitmap = NULL; |
|
151 CFbsBitmap* mask = NULL; |
|
152 |
|
153 aServer.GetBrandIconL( |
|
154 aImageType, |
|
155 bitmap, |
|
156 mask ); |
|
157 |
|
158 image->SetPicture( bitmap, mask ); |
|
159 |
|
160 CTelBubbleCustomElement* customElement = |
|
161 CTelBubbleCustomElement::NewL( image, aType ); |
|
162 |
|
163 CleanupStack::Pop( image ); |
|
164 |
|
165 TInt lowerIndex = iElements.Count()-1; |
|
166 if( lowerIndex != KErrNotFound ) |
|
167 { |
|
168 // Set previous element to lower priority |
|
169 CTelBrandingImage* lowerImage = |
|
170 static_cast<CTelBrandingImage*>( iElements[lowerIndex]->Control() ); |
|
171 image->SetLowerPriorityBranding( lowerImage ); |
|
172 } |
|
173 |
|
174 AddElementToArrayL( customElement ); |
|
175 } |
|
176 |
|
177 // --------------------------------------------------------------------------- |
|
178 // CTelBrandingBubble::AddElementToArrayL |
|
179 // --------------------------------------------------------------------------- |
|
180 // |
|
181 void CTelBrandingBubble::AddElementToArrayL( CTelBubbleCustomElement* aElement ) |
|
182 { |
|
183 CleanupStack::PushL( aElement ); |
|
184 |
|
185 iElements.AppendL( aElement ); |
|
186 |
|
187 CleanupStack::Pop( aElement ); |
|
188 } |
|
189 |
|
190 // --------------------------------------------------------------------------- |
|
191 // CTelBrandingBubble::BubbleId |
|
192 // --------------------------------------------------------------------------- |
|
193 // |
|
194 TInt CTelBrandingBubble::BubbleId() const |
|
195 { |
|
196 return iCallData.BubbleId(); |
|
197 } |
|
198 |
|
199 // --------------------------------------------------------------------------- |
|
200 // CTelBrandingBubble::AttachElements |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CTelBrandingBubble::AttachElements( MTelBubbleExtensionObserver& aObs ) const |
|
204 { |
|
205 for( TInt i = 0; i < iElements.Count(); i++ ) |
|
206 { |
|
207 aObs.AttachElement( |
|
208 BubbleId(), iElements[i] ); |
|
209 } |
|
210 |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CTelBrandingBubble::DetechElements |
|
215 // --------------------------------------------------------------------------- |
|
216 // |
|
217 void CTelBrandingBubble::DetechElements( MTelBubbleExtensionObserver& aObs ) const |
|
218 { |
|
219 for( TInt i = 0; i < iElements.Count(); i++ ) |
|
220 { |
|
221 aObs.DetachElement( |
|
222 BubbleId(), iElements[i] ); |
|
223 } |
|
224 } |
|
225 |