|
1 /* |
|
2 * Copyright (c) 2004 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: Connection mode rewaker. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <E32std.h> |
|
20 #include <PEngWVPresenceErrors2.h> |
|
21 |
|
22 #include "CCnUiConnModeRewaker.h" |
|
23 #include "MCnUiClientPlugin.h" |
|
24 #include "CnUiErrors.h" |
|
25 |
|
26 #include "IMPSCommonUiDebugPrint.h" |
|
27 |
|
28 |
|
29 //CONSTANTS |
|
30 const TInt KReWakeUserActivityTimeout = 30000000; //30 seconds, defined in UI specification |
|
31 |
|
32 |
|
33 |
|
34 // ================= LOCAL FUNCTIONS ======================= |
|
35 // ----------------------------------------------------------------------------- |
|
36 // ResumeRewakeStatic() |
|
37 // ----------------------------------------------------------------------------- |
|
38 // |
|
39 void ResumeRewakeStatic( TAny* aRewaker ) |
|
40 { |
|
41 CCnUiConnModeRewaker* p = static_cast< CCnUiConnModeRewaker* >( aRewaker ); |
|
42 p->ResumeRewake(); |
|
43 } |
|
44 |
|
45 |
|
46 |
|
47 // ================= MEMBER FUNCTIONS ======================= |
|
48 // Two-phased constructor. |
|
49 CCnUiConnModeRewaker* CCnUiConnModeRewaker::NewL() |
|
50 { |
|
51 CCnUiConnModeRewaker* self = new ( ELeave ) CCnUiConnModeRewaker(); |
|
52 CleanupStack::PushL( self ); |
|
53 self->ConstructL(); |
|
54 CleanupStack::Pop( self ); //self |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // Destructor |
|
60 CCnUiConnModeRewaker::~CCnUiConnModeRewaker() |
|
61 { |
|
62 Cancel(); |
|
63 |
|
64 //Rewaker is closing down. Issue possibly pending rewakes now. |
|
65 //Raising errors can be only ignored.. |
|
66 TInt ignore; |
|
67 TRAP( ignore, RewakeRegisteredClientsL() ); |
|
68 |
|
69 iAAClntsToRewake.ResetAndDestroy(); |
|
70 } |
|
71 |
|
72 |
|
73 // C++ default constructor can NOT contain any code, that |
|
74 // might leave. |
|
75 // |
|
76 CCnUiConnModeRewaker::CCnUiConnModeRewaker() |
|
77 : CTimer( CActive::EPriorityStandard ) |
|
78 { |
|
79 } |
|
80 |
|
81 |
|
82 // Symbian OS default constructor can leave. |
|
83 void CCnUiConnModeRewaker::ConstructL() |
|
84 { |
|
85 CTimer::ConstructL(); |
|
86 CActiveScheduler::Add( this ); |
|
87 } |
|
88 |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CCnUiConnModeRewaker::AddToAAModeRewakeListL() |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CCnUiConnModeRewaker::AddToAAModeRewakeListL( MCnUiClientPlugin& aClientPlugin, |
|
95 CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
96 { |
|
97 if ( aClientPlugin.CurrentConnectionModeSettingL() == ECnUiCMAutomatic ) |
|
98 { |
|
99 const TIMPSConnectionClient client = aClientPlugin.ClientID(); |
|
100 if ( !ClientAlreadyReqistered( client ) ) |
|
101 { |
|
102 //Make a own copy of plug-in object |
|
103 MCnUiClientPlugin* cPlugin = CreateClientPluginL( client, aNWSessionSlotID ); |
|
104 TInt err = iAAClntsToRewake.Append( cPlugin ); |
|
105 if ( err != KErrNone ) |
|
106 { |
|
107 delete cPlugin; |
|
108 User::Leave( err ); |
|
109 } |
|
110 |
|
111 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiConnModeRewaker::AddToAAModeRewakeListL( added client[%d] )" ), client ); |
|
112 } |
|
113 } |
|
114 } |
|
115 |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CCnUiConnModeRewaker::GetAARewakeListL() |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 void CCnUiConnModeRewaker::GetAARewakeListL( RArray< TIMPSConnectionClient >& aAARewakedClients ) |
|
122 { |
|
123 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiConnModeRewaker::GetAARewakeListL( %d clients on the list)" ), iAAClntsToRewake.Count() ); |
|
124 |
|
125 aAARewakedClients.Reset(); |
|
126 |
|
127 const TInt AARewakeCount = iAAClntsToRewake.Count(); |
|
128 for ( TInt ii = 0; ii < AARewakeCount; ii++ ) |
|
129 { |
|
130 MCnUiClientPlugin* cPlugin = iAAClntsToRewake[ ii ]; |
|
131 const TIMPSConnectionClient client = cPlugin->ClientID(); |
|
132 User::LeaveIfError( aAARewakedClients.Append( client ) ); |
|
133 } |
|
134 } |
|
135 |
|
136 |
|
137 // ----------------------------------------------------------------------------- |
|
138 // CCnUiConnModeRewaker::ClearAARewakeList() |
|
139 // ----------------------------------------------------------------------------- |
|
140 // |
|
141 void CCnUiConnModeRewaker::ClearAARewakeList() |
|
142 { |
|
143 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiConnModeRewaker::ClearAARewakeList()" ) ); |
|
144 iAAClntsToRewake.ResetAndDestroy(); |
|
145 } |
|
146 |
|
147 |
|
148 // ----------------------------------------------------------------------------- |
|
149 // CCnUiConnModeRewaker::RemoveFromAARewakeList() |
|
150 // ----------------------------------------------------------------------------- |
|
151 // |
|
152 void CCnUiConnModeRewaker::RemoveFromAARewakeList( TIMPSConnectionClient aClient ) |
|
153 { |
|
154 TInt ii = ( iAAClntsToRewake.Count() - 1 ); //last index is 1 smaller than total count |
|
155 for ( ; ii >= 0; ii-- ) |
|
156 { |
|
157 MCnUiClientPlugin* cPlugin = iAAClntsToRewake[ ii ]; |
|
158 if ( cPlugin->ClientID() == aClient ) |
|
159 { |
|
160 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiConnModeRewaker::RemoveFromAARewakeList( removed client [%d] )" ), aClient ); |
|
161 iAAClntsToRewake.Remove( ii ); |
|
162 delete cPlugin; |
|
163 } |
|
164 } |
|
165 } |
|
166 |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CCnUiConnModeRewaker::SuspendLC() |
|
170 // ----------------------------------------------------------------------------- |
|
171 // |
|
172 void CCnUiConnModeRewaker::SuspendLC() |
|
173 { |
|
174 //Cancel the possibly running timer |
|
175 Cancel(); |
|
176 |
|
177 //And push Resume operation to cleanup stack |
|
178 CleanupStack::PushL( TCleanupItem( ResumeRewakeStatic, this ) ); |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // CCnUiConnModeRewaker::ResumeRewake() |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CCnUiConnModeRewaker::ResumeRewake() |
|
187 { |
|
188 //Cancel the possibly running timer |
|
189 Cancel(); |
|
190 |
|
191 //And issue new timer event |
|
192 if ( iAAClntsToRewake.Count() > 0 ) |
|
193 { |
|
194 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiConnModeRewaker::ResumeRewake() - starting timeout timer for %d clients" ), iAAClntsToRewake.Count() ); |
|
195 After( KReWakeUserActivityTimeout ); |
|
196 } |
|
197 } |
|
198 |
|
199 |
|
200 // ----------------------------------------------------------------------------- |
|
201 // CCnUiConnModeRewaker::RunL() |
|
202 // ----------------------------------------------------------------------------- |
|
203 // |
|
204 void CCnUiConnModeRewaker::RunL() |
|
205 { |
|
206 RewakeRegisteredClientsL(); |
|
207 } |
|
208 |
|
209 |
|
210 // ----------------------------------------------------------------------------- |
|
211 // CCnUiConnModeRewaker::RunError() |
|
212 // ----------------------------------------------------------------------------- |
|
213 // |
|
214 TInt CCnUiConnModeRewaker::RunError( TInt aError ) |
|
215 { |
|
216 iAAClntsToRewake.ResetAndDestroy(); |
|
217 return aError; |
|
218 } |
|
219 |
|
220 |
|
221 // ----------------------------------------------------------------------------- |
|
222 // CCnUiConnModeRewaker::RewakeRegisteredClientsL() |
|
223 // ----------------------------------------------------------------------------- |
|
224 // |
|
225 void CCnUiConnModeRewaker::RewakeRegisteredClientsL() |
|
226 { |
|
227 const TInt clientsToReWakeCount = iAAClntsToRewake.Count(); |
|
228 for ( TInt ii = 0; ii < clientsToReWakeCount; ii++ ) |
|
229 { |
|
230 MCnUiClientPlugin* cPlugin = iAAClntsToRewake[ ii ]; |
|
231 IMPSCUI_DP( D_IMPSCUI_LIT( "CCnUiConnModeRewaker::RewakeRegisteredClientsL( waking client [%d] )" ), cPlugin->ClientID() ); |
|
232 cPlugin->ReWakeAutomaticConnectionModeL(); |
|
233 } |
|
234 |
|
235 iAAClntsToRewake.ResetAndDestroy(); |
|
236 } |
|
237 |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // CCnUiConnModeRewaker::ClientAlreadyReqistered() |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 TBool CCnUiConnModeRewaker::ClientAlreadyReqistered( TIMPSConnectionClient aClient ) |
|
244 { |
|
245 const TInt reqisteredClientsCount = iAAClntsToRewake.Count(); |
|
246 for ( TInt ii = 0; ii < reqisteredClientsCount; ii++ ) |
|
247 { |
|
248 MCnUiClientPlugin* cPlugin = iAAClntsToRewake[ ii ]; |
|
249 if ( cPlugin->ClientID() == aClient ) |
|
250 { |
|
251 return ETrue; |
|
252 } |
|
253 } |
|
254 |
|
255 return EFalse; |
|
256 } |
|
257 |
|
258 |
|
259 // End of File |