1 /* |
|
2 * Copyright (c) 2007 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 progress notifier |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <es_sock.h> |
|
20 #include <in_iface.h> |
|
21 #include "dhcppsy.hrh" |
|
22 #include "dhcppsylogging.h" |
|
23 #include "dhcpconnectionstateobserver.h" |
|
24 #include "dhcpconnectionprogressnotifier.h" |
|
25 |
|
26 // --------------------------------------------------------------------------- |
|
27 // Statical constructor |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 CDhcpConnectionProgressNotifier* CDhcpConnectionProgressNotifier::NewL(RConnection& aConnection, |
|
31 MDhcpConnectionStateObserver* aObserver) |
|
32 { |
|
33 CDhcpConnectionProgressNotifier* self = new (ELeave) |
|
34 CDhcpConnectionProgressNotifier (aConnection, aObserver); |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(); |
|
37 CleanupStack::Pop (self); |
|
38 return self; |
|
39 } |
|
40 |
|
41 // --------------------------------------------------------------------------- |
|
42 // Destructor |
|
43 // --------------------------------------------------------------------------- |
|
44 // |
|
45 CDhcpConnectionProgressNotifier::~CDhcpConnectionProgressNotifier () |
|
46 { |
|
47 Cancel(); |
|
48 } |
|
49 |
|
50 // --------------------------------------------------------------------------- |
|
51 // Second-phase constructor which can leave. |
|
52 // --------------------------------------------------------------------------- |
|
53 // |
|
54 void CDhcpConnectionProgressNotifier::ConstructL() |
|
55 { |
|
56 iConnection.ProgressNotification(iProgress, iStatus); |
|
57 SetActive(); |
|
58 } |
|
59 |
|
60 // --------------------------------------------------------------------------- |
|
61 // RunL |
|
62 // --------------------------------------------------------------------------- |
|
63 // |
|
64 void CDhcpConnectionProgressNotifier::RunL() |
|
65 { |
|
66 TRACESTRING2( "CDhcpConnectionProgressNotifier::RunL, %d", iProgress().iStage); |
|
67 switch (iProgress().iStage) |
|
68 { |
|
69 case KConnectionUninitialised: |
|
70 { |
|
71 // Connection unitialised |
|
72 iState = EDhcpConnectStateNotConnected; |
|
73 } |
|
74 break; |
|
75 case KStartingSelection: |
|
76 { |
|
77 // Starting connetion selection |
|
78 iState = EDhcpConnectStateConnecting; |
|
79 } |
|
80 break; |
|
81 case KFinishedSelection: |
|
82 { |
|
83 // Selection finished |
|
84 if (iProgress().iError == KErrNone) |
|
85 { |
|
86 // The user successfully selected an IAP to be used |
|
87 iState = EDhcpConnectStateConnecting; |
|
88 } |
|
89 else |
|
90 { |
|
91 iState = EDhcpConnectStateNotConnected; |
|
92 } |
|
93 } |
|
94 break; |
|
95 case KConnectionFailure: |
|
96 { |
|
97 // Connection failure |
|
98 iState = EDhcpConnectStateNotConnected; |
|
99 } |
|
100 break; |
|
101 case KPsdStartingConfiguration: |
|
102 case KPsdFinishedConfiguration: |
|
103 case KCsdFinishedDialling: |
|
104 case KCsdScanningScript: |
|
105 case KCsdGettingLoginInfo: |
|
106 case KCsdGotLoginInfo: |
|
107 { |
|
108 // Prepearing connection (e.g. dialing) |
|
109 iState = EDhcpConnectStateConnecting; |
|
110 } |
|
111 break; |
|
112 case KCsdStartingConnect: |
|
113 case KCsdFinishedConnect: |
|
114 { |
|
115 // Creating connection (e.g. GPRS activation) |
|
116 iState = EDhcpConnectStateConnecting; |
|
117 } |
|
118 break; |
|
119 case KCsdStartingLogIn: |
|
120 { |
|
121 // Starting log in |
|
122 iState = EDhcpConnectStateConnecting; |
|
123 } |
|
124 break; |
|
125 case KCsdFinishedLogIn: |
|
126 { |
|
127 // Finished login |
|
128 iState = EDhcpConnectStateConnecting; |
|
129 } |
|
130 break; |
|
131 case KConnectionOpen: |
|
132 { |
|
133 iState = EDhcpConnectStateConnecting; |
|
134 } |
|
135 break; |
|
136 case KLinkLayerOpen: |
|
137 { |
|
138 // Connection open |
|
139 iState = EDhcpConnectStateConnected; |
|
140 } |
|
141 break; |
|
142 case KDataTransferTemporarilyBlocked: |
|
143 { |
|
144 // Connection blocked or suspended |
|
145 iState = EDhcpConnectStateConnected; |
|
146 } |
|
147 break; |
|
148 |
|
149 case KConnectionStartingClose: |
|
150 { |
|
151 // Hangup or GRPS deactivation |
|
152 iState = EDhcpConnectStateDisconnecting; |
|
153 } |
|
154 break; |
|
155 |
|
156 case KConnectionClosed: |
|
157 case KLinkLayerClosed: |
|
158 { |
|
159 // Connection closed |
|
160 iState = EDhcpConnectStateNotConnected; |
|
161 } |
|
162 break; |
|
163 default: |
|
164 { |
|
165 // Unhandled state |
|
166 iState = EDhcpConnectStateUnknown; |
|
167 } |
|
168 break; |
|
169 } |
|
170 iObserver->StateChangedL(); |
|
171 iConnection.ProgressNotification(iProgress, iStatus); |
|
172 SetActive(); |
|
173 } |
|
174 |
|
175 // --------------------------------------------------------------------------- |
|
176 // GetState |
|
177 // --------------------------------------------------------------------------- |
|
178 // |
|
179 TInt CDhcpConnectionProgressNotifier::GetState () |
|
180 { |
|
181 return iState; |
|
182 } |
|
183 |
|
184 // --------------------------------------------------------------------------- |
|
185 // DoCancel |
|
186 // --------------------------------------------------------------------------- |
|
187 // |
|
188 void CDhcpConnectionProgressNotifier::DoCancel () |
|
189 { |
|
190 TRACESTRING( "CDhcpConnectionProgressNotifier::DoCancel"); |
|
191 iConnection.CancelProgressNotification(); |
|
192 } |
|
193 |
|
194 // --------------------------------------------------------------------------- |
|
195 // CDhcpConnectionProgressNotifier |
|
196 // --------------------------------------------------------------------------- |
|
197 // |
|
198 CDhcpConnectionProgressNotifier::CDhcpConnectionProgressNotifier (RConnection& aConnection, |
|
199 MDhcpConnectionStateObserver* aObserver) : |
|
200 CActive ( EPriorityStandard ), iConnection (aConnection), |
|
201 iObserver (aObserver) |
|
202 { |
|
203 CActiveScheduler::Add (this); |
|
204 } |
|
205 |
|
206 // End of file |
|