|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 /** |
|
17 @file |
|
18 */ |
|
19 |
|
20 #include "CAgentSMBase.h" |
|
21 #include "dialogprocessor.h" |
|
22 #include "AgentPanic.h" |
|
23 #include "Ni_Log.h" |
|
24 |
|
25 |
|
26 NONSHARABLE_CLASS(CDialogDestroyPCTNotification) : public CActive |
|
27 /** |
|
28 Declaration of this private class - forward reference in dialogprocessor.h |
|
29 */ |
|
30 { |
|
31 public: |
|
32 CDialogDestroyPCTNotification(RGenConAgentDialogServer* aDialogSvr, |
|
33 CDialogProcessor* aDlgPrc, |
|
34 TInt aPriority = CActive::EPriorityStandard); |
|
35 virtual ~CDialogDestroyPCTNotification(); |
|
36 void RequestNotification(); |
|
37 private: |
|
38 |
|
39 /** From CActive */ |
|
40 virtual void DoCancel(); |
|
41 virtual void RunL(); |
|
42 private: |
|
43 RGenConAgentDialogServer* iDialogSvr; |
|
44 CDialogProcessor* iDlgPrc; |
|
45 }; |
|
46 |
|
47 // |
|
48 // MDialogProcessorObserver |
|
49 // |
|
50 |
|
51 EXPORT_C void MDialogProcessorObserver::MDPOSelectComplete(TInt /*aError*/, const TConnectionSettings& /*aSettings*/) |
|
52 { AgentPanic(Agent::EDialogProcessorSelectObserverNotImplemented); } |
|
53 |
|
54 EXPORT_C void MDialogProcessorObserver::MDPOSelectModemAndLocationComplete(TInt /*aError*/, const TConnectionSettings& /*aSettings*/) |
|
55 { AgentPanic(Agent::EDialogProcessorSelectModemAndLocationObserverNotImplemented); } |
|
56 |
|
57 EXPORT_C void MDialogProcessorObserver::MDPOWarnComplete(TInt /*aError*/, TBool /*aResponse*/) |
|
58 { AgentPanic(Agent::EDialogProcessorWarnObserverNotImplemented); } |
|
59 |
|
60 EXPORT_C void MDialogProcessorObserver::MDPOLoginComplete(TInt /*aError*/) |
|
61 { AgentPanic(Agent::EDialogProcessorLoginObserverNotImplemented); } |
|
62 |
|
63 EXPORT_C void MDialogProcessorObserver::MDPOAuthenticateComplete(TInt /*aError*/) |
|
64 { AgentPanic(Agent::EDialogProcessorAuthObserverNotImplemented); } |
|
65 |
|
66 EXPORT_C void MDialogProcessorObserver::MDPOReconnectComplete(TInt /*aError*/) |
|
67 { AgentPanic(Agent::EDialogProcessorReconnectObserverNotImplemented); } |
|
68 |
|
69 EXPORT_C void MDialogProcessorObserver::MDPOReadPctComplete(TInt /*aError*/) |
|
70 { AgentPanic(Agent::EDialogProcessorReadPctObserverNotImplemented); } |
|
71 |
|
72 EXPORT_C void MDialogProcessorObserver::MDPODestroyPctComplete(TInt /*aError*/) |
|
73 { AgentPanic(Agent::EDialogProcessorDestroyPctObserverNotImplemented); } |
|
74 |
|
75 EXPORT_C void MDialogProcessorObserver::MDPOQoSWarningComplete(TInt /*aError*/, TBool /*aResponse*/) |
|
76 { AgentPanic(Agent::EDialogProcessorWarnQoSObserverNotImplemented); } |
|
77 |
|
78 // |
|
79 // CDialogProcessor definitions |
|
80 // |
|
81 |
|
82 EXPORT_C CDialogProcessor* CDialogProcessor::NewL(TInt aPriority) |
|
83 { |
|
84 CDialogProcessor* self = new(ELeave) CDialogProcessor(aPriority); |
|
85 CleanupStack::PushL(self); |
|
86 self->ConstructL(); |
|
87 CleanupStack::Pop(); // self |
|
88 return self; |
|
89 } |
|
90 |
|
91 CDialogProcessor::CDialogProcessor(TInt aPriority) |
|
92 : CActive(aPriority) |
|
93 {} |
|
94 |
|
95 void CDialogProcessor::ConstructL() |
|
96 { |
|
97 CActiveScheduler::Add(this); |
|
98 TInt ret = iDlgServ.Connect(); |
|
99 LOG(NifmanLog::Printf(_L("CDialogProcessor::ConstructL - Connect returned %d"),ret); ) |
|
100 User::LeaveIfError(ret); |
|
101 iDestroyPctNotification = new(ELeave) CDialogDestroyPCTNotification(&iDlgServ,this); |
|
102 iState = ENoState; |
|
103 } |
|
104 |
|
105 EXPORT_C CDialogProcessor::~CDialogProcessor() |
|
106 { |
|
107 CancelEverything(); |
|
108 delete iDestroyPctNotification; |
|
109 iDlgServ.Close(); |
|
110 } |
|
111 |
|
112 EXPORT_C void CDialogProcessor::SelectConnection(MDialogProcessorObserver& aObserver, const TConnectionPrefs& aPrefs) |
|
113 /** |
|
114 Request connection dialog |
|
115 */ |
|
116 { |
|
117 iDlgServ.IapConnection(iSettings.iIAPId, aPrefs, iStatus); |
|
118 |
|
119 SetActive(aObserver,ESelectConnection); |
|
120 } |
|
121 |
|
122 EXPORT_C void CDialogProcessor::SelectConnection(MDialogProcessorObserver& aObserver, const TConnectionPrefs& aPrefs, TInt aLastError) |
|
123 |
|
124 /** |
|
125 Request connection dialog |
|
126 */ |
|
127 { |
|
128 iDlgServ.IapConnection(iSettings.iIAPId, aPrefs, aLastError, iStatus); |
|
129 |
|
130 SetActive(aObserver,ESelectConnection); |
|
131 } |
|
132 |
|
133 EXPORT_C void CDialogProcessor::SelectModemAndLocation(MDialogProcessorObserver& aObserver) |
|
134 /** |
|
135 Request Modem Dialog |
|
136 */ |
|
137 { |
|
138 iDlgServ.ModemAndLocationSelection(iSettings.iBearerId,iSettings.iLocationId,iStatus); |
|
139 SetActive(aObserver,ESelectModemAndLocation); |
|
140 } |
|
141 |
|
142 EXPORT_C void CDialogProcessor::Authenticate(MDialogProcessorObserver& aObserver, TDes& aUsername,TDes& aPassword,TBool aIsReconnect) |
|
143 /** |
|
144 Request authentication dialog |
|
145 */ |
|
146 { |
|
147 iDlgServ.Authenticate(aUsername,aPassword,aIsReconnect,iStatus); |
|
148 SetActive(aObserver,EAuthentication); |
|
149 } |
|
150 |
|
151 EXPORT_C void CDialogProcessor::Reconnect(MDialogProcessorObserver& aObserver) |
|
152 /** |
|
153 Request reconnect dialog |
|
154 */ |
|
155 { |
|
156 iDlgServ.Reconnect(iReconResponse,iStatus); |
|
157 SetActive(aObserver,EReconnect); |
|
158 } |
|
159 |
|
160 EXPORT_C void CDialogProcessor::WarnNewConnection(MDialogProcessorObserver& aObserver, const TConnectionPrefs& aPrefs, const TDesC* aNewIapName, const TIspConnectionNames*, TInt aLastError) |
|
161 /** |
|
162 Warn of new connection dialog |
|
163 */ |
|
164 { |
|
165 __ASSERT_DEBUG(aNewIapName, AgentPanic(Agent::ENullWarnParameter)); |
|
166 iDlgServ.WarnNewIapConnection(aPrefs, aLastError, *aNewIapName, iWarnNewConnectResponse, iStatus); |
|
167 |
|
168 SetActive(aObserver,EWarnNewConnection); |
|
169 } |
|
170 |
|
171 EXPORT_C void CDialogProcessor::Login(MDialogProcessorObserver& aObserver, TDes& aUsername, TDes& aPassword,TBool aIsReconnect) |
|
172 /** |
|
173 Request login dialog |
|
174 */ |
|
175 { |
|
176 iDlgServ.Login(aUsername,aPassword,aIsReconnect,iStatus); |
|
177 SetActive(aObserver,ELogin); |
|
178 } |
|
179 |
|
180 EXPORT_C void CDialogProcessor::DestroyPctNotification(MDialogProcessorObserver& aObserver) |
|
181 /** |
|
182 Request notification on destruction of PCT. |
|
183 */ |
|
184 { |
|
185 iDestroyPctNotification->RequestNotification(); |
|
186 iPctDestructionObserver = &aObserver; |
|
187 } |
|
188 |
|
189 EXPORT_C void CDialogProcessor::ReadPct(MDialogProcessorObserver& aObserver, TDes& aData) |
|
190 /** |
|
191 Request read from PCT and return read string in aData |
|
192 */ |
|
193 { |
|
194 iDlgServ.ReadPct(aData,iStatus); |
|
195 SetActive(aObserver,EReadPct); |
|
196 } |
|
197 |
|
198 EXPORT_C void CDialogProcessor::QoSWarning(MDialogProcessorObserver& aObserver) |
|
199 /** |
|
200 Warn QoS has fallen below minimum values |
|
201 */ |
|
202 { |
|
203 iDlgServ.QoSWarning(iQoSWarningResponse, iStatus); |
|
204 SetActive(aObserver,EQoSWarning); |
|
205 } |
|
206 |
|
207 EXPORT_C TInt CDialogProcessor::OpenPct() |
|
208 /** |
|
209 Request open of PCT |
|
210 */ |
|
211 { |
|
212 return iDlgServ.OpenPct(); |
|
213 } |
|
214 |
|
215 EXPORT_C TInt CDialogProcessor::WritePct(const TDesC& aData) |
|
216 /** |
|
217 Request write aData to PCT |
|
218 */ |
|
219 { |
|
220 return iDlgServ.WritePct(aData); |
|
221 } |
|
222 |
|
223 EXPORT_C void CDialogProcessor::ClosePct() |
|
224 /** |
|
225 Request close of PCT |
|
226 */ |
|
227 { |
|
228 iDlgServ.ClosePct(); |
|
229 } |
|
230 |
|
231 EXPORT_C void CDialogProcessor::CancelEverything() |
|
232 /** |
|
233 Cancel the active object waiting on the destroy pct notification |
|
234 and then everything else outstanding |
|
235 */ |
|
236 { |
|
237 if (iDestroyPctNotification) |
|
238 { |
|
239 iDestroyPctNotification->Cancel(); |
|
240 // Null the observer pointer, the observer is owned by other objects! |
|
241 iPctDestructionObserver = NULL; |
|
242 } |
|
243 |
|
244 Cancel(); |
|
245 } |
|
246 |
|
247 void CDialogProcessor::CompleteDestroyPctNotification(TInt aStatus) |
|
248 /** |
|
249 Complete notification on destruction of PCT |
|
250 */ |
|
251 { |
|
252 if (iPctDestructionObserver) |
|
253 { |
|
254 iPctDestructionObserver->MDPODestroyPctComplete(aStatus); |
|
255 // Null the observer pointer, the observer is owned by other objects! |
|
256 iPctDestructionObserver = NULL; |
|
257 } |
|
258 } |
|
259 |
|
260 void CDialogProcessor::SetActive(MDialogProcessorObserver& aObserver, TDPState aState) |
|
261 { |
|
262 __ASSERT_DEBUG(!iCurrentObserver, AgentPanic(Agent::EObserverNotNull)); |
|
263 |
|
264 iCurrentObserver = &aObserver; |
|
265 iState = aState; |
|
266 CActive::SetActive(); |
|
267 } |
|
268 |
|
269 void CDialogProcessor::RunL() |
|
270 { |
|
271 __ASSERT_DEBUG(iCurrentObserver, AgentPanic(Agent::EObserverNull)); |
|
272 |
|
273 const TDPState state = iState; |
|
274 iState = ENoState; |
|
275 MDialogProcessorObserver* currentObserver = iCurrentObserver; |
|
276 iCurrentObserver = NULL; |
|
277 |
|
278 switch (state) |
|
279 { |
|
280 case ESelectConnection: |
|
281 currentObserver->MDPOSelectComplete(iStatus.Int(),iSettings); |
|
282 break; |
|
283 case EWarnNewConnection: |
|
284 currentObserver->MDPOWarnComplete(iStatus.Int(),iWarnNewConnectResponse); |
|
285 break; |
|
286 case ESelectModemAndLocation: |
|
287 currentObserver->MDPOSelectModemAndLocationComplete(iStatus.Int(),iSettings); |
|
288 break; |
|
289 case ELogin: |
|
290 currentObserver->MDPOLoginComplete(iStatus.Int()); |
|
291 break; |
|
292 case EAuthentication: |
|
293 currentObserver->MDPOAuthenticateComplete(iStatus.Int()); |
|
294 break; |
|
295 case EReconnect: |
|
296 if(iReconResponse) |
|
297 currentObserver->MDPOReconnectComplete(KErrNone); |
|
298 else |
|
299 currentObserver->MDPOReconnectComplete(KErrCancel); |
|
300 break; |
|
301 case EReadPct: |
|
302 currentObserver->MDPOReadPctComplete(iStatus.Int()); |
|
303 break; |
|
304 case EQoSWarning: |
|
305 currentObserver->MDPOQoSWarningComplete(iStatus.Int(),iQoSWarningResponse); |
|
306 break; |
|
307 default: |
|
308 User::Leave(KErrGeneral); |
|
309 break; |
|
310 } |
|
311 } |
|
312 |
|
313 void CDialogProcessor::DoCancel() |
|
314 /** |
|
315 Only called if CDialogProcessor is active (Could be inactive while iDestroyPctNotification |
|
316 is still active so should call CancelEverything() instead if pct around) |
|
317 */ |
|
318 { |
|
319 __ASSERT_DEBUG(!iPctDestructionObserver, AgentPanic(Agent::EDestroyNotificationNotCancelled)); |
|
320 |
|
321 switch (iState) |
|
322 { |
|
323 case ESelectConnection: |
|
324 iDlgServ.CancelIapConnection(); |
|
325 break; |
|
326 case ESelectModemAndLocation: |
|
327 iDlgServ.CancelModemAndLocationSelection(); |
|
328 break; |
|
329 case EWarnNewConnection: |
|
330 iDlgServ.CancelWarnNewIapConnection(); |
|
331 break; |
|
332 case ELogin: |
|
333 iDlgServ.CancelLogin(); |
|
334 break; |
|
335 case EAuthentication: |
|
336 iDlgServ.CancelAuthenticate(); |
|
337 break; |
|
338 case EReconnect: |
|
339 iDlgServ.CancelReconnect(); |
|
340 break; |
|
341 case EReadPct: |
|
342 iDlgServ.CancelReadPct(); |
|
343 break; |
|
344 case EQoSWarning: |
|
345 iDlgServ.CancelQoSWarning(); |
|
346 break; |
|
347 default: |
|
348 AgentPanic(Agent::EIllegalActionType); |
|
349 break; |
|
350 } |
|
351 |
|
352 iState = ENoState; |
|
353 iCurrentObserver = NULL; |
|
354 } |
|
355 |
|
356 // |
|
357 // CDialogDestroyPCTNotification |
|
358 // |
|
359 |
|
360 CDialogDestroyPCTNotification::CDialogDestroyPCTNotification(RGenConAgentDialogServer* aDialogSvr, |
|
361 CDialogProcessor* aDlgPrc, |
|
362 TInt aPriority) |
|
363 : CActive(aPriority), iDialogSvr(aDialogSvr), iDlgPrc(aDlgPrc) |
|
364 { |
|
365 CActiveScheduler::Add(this); |
|
366 } |
|
367 |
|
368 CDialogDestroyPCTNotification::~CDialogDestroyPCTNotification() |
|
369 { |
|
370 Cancel(); |
|
371 } |
|
372 |
|
373 void CDialogDestroyPCTNotification::RequestNotification() |
|
374 /** |
|
375 Request notification when the PCT is destroyed |
|
376 */ |
|
377 { |
|
378 iDialogSvr->DestroyPctNotification(iStatus); |
|
379 SetActive(); |
|
380 } |
|
381 |
|
382 void CDialogDestroyPCTNotification::DoCancel() |
|
383 /** |
|
384 This will cancel any oustanding requests and cause the destroy notification to complete - which will |
|
385 get caught by the CActive::Cancel() |
|
386 */ |
|
387 { |
|
388 iDialogSvr->CancelDestroyPctNotification(); |
|
389 } |
|
390 |
|
391 void CDialogDestroyPCTNotification::RunL() |
|
392 /** |
|
393 Received notification |
|
394 */ |
|
395 { |
|
396 iDlgPrc->CompleteDestroyPctNotification(iStatus.Int()); |
|
397 } |
|
398 |