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: Monitor the set up idle mote text P&S key. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <e32base.h> |
|
20 #include <etelsat.h> |
|
21 #include <SATInternalPSKeys.h> // For monitor the P&S key |
|
22 |
|
23 #include "csatpluginmonitor.h" |
|
24 #include "SatLog.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // Symbian 2nd phase constructor can leave |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CSatPluginMonitor* CSatPluginMonitor::NewL() |
|
33 { |
|
34 LOG( SIMPLE, "CSatPluginMonitor::NewL calling" ) |
|
35 |
|
36 CSatPluginMonitor* self = new ( ELeave ) CSatPluginMonitor(); |
|
37 CleanupStack::PushL( self ); |
|
38 self->ConstructL(); |
|
39 CleanupStack::Pop( self ); |
|
40 |
|
41 LOG( SIMPLE, "CSatPluginMonitor::NewL exits" ) |
|
42 return self; |
|
43 } |
|
44 // ----------------------------------------------------------------------------- |
|
45 // Destructor |
|
46 // Cancels and deletes |
|
47 // all the dynamic content |
|
48 // ----------------------------------------------------------------------------- |
|
49 // |
|
50 CSatPluginMonitor::~CSatPluginMonitor() |
|
51 { |
|
52 LOG( SIMPLE, "CSatPluginMonitor::~CSatPluginMonitor calling" ) |
|
53 iIdleAppStatus = NULL; |
|
54 Cancel(); |
|
55 iIdleMode.Close(); |
|
56 LOG( SIMPLE, "CSatPluginMonitor::~CSatPluginMonitor exits" ) |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // Start monitor the P&S key. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 TInt CSatPluginMonitor::Start( TRequestStatus& aStatus ) |
|
64 { |
|
65 LOG( SIMPLE, "CSatPluginMonitor::StartMonitor calling" ) |
|
66 TInt err ( KErrNotReady ); |
|
67 |
|
68 if ( !iIdleAppStatus && !IsActive() ) |
|
69 { |
|
70 aStatus = KRequestPending; |
|
71 iIdleAppStatus = &aStatus; |
|
72 iIdleMode.Subscribe( iStatus ); |
|
73 SetActive(); |
|
74 err = KErrNone; |
|
75 LOG( DETAILED, "CSatPluginMonitor::StartMonitor subscribe the P&S key" ) |
|
76 } |
|
77 |
|
78 LOG2( SIMPLE, "CSatPluginMonitor::StartMonitor exits, err: %d", err ) |
|
79 return err; |
|
80 } |
|
81 |
|
82 // ----------------------------------------------------------------------------- |
|
83 // Get idle mode text |
|
84 // ----------------------------------------------------------------------------- |
|
85 // |
|
86 TInt CSatPluginMonitor::GetIdleModeText( HBufC*& aText ) |
|
87 { |
|
88 LOG( SIMPLE, "CSatPluginMonitor::GetIdleModeText calling" ) |
|
89 TInt err ( KErrNoMemory ); |
|
90 |
|
91 // Make the function no-leave. |
|
92 aText = HBufC::New( RSat::KIdleModeTextMaxSize ); |
|
93 if( aText ) |
|
94 { |
|
95 TPtr txtPtr( aText->Des() ); |
|
96 err = RProperty::Get( KPSUidSatServerInternal, |
|
97 KSatIdleModeText, |
|
98 txtPtr ); |
|
99 if ( KErrNone != err ) |
|
100 { |
|
101 delete aText; |
|
102 aText = NULL; |
|
103 } |
|
104 } |
|
105 LOG2( SIMPLE, |
|
106 "SATCLIENT::GetSetupIdleModeTextL text exits, error: %i", |
|
107 err ) |
|
108 return err; |
|
109 } |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // Get idle mode icon qualifier |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 TInt CSatPluginMonitor::GetIdleModeIconQualifier( TInt& aIconQualifier ) |
|
116 { |
|
117 LOG( SIMPLE, "CSatPluginMonitor::GetIdleModeIconQualifier calling" ) |
|
118 TInt err( KErrNone ); |
|
119 err = RProperty::Get( KPSUidSatServerInternal, |
|
120 KSatIdleModeTextIconQualifier, |
|
121 aIconQualifier ); |
|
122 LOG2( DETAILED, |
|
123 "SATCLIENT::GetSetupIdleModeTextL iconQualifier error: %i", |
|
124 err ) |
|
125 LOG2( SIMPLE, |
|
126 "SATCLIENT::GetSetupIdleModeTextL exits, iconQualifier: %i", |
|
127 aIconQualifier ) |
|
128 return err; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // Get idle mode icon id |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 TInt CSatPluginMonitor::GetIdleModeIconId( TInt& aRecordNumber ) |
|
136 { |
|
137 LOG( SIMPLE, "CSatPluginMonitor::GetIdleModeIconId calling" ) |
|
138 TInt err( KErrNone ); |
|
139 err = RProperty::Get( KPSUidSatServerInternal, |
|
140 KSatIdleModeTextIconId, |
|
141 aRecordNumber ); |
|
142 LOG2( DETAILED, |
|
143 "SATCLIENT::GetIdleModeIconId icon id error: %i", |
|
144 err ) |
|
145 LOG2( SIMPLE, |
|
146 "SATCLIENT: RSatService:GetIdleModeIconId exits, id: %i", |
|
147 aRecordNumber ) |
|
148 |
|
149 return err; |
|
150 } |
|
151 |
|
152 |
|
153 // ----------------------------------------------------------------------------- |
|
154 // Handles the request completion. |
|
155 // ----------------------------------------------------------------------------- |
|
156 // |
|
157 void CSatPluginMonitor::RunL() |
|
158 { |
|
159 LOG2( SIMPLE, "SATCLIENT::CSatPluginMonitor::RunL calling, \ |
|
160 iIdleAppStatus: %i", iIdleAppStatus ) |
|
161 |
|
162 if ( iIdleAppStatus ) |
|
163 { |
|
164 // Complete the request. |
|
165 User::RequestComplete( iIdleAppStatus, iStatus.Int() ); |
|
166 LOG2( DETAILED, "CSatPluginMonitor::RunL error: %i", iStatus.Int() ); |
|
167 |
|
168 iIdleAppStatus = NULL; |
|
169 } |
|
170 |
|
171 LOG( SIMPLE, "SATCLIENT::CSatPluginMonitor::RunL exits" ) |
|
172 } |
|
173 |
|
174 // ----------------------------------------------------------------------------- |
|
175 // Cancels the pending request |
|
176 // ----------------------------------------------------------------------------- |
|
177 // |
|
178 void CSatPluginMonitor::DoCancel() |
|
179 { |
|
180 LOG( SIMPLE, "CSatPluginMonitor::DoCancel calling" ) |
|
181 if ( iIdleAppStatus ) |
|
182 { |
|
183 User::RequestComplete( iIdleAppStatus, KErrCancel ); |
|
184 iIdleMode.Cancel(); |
|
185 |
|
186 iIdleAppStatus = NULL; |
|
187 } |
|
188 LOG( SIMPLE, "CSatPluginMonitor::DoCancel exits" ) |
|
189 } |
|
190 |
|
191 // ----------------------------------------------------------------------------- |
|
192 // Handles a leave occurring in the request completion event handler RunL() |
|
193 // ----------------------------------------------------------------------------- |
|
194 // |
|
195 TInt CSatPluginMonitor::RunError( TInt aError ) |
|
196 { |
|
197 LOG2( SIMPLE, "CSatPluginMonitor::RunError calling, error: %i", aError ) |
|
198 if ( iIdleAppStatus ) |
|
199 { |
|
200 // Complete the request. |
|
201 User::RequestComplete( iIdleAppStatus, aError ); |
|
202 iIdleMode.Cancel(); |
|
203 |
|
204 iIdleAppStatus = NULL; |
|
205 } |
|
206 LOG( SIMPLE, "CSatPluginMonitor::RunError exits" ) |
|
207 return aError; |
|
208 } |
|
209 // ----------------------------------------------------------------------------- |
|
210 // Symbian 2nd phase constructor can leave |
|
211 // ----------------------------------------------------------------------------- |
|
212 // |
|
213 void CSatPluginMonitor::ConstructL() |
|
214 { |
|
215 LOG( SIMPLE, "CSatPluginMonitor::ConstructL calling" ) |
|
216 |
|
217 TInt err = iIdleMode.Attach( KPSUidSatServerInternal, |
|
218 KSatIdleModeTextIconQualifier ); |
|
219 LOG2( DETAILED, "CSatPluginMonitor::ConstructL err: %i, exits", err ) |
|
220 |
|
221 User::LeaveIfError( err ); |
|
222 } |
|
223 |
|
224 // ----------------------------------------------------------------------------- |
|
225 // Default constructor |
|
226 // ----------------------------------------------------------------------------- |
|
227 // |
|
228 CSatPluginMonitor::CSatPluginMonitor() : |
|
229 CActive( EPriorityStandard ) |
|
230 { |
|
231 LOG( SIMPLE, "CSatPluginMonitor::ConstructL calling" ) |
|
232 CActiveScheduler::Add( this ); |
|
233 LOG( SIMPLE, "CSatPluginMonitor::ConstructL exits" ) |
|
234 } |
|
235 |
|
236 // End of File |
|