|
1 /* |
|
2 * Copyright (c) 2007-2010 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: The engine class of operator info plugin. Handles the |
|
15 * communication with Publish&Subscribe data. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <AknIconArray.h> // For itemsicon |
|
22 #include <gulicon.h> // For itemsicon |
|
23 #include <aknlayout.cdl.h> // For TAknWindowLineLayout |
|
24 #include <aknlayoutscalable_avkon.cdl.h> // For scalable layouts |
|
25 #include <AknUtils.h> |
|
26 #include <AknIconUtils.h> |
|
27 |
|
28 #include "caisatengine.h" |
|
29 #include "caisatnotifier.h" |
|
30 #include "mpluginapi.h" |
|
31 #include "tflogger.h" |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 // ----------------------------------------------------------------------------- |
|
35 // Default constructor |
|
36 // ----------------------------------------------------------------------------- |
|
37 // |
|
38 CAiSatEngine::CAiSatEngine( MPluginAPI& aPlugin ) : |
|
39 iPlugin ( aPlugin ), |
|
40 iIcon( NULL ), |
|
41 iPreviousIconId( 0 ) |
|
42 { |
|
43 } |
|
44 |
|
45 // ----------------------------------------------------------------------------- |
|
46 // Two-phased constructor. |
|
47 // Create instance of concrete ECOM interface implementation |
|
48 // ----------------------------------------------------------------------------- |
|
49 CAiSatEngine* CAiSatEngine::NewL( MPluginAPI& aPlugin ) |
|
50 { |
|
51 TFLOGSTRING( "CAiSatEngine::NewL called" ) |
|
52 |
|
53 CAiSatEngine* self = new( ELeave )CAiSatEngine( aPlugin ); |
|
54 CleanupStack::PushL( self ); |
|
55 self->ConstructL(); |
|
56 CleanupStack::Pop( self ); |
|
57 |
|
58 TFLOGSTRING( "CAiSatEngine::NewL exits" ) |
|
59 return self; |
|
60 } |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // Destructor. |
|
64 // Closes the connection to the P&S and deletes |
|
65 // all the dynamic content. |
|
66 // ----------------------------------------------------------------------------- |
|
67 // |
|
68 CAiSatEngine::~CAiSatEngine() |
|
69 { |
|
70 TFLOGSTRING( "CAiSatEngine::~CAiSatEngine called" ) |
|
71 |
|
72 delete iNotifier; |
|
73 |
|
74 // Delete icon and null the pointer. |
|
75 delete iIcon; |
|
76 iIcon = NULL; |
|
77 |
|
78 iSatService.Close(); |
|
79 iSatSession.Close(); |
|
80 |
|
81 TFLOGSTRING( "CAiSatEngine::~CAiSatEngine exits" ) |
|
82 } |
|
83 |
|
84 // ----------------------------------------------------------------------------- |
|
85 // Offers information about the content |
|
86 // Returns ETrue if there is content available, |
|
87 // EFalse if not. |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 TBool CAiSatEngine::HasContent() |
|
91 { |
|
92 TFLOGSTRING( "CAiSatEngine::HasContent called - exits" ) |
|
93 return iNotifier->HasContent(); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // Retrieves the operator info text from RSatService |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CAiSatEngine::ContentText( TPtrC& aString ) |
|
101 { |
|
102 TFLOGSTRING( "CAiSatEngine::ContentText called" ) |
|
103 |
|
104 iNotifier->GetIdleTextString( aString ); |
|
105 |
|
106 TFLOGSTRING( "CAiSatEngine::ContentText exits" ) |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // Offers the Idle Mode icon |
|
111 // ----------------------------------------------------------------------------- |
|
112 // |
|
113 void CAiSatEngine::ContentIconL( CGulIcon*& aGulIcon ) |
|
114 { |
|
115 TFLOGSTRING( "CAiSatEngine::ContentIconL called" ) |
|
116 |
|
117 // Active Idle framework will release the bitmap we would |
|
118 // publish. So a new bitmap should be created to avoid |
|
119 // destroying the bitmap owned by UAA. |
|
120 if ( iIcon ) |
|
121 { |
|
122 TFLOGSTRING( "CAiSatEngine::ContentIconL iIcon != NULL" ) |
|
123 // The bitmap for publishing. |
|
124 CFbsBitmap* bitmapToPublish( NULL ); |
|
125 |
|
126 bitmapToPublish = new (ELeave) CFbsBitmap; |
|
127 CleanupStack::PushL( bitmapToPublish ); |
|
128 |
|
129 TSize size = iIcon->SizeInPixels(); |
|
130 TInt error = bitmapToPublish->Create( size, iIcon->DisplayMode() ); |
|
131 TFLOGSTRING2( "CFbsBitmap::Create returns %d", error ) |
|
132 // Duplicate the bitmap owned by UAA into the new bitmap. |
|
133 if ( !error ) |
|
134 { |
|
135 error = bitmapToPublish->Duplicate( iIcon->Handle() ); |
|
136 TFLOGSTRING2( "CFbsBitmap::Duplicate returns %d", error ) |
|
137 if ( !error ) |
|
138 { |
|
139 // Create a icon from the bitmap and publish it. |
|
140 aGulIcon = CGulIcon::NewL( bitmapToPublish ); |
|
141 CleanupStack::Pop( bitmapToPublish ); |
|
142 TFLOGSTRING( "CAiSatEngine::ContentIconL create GulIcon" ) |
|
143 } |
|
144 } |
|
145 if ( error ) |
|
146 { |
|
147 CleanupStack::PopAndDestroy( bitmapToPublish ); |
|
148 aGulIcon = NULL; |
|
149 } |
|
150 } |
|
151 TFLOGSTRING( "CAiSatEngine::ContentIconL exits" ) |
|
152 } |
|
153 |
|
154 //------------------------------------------------------------------------------ |
|
155 // Loads icon provided by SIM from RSatIcon |
|
156 //------------------------------------------------------------------------------ |
|
157 CFbsBitmap* CAiSatEngine::LoadIconL( TUint8 aIconId, |
|
158 RSatService::TSatIconQualifier aIconQualifier ) |
|
159 { |
|
160 TFLOGSTRING( "CAiSatEngine::LoadIconL called" ) |
|
161 CFbsBitmap* simIconBuffer( NULL ); |
|
162 |
|
163 // If icon allready has been got from SIM (via satIcon and SATServer) |
|
164 // Because mechanism for fetching icon is very slow, it has been |
|
165 // stored in class variable to make reasonable speed for |
|
166 // Active Idle refreshing. |
|
167 if ( RSatService::ESatIconSelfExplanatory == aIconQualifier || |
|
168 RSatService::ESatIconNotSelfExplanatory == aIconQualifier ) |
|
169 { |
|
170 TFLOGSTRING( "CAiSatEngine::LoadIconL having icon" ) |
|
171 RIconEf iconEf; |
|
172 CleanupClosePushL( iconEf ); |
|
173 |
|
174 // Get icon info |
|
175 iSatService.GetIconInfoL( aIconId, iconEf ); |
|
176 // Get the an available icon from info array. |
|
177 TInt infoCount( iconEf.Count() ); |
|
178 TInt error( KErrNotFound ); |
|
179 for ( TInt i = 0; i < infoCount && KErrNone != error; i++ ) |
|
180 { |
|
181 TRAP( error, simIconBuffer = iSatService.GetIconL( iconEf[i] ) ); |
|
182 } |
|
183 |
|
184 // Check whether the for loop ends without icon gotton. |
|
185 if ( error != KErrNone ) |
|
186 { |
|
187 TFLOGSTRING2( "CAiSatEngine::LoadIconL: error=%d",error ) |
|
188 simIconBuffer = NULL; |
|
189 } |
|
190 |
|
191 CleanupStack::PopAndDestroy( &iconEf ); |
|
192 } |
|
193 TFLOGSTRING( "CAiSatEngine::LoadIconL exit" ) |
|
194 return simIconBuffer; |
|
195 } |
|
196 |
|
197 // --------------------------------------------------------------------------- |
|
198 // Formulates response to SatIcon API |
|
199 // --------------------------------------------------------------------------- |
|
200 // |
|
201 void CAiSatEngine::HandleNotifyL() |
|
202 { |
|
203 TFLOGSTRING( "CAiSatEngine::HandleNotifyL called" ) |
|
204 TUint8 id( iNotifier->IdleIconId() ); |
|
205 RSatService::TSatIconQualifier iconQualifier( |
|
206 iNotifier->IdleIconQualifier() ); |
|
207 |
|
208 if ( !HasContent() && RSatService::ESatIconNoIcon == iconQualifier ) |
|
209 { |
|
210 // Removal of text = No text and no icon |
|
211 TFLOGSTRING( "CAiSatNotifier::HasContent ETrue remove text success" ) |
|
212 SendSatResponseL( RSatService::ESATIdleSuccess ); |
|
213 } |
|
214 else |
|
215 { |
|
216 TFLOGSTRING2( "CAiSatEngine::HandleNotifyL Icon: %d", iconQualifier ) |
|
217 if ( RSatService::ESatIconNoIcon == iconQualifier) |
|
218 { |
|
219 TFLOGSTRING( "CAiSatEngine::HandleNotifyL ESatIconNoIcon" ) |
|
220 SendSatResponseL( RSatService::ESATIdleSuccess ); |
|
221 } |
|
222 else if ( RSatService::ESatIconSelfExplanatory == iconQualifier || |
|
223 RSatService::ESatIconNotSelfExplanatory == iconQualifier ) |
|
224 { |
|
225 SendSatResponseL( RSatService::ESATIdleSuccess ); |
|
226 TFLOGSTRING( "CAiSatEngine::HandleNotify icon & success resp" ) |
|
227 } |
|
228 else if ( RSatService::ESatIconNotSelfExplanatory != iconQualifier && |
|
229 RSatService::ESatIconNoIcon != iconQualifier ) |
|
230 { |
|
231 SendSatResponseL( RSatService::ESATIdleSuccessRequestedIconNotDisplayed ); |
|
232 TFLOGSTRING( "CAiSatEngine: KSATIdleSuccessRequestedIconNotDisplayed" ) |
|
233 } |
|
234 else |
|
235 { |
|
236 TFLOGSTRING( "CAiSatEngine::HandleNotifyL others" ) |
|
237 // Report error |
|
238 SendSatResponseL( RSatService::ESATIdleMeUnableToProcessCmd ); |
|
239 } |
|
240 } |
|
241 |
|
242 TFLOGSTRING( "CAiSatEngine::HandleNotify exit" ) |
|
243 } |
|
244 |
|
245 // --------------------------------------------------------------------------- |
|
246 // Get Idle mode data first, and load icon for publishing |
|
247 // --------------------------------------------------------------------------- |
|
248 // |
|
249 void CAiSatEngine::PrepareIdleModeDataL( TBool& aDupIcon, TBool& aDupText ) |
|
250 { |
|
251 TFLOGSTRING( "CAiSatEngine::PrepareGetIdleModeDataL called" ) |
|
252 |
|
253 // Get icon Id, icon qualifier and text. |
|
254 iNotifier->GetIdleModeDataL( aDupIcon, aDupText ); |
|
255 |
|
256 // Load icon, and check whether it is the same with previous one. |
|
257 // if not, Load icon, otherwise, do nothing. |
|
258 TUint8 id ( iNotifier->IdleIconId() ); |
|
259 RSatService::TSatIconQualifier iconQualifier( |
|
260 iNotifier->IdleIconQualifier() ); |
|
261 |
|
262 if ( !( RSatService::ESatIconNoIcon == iconQualifier ) || |
|
263 !( id == iPreviousIconId && iIcon ) ) |
|
264 { |
|
265 TFLOGSTRING( "CAiSatEngine::PrepareIdleModeDataL load icon" ) |
|
266 delete iIcon; |
|
267 iIcon = NULL; |
|
268 |
|
269 // The bitmap is fetched from UAA. |
|
270 iIcon = LoadIconL( id, iconQualifier ); |
|
271 iPreviousIconId = id; |
|
272 } |
|
273 TFLOGSTRING( "CAiSatEngine::PrepareGetIdleModeDataL exits" ) |
|
274 } |
|
275 |
|
276 // --------------------------------------------------------------------------- |
|
277 // Symbian 2nd phase constructor can leave |
|
278 // --------------------------------------------------------------------------- |
|
279 // |
|
280 void CAiSatEngine::ConstructL() |
|
281 { |
|
282 TFLOGSTRING( "CAiSatEngine::ConstructL called" ) |
|
283 |
|
284 iSatSession.ConnectL(); |
|
285 TFLOGSTRING( "CAiSatEngine::ConstructL connect sat session" ) |
|
286 |
|
287 iSatService.OpenL( iSatSession ); |
|
288 TFLOGSTRING( "CAiSatEngine::ConstructL open sat service" ) |
|
289 |
|
290 iNotifier = CAiSatNotifier::NewL( iPlugin, iSatService ); |
|
291 User::LeaveIfError( iNotifier->Start() ); |
|
292 |
|
293 TFLOGSTRING( "CAiSatEngine::ConstructL exits" ) |
|
294 } |
|
295 |
|
296 // --------------------------------------------------------------------------- |
|
297 // Sends SAT response to RSatIcon |
|
298 // --------------------------------------------------------------------------- |
|
299 // |
|
300 void CAiSatEngine::SendSatResponseL( |
|
301 const RSatService::TSATIdleResult& aResponse ) const |
|
302 { |
|
303 TFLOGSTRING( "CAiSatEngine::SendSatResponseL called") |
|
304 |
|
305 iSatService.SetIdleModeTextResponse( aResponse ); |
|
306 |
|
307 TFLOGSTRING( "CAiSatEngine::SendSatResponseL exits" ) |
|
308 } |
|
309 |
|
310 // End Of File |