|
1 // Copyright (c) 2003-2010 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 #include <commdbconnpref.h> |
|
16 #include <es_sock.h> |
|
17 #include "CConnectionMonitor.h" |
|
18 #include "chttpnetworkconnectioninfo.h" |
|
19 |
|
20 CConnectionMonitor* CConnectionMonitor::NewL(CHttpNetworkConnection* aNetworkConn ) |
|
21 { |
|
22 CConnectionMonitor* self = NewLC( aNetworkConn ); |
|
23 CleanupStack::Pop( self ); |
|
24 return self; |
|
25 } |
|
26 |
|
27 CConnectionMonitor* CConnectionMonitor::NewLC( CHttpNetworkConnection* aNetworkConn ) |
|
28 { |
|
29 CConnectionMonitor* self = new (ELeave) CConnectionMonitor( aNetworkConn ); |
|
30 CleanupStack::PushL( self ); |
|
31 self->ConstructL(); |
|
32 return self; |
|
33 } |
|
34 |
|
35 CConnectionMonitor::CConnectionMonitor( CHttpNetworkConnection* aNetworkConnInfo ) |
|
36 : CActive(CActive::EPriorityStandard) |
|
37 { |
|
38 iNetworkConnInfo = aNetworkConnInfo; |
|
39 CActiveScheduler::Add(this); |
|
40 } |
|
41 |
|
42 CConnectionMonitor::~CConnectionMonitor() |
|
43 { |
|
44 Cancel(); |
|
45 } |
|
46 |
|
47 RConnection CConnectionMonitor::Connection() |
|
48 { |
|
49 return iNetworkConnInfo->Connection(); |
|
50 } |
|
51 |
|
52 void CConnectionMonitor::ConstructL() |
|
53 { |
|
54 iNetworkConnInfo->Connection().ProgressNotification(iProgress, iStatus); |
|
55 SetActive(); |
|
56 } |
|
57 |
|
58 void CConnectionMonitor::DoCancel() |
|
59 { |
|
60 iNetworkConnInfo->Connection().CancelProgressNotification(); |
|
61 } |
|
62 |
|
63 void CConnectionMonitor::RunL() |
|
64 { |
|
65 |
|
66 |
|
67 switch ( iProgress().iStage ) |
|
68 { |
|
69 |
|
70 // Connection closed |
|
71 case KConnectionClosed: |
|
72 case KLinkLayerClosed: |
|
73 if (iNetworkConnInfo) |
|
74 { |
|
75 iNetworkConnInfo->HandleConnectionEvent( iProgress().iStage ); |
|
76 } |
|
77 break; |
|
78 |
|
79 case KConnectionUninitialised: |
|
80 break; |
|
81 |
|
82 case KStartingSelection: |
|
83 break; |
|
84 |
|
85 case KFinishedSelection: |
|
86 if (iProgress().iError == KErrNone) |
|
87 { |
|
88 // The user successfully selected an IAP to be used |
|
89 } |
|
90 else |
|
91 { |
|
92 // The user pressed e.g. "Cancel" and did not select an IAP |
|
93 } |
|
94 break; |
|
95 |
|
96 case KConnectionFailure: |
|
97 break; |
|
98 |
|
99 // Prepearing connection (e.g. dialing) |
|
100 case KPsdStartingConfiguration: |
|
101 case KPsdFinishedConfiguration: |
|
102 case KCsdFinishedDialling: |
|
103 case KCsdScanningScript: |
|
104 case KCsdGettingLoginInfo: |
|
105 case KCsdGotLoginInfo: |
|
106 break; |
|
107 |
|
108 // Creating connection (e.g. GPRS activation) |
|
109 case KCsdStartingConnect: |
|
110 case KCsdFinishedConnect: |
|
111 break; |
|
112 |
|
113 // Starting log in |
|
114 case KCsdStartingLogIn: |
|
115 break; |
|
116 |
|
117 // Finished login |
|
118 case KCsdFinishedLogIn: |
|
119 break; |
|
120 |
|
121 // Connection open |
|
122 case KConnectionOpen: |
|
123 case KLinkLayerOpen: |
|
124 break; |
|
125 |
|
126 // Connection blocked or suspended |
|
127 case KDataTransferTemporarilyBlocked: |
|
128 break; |
|
129 |
|
130 // Hangup or GRPS deactivation |
|
131 case KConnectionStartingClose: |
|
132 break; |
|
133 |
|
134 // Unhandled state |
|
135 default: |
|
136 break; |
|
137 } |
|
138 |
|
139 Connection().ProgressNotification(iProgress, iStatus); |
|
140 SetActive(); |
|
141 } |