author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 15:10:43 +0300 | |
branch | RCL_3 |
changeset 56 | 2735883dd3f6 |
parent 44 | 987c9837762f |
permissions | -rw-r--r-- |
44 | 1 |
/* |
2 |
* Copyright (c) 2006-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: The handler for the SAT Plug-in |
|
15 |
* Set Up Idle Mode Text proactive command. |
|
16 |
* |
|
17 |
*/ |
|
18 |
||
19 |
||
20 |
// INCLUDE FILES |
|
21 |
#include <e32base.h> |
|
22 |
#include <etelsat.h> |
|
56
2735883dd3f6
Revision: 201038
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
44
diff
changeset
|
23 |
#include <RSatSession.h> |
44 | 24 |
#include <rsatservice.h> |
25 |
||
26 |
#include "caisatnotifier.h" |
|
27 |
#include "mpluginapi.h" // Needed in cpp and header |
|
28 |
#include "tflogger.h" |
|
29 |
||
30 |
// ============================ MEMBER FUNCTIONS ============================= |
|
31 |
// --------------------------------------------------------------------------- |
|
32 |
// Symbian 2nd phase constructor can leave |
|
33 |
// --------------------------------------------------------------------------- |
|
34 |
// |
|
35 |
CAiSatNotifier* CAiSatNotifier::NewL( MPluginAPI& aPlugin, |
|
36 |
RSatService& aSatService ) |
|
37 |
{ |
|
38 |
TFLOGSTRING( "CAiSatNotifier::NewL calling" ) |
|
39 |
CAiSatNotifier* self = new ( ELeave ) CAiSatNotifier( aPlugin, |
|
40 |
aSatService ); |
|
41 |
||
42 |
TFLOGSTRING( "CAiSatNotifier::NewL exits" ) |
|
43 |
return self; |
|
44 |
} |
|
45 |
||
46 |
// --------------------------------------------------------------------------- |
|
47 |
// Destructor |
|
48 |
// Cancels and deletes |
|
49 |
// all the dynamic content |
|
50 |
// --------------------------------------------------------------------------- |
|
51 |
// |
|
52 |
CAiSatNotifier::~CAiSatNotifier() |
|
53 |
{ |
|
54 |
TFLOGSTRING( "CAiSatNotifier::~CAiSatNotifier calling" ) |
|
55 |
||
56 |
// Cancel any outstanding requests |
|
57 |
Cancel(); |
|
58 |
delete iString; |
|
59 |
||
60 |
TFLOGSTRING( "CAiSatNotifier::~CAiSatNotifier exits" ) |
|
61 |
} |
|
62 |
||
63 |
// --------------------------------------------------------------------------- |
|
64 |
// Starts the handler |
|
65 |
// --------------------------------------------------------------------------- |
|
66 |
// |
|
67 |
TInt CAiSatNotifier::Start() |
|
68 |
{ |
|
69 |
TFLOGSTRING( "CAiSatNotifier::Start calling" ) |
|
70 |
||
71 |
TInt error( KErrNotReady ); |
|
72 |
if ( !IsActive() ) |
|
73 |
{ |
|
74 |
error = iSatService.NotifySetupIdleModeTextChange( iStatus ); |
|
75 |
TFLOGSTRING2( "CAiSatNotifier::Start error %i", error ) |
|
76 |
if ( KErrNone == error ) |
|
77 |
{ |
|
78 |
// Set to active so that requests can be received |
|
79 |
SetActive(); |
|
80 |
} |
|
81 |
} |
|
82 |
||
83 |
TFLOGSTRING( "CAiSatNotifier::Start exits" ) |
|
84 |
return error; |
|
85 |
} |
|
86 |
||
87 |
// --------------------------------------------------------------------------- |
|
88 |
// Get the idle mode data to member: string, icon qualifier, icon id. |
|
89 |
// --------------------------------------------------------------------------- |
|
90 |
// |
|
91 |
TBool CAiSatNotifier::HasContent() |
|
92 |
{ |
|
93 |
TFLOGSTRING( "CAiSatNotifier::HasContent calling" ) |
|
94 |
TBool ret( EFalse ); |
|
95 |
if ( ( iString && iString->Length() ) || |
|
96 |
RSatService::ESatIconNoIcon != iIconQualifier ) |
|
97 |
{ |
|
98 |
TFLOGSTRING( "CAiSatNotifier::HasContent ETrue" ) |
|
99 |
ret = ETrue; |
|
100 |
} |
|
101 |
TFLOGSTRING( "CAiSatNotifier::HasContent exits" ) |
|
102 |
return ret; |
|
103 |
} |
|
104 |
||
105 |
// --------------------------------------------------------------------------- |
|
106 |
// Get the idle mode data to member: string, icon qualifier, icon id. |
|
107 |
// --------------------------------------------------------------------------- |
|
108 |
// |
|
109 |
void CAiSatNotifier::GetIdleModeDataL( TBool& aDupIcon, TBool& aDupText ) |
|
110 |
{ |
|
111 |
TFLOGSTRING( "CAiSatNotifier::GetIdleModeData calling" ) |
|
112 |
HBufC* string( NULL ); |
|
113 |
TUint8 recordId( NULL ); |
|
114 |
RSatService::TSatIconQualifier iconQualifier( |
|
115 |
RSatService::ESatIconNoIcon ); |
|
116 |
||
117 |
// Get setup idle mode text, icon qualifier and record id. |
|
118 |
iSatService.GetSetupIdleModeTextL( string, iconQualifier, recordId ); |
|
119 |
||
120 |
// If the icon is self explanatory, NULL the string. |
|
121 |
if ( string && RSatService::ESatIconSelfExplanatory == iconQualifier ) |
|
122 |
{ |
|
123 |
TPtr ptr( string->Des() ); |
|
124 |
ptr.Copy( KNullDesC ); |
|
125 |
} |
|
126 |
||
127 |
// Check if the icon or text is the same as previous one. |
|
128 |
if ( iFirstStartup ) |
|
129 |
{ |
|
130 |
aDupIcon = EFalse; |
|
131 |
aDupText = EFalse; |
|
132 |
iFirstStartup = EFalse; |
|
133 |
} |
|
134 |
else |
|
135 |
{ |
|
136 |
// Check if setup idle mode icon is changed. |
|
137 |
aDupIcon = ( iRecordId == recordId ); |
|
138 |
||
139 |
// Check if setup idle mode text is changed. |
|
140 |
// If both of the iString and string are NULL, it is duplicated. |
|
141 |
// If both of the iString and string are not NULL, and they have |
|
142 |
// the same content, it is duplicated. |
|
143 |
// Otherwise, it is not duplicated. |
|
144 |
||
145 |
aDupText = ( ( ( !iString || !iString->Length() ) && |
|
146 |
( !string || !string->Length() ) ) || |
|
147 |
( iString && string && |
|
148 |
*iString == string->Des() ) ); |
|
149 |
} |
|
150 |
||
151 |
// Save the setup idle mode text, icon qulifier |
|
152 |
// and record id to member params. |
|
153 |
delete iString; |
|
154 |
iString = NULL; |
|
155 |
if ( string ) |
|
156 |
{ |
|
157 |
CleanupStack::PushL( string ); |
|
158 |
iString = HBufC::NewL( string->Size() ); |
|
159 |
TPtr ptr( iString->Des() ); |
|
160 |
ptr.Copy( string->Des() ); |
|
161 |
CleanupStack::PopAndDestroy( string ); |
|
162 |
} |
|
163 |
||
164 |
iIconQualifier = iconQualifier; |
|
165 |
||
166 |
iRecordId = recordId; |
|
167 |
||
168 |
TFLOGSTRING( "CAiSatNotifier::GetIdleModeData exits" ) |
|
169 |
} |
|
170 |
||
171 |
// --------------------------------------------------------------------------- |
|
172 |
// Handles the Idle Text string command |
|
173 |
// --------------------------------------------------------------------------- |
|
174 |
// |
|
175 |
void CAiSatNotifier::GetIdleTextString( TPtrC& aString ) |
|
176 |
{ |
|
177 |
TFLOGSTRING( "CAiSatNotifier::GetIdleTextString calling" ) |
|
178 |
||
179 |
if ( iString ) |
|
180 |
{ |
|
181 |
TFLOGSTRING2( "CAiSatNotifier::IdleTextStringL exits, \ |
|
182 |
length of string: %i", iString->Length() ) |
|
183 |
aString.Set( iString->Des() ); |
|
184 |
} |
|
185 |
else |
|
186 |
{ |
|
187 |
aString.Set( KNullDesC ); |
|
188 |
} |
|
189 |
TFLOGSTRING( "CAiSatNotifier::GetIdleTextString exits" ) |
|
190 |
} |
|
191 |
||
192 |
||
193 |
// --------------------------------------------------------------------------- |
|
194 |
// Handles the Idle Icon command. |
|
195 |
// --------------------------------------------------------------------------- |
|
196 |
// |
|
197 |
TUint8 CAiSatNotifier::IdleIconId() |
|
198 |
{ |
|
199 |
TFLOGSTRING( "CAiSatNotifier::IdleIconId calling" ) |
|
200 |
||
201 |
TFLOGSTRING2( "CAiSatNotifier::IdleIconId exits, id: %i", iRecordId ) |
|
202 |
||
203 |
return iRecordId; |
|
204 |
} |
|
205 |
||
206 |
// --------------------------------------------------------------------------- |
|
207 |
// Handles the Idle Icon Qulifier command. |
|
208 |
// --------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
RSatService::TSatIconQualifier CAiSatNotifier::IdleIconQualifier() |
|
211 |
{ |
|
212 |
TFLOGSTRING( "CAiSatNotifier::IdleIconQualifier calling" ) |
|
213 |
||
214 |
TFLOGSTRING2( "CAiSatNotifier::IdleIconQualifier exits, \ |
|
215 |
iconQualifier: %d", iIconQualifier ) |
|
216 |
||
217 |
return iIconQualifier; |
|
218 |
} |
|
219 |
||
220 |
// --------------------------------------------------------------------------- |
|
221 |
// Handles the Plugin's NotifyContentUpdate command. |
|
222 |
// --------------------------------------------------------------------------- |
|
223 |
// |
|
224 |
void CAiSatNotifier::RunL() |
|
225 |
{ |
|
226 |
TFLOGSTRING( "CAiSatNotifier::RunL calling" ) |
|
227 |
||
228 |
// Notify the plugin about the event through the MPluginAPI interface |
|
229 |
if ( KErrNone == iStatus.Int() ) |
|
230 |
{ |
|
231 |
// Notify plugin when the content update. |
|
232 |
// The plugin should get data again. |
|
233 |
iPlugin.NotifyContentUpdate(); |
|
234 |
} |
|
235 |
if ( !IsActive() ) |
|
236 |
{ |
|
237 |
Activate(); |
|
238 |
} |
|
239 |
TFLOGSTRING( "CAiSatNotifier::RunL exits" ) |
|
240 |
||
241 |
} |
|
242 |
||
243 |
// --------------------------------------------------------------------------- |
|
244 |
// Cancels the pending request |
|
245 |
// --------------------------------------------------------------------------- |
|
246 |
// |
|
247 |
void CAiSatNotifier::DoCancel() |
|
248 |
{ |
|
249 |
TFLOGSTRING( "CAiSatNotifier::DoCancel calling" ) |
|
250 |
||
251 |
iSatService.NotifySetupIdleModeTextChangeCancel(); |
|
252 |
||
253 |
TFLOGSTRING( "CAiSatNotifier::DoCancel exits" ) |
|
254 |
} |
|
255 |
||
256 |
// --------------------------------------------------------------------------- |
|
257 |
// Default constructor |
|
258 |
// --------------------------------------------------------------------------- |
|
259 |
// |
|
260 |
CAiSatNotifier::CAiSatNotifier( MPluginAPI& aPlugin, |
|
261 |
RSatService& aSatService ): |
|
262 |
CActive( EPriorityStandard ), |
|
263 |
iString( NULL ), |
|
264 |
iRecordId( 0 ), |
|
265 |
iIconQualifier( RSatService::ESatIconNoIcon ), |
|
266 |
iPlugin( aPlugin ), |
|
267 |
iSatService( aSatService ), |
|
268 |
iFirstStartup( ETrue ) |
|
269 |
{ |
|
270 |
TFLOGSTRING( "CAiSatNotifier::CAiSatNotifier calling" ) |
|
271 |
||
272 |
// Add to active scheduler |
|
273 |
CActiveScheduler::Add( this ); |
|
274 |
||
275 |
TFLOGSTRING( "CAiSatNotifier::CAiSatNotifier exits" ) |
|
276 |
} |
|
277 |
||
278 |
// --------------------------------------------------------------------------- |
|
279 |
// Continues listening to the Sat command |
|
280 |
// --------------------------------------------------------------------------- |
|
281 |
// |
|
282 |
void CAiSatNotifier::Activate() |
|
283 |
{ |
|
284 |
TFLOGSTRING( "CAiSatNotifier:Activate() calling" ) |
|
285 |
||
286 |
Cancel(); |
|
287 |
TInt error = iSatService.NotifySetupIdleModeTextChange( iStatus ); |
|
288 |
TFLOGSTRING2( "CAiSatNotifier::Activate error: %i", error ) |
|
289 |
if ( KErrNone == error ) |
|
290 |
{ |
|
291 |
SetActive(); |
|
292 |
} |
|
293 |
TFLOGSTRING( "CAiSatNotifier:Activate() exits" ) |
|
294 |
} |