|
1 /* |
|
2 * Copyright (c) 2010 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: |
|
15 * Connection Monitor interface implementation. |
|
16 */ |
|
17 |
|
18 // System include files |
|
19 |
|
20 #include <rconnmon.h> |
|
21 #include <nifvar.h> |
|
22 |
|
23 // User include files |
|
24 |
|
25 #include "wsfkeepalive.h" |
|
26 #include "wsfkeepaliveconnmon.h" |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "wsfkeepaliveconnmonTraces.h" |
|
30 #endif |
|
31 |
|
32 // External function prototypes |
|
33 |
|
34 // Local constants |
|
35 |
|
36 // ======== LOCAL FUNCTIONS ======== |
|
37 |
|
38 // ======== MEMBER FUNCTIONS ======== |
|
39 |
|
40 CWsfKeepaliveConnMon* CWsfKeepaliveConnMon::NewL( CWsfKeepalive& aNotify ) |
|
41 { |
|
42 OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_NEWL_ENTRY ); |
|
43 |
|
44 CWsfKeepaliveConnMon* me = new ( ELeave ) CWsfKeepaliveConnMon( aNotify ); |
|
45 CleanupStack::PushL( me ); |
|
46 me->ConstructL(); |
|
47 CleanupStack::Pop( me ); |
|
48 |
|
49 OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_NEWL_EXIT ); |
|
50 return me; |
|
51 } |
|
52 |
|
53 CWsfKeepaliveConnMon::~CWsfKeepaliveConnMon() |
|
54 { |
|
55 OstTraceFunctionEntry0( |
|
56 DUP1_CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_ENTRY ); |
|
57 |
|
58 // Stop monitoring observer events |
|
59 iMonitor.CancelNotifications(); |
|
60 iMonitor.Close(); |
|
61 |
|
62 OstTraceFunctionExit0( |
|
63 DUP1_CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_EXIT ); |
|
64 } |
|
65 |
|
66 void CWsfKeepaliveConnMon::GetClientInfo( |
|
67 TConnMonClientEnumBuf& aClientInfo, |
|
68 TUint aConnectionId ) |
|
69 { |
|
70 OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_GETCLIENTINFO_ENTRY ); |
|
71 |
|
72 // Get all clients of this connection |
|
73 TRequestStatus status; |
|
74 iMonitor.GetPckgAttribute( |
|
75 aConnectionId, |
|
76 0, |
|
77 KClientInfo, |
|
78 aClientInfo, |
|
79 status ); |
|
80 User::WaitForRequest( status ); |
|
81 if ( status.Int() != KErrNone ) |
|
82 { |
|
83 // Make sure we don't try to use the result buffer since its |
|
84 // contents are not ok |
|
85 aClientInfo().iCount = 0; |
|
86 } |
|
87 |
|
88 #ifdef OST_TRACE_COMPILER_IN_USE |
|
89 for ( TInt i( 0 ); i < aClientInfo().iCount; ++i ) |
|
90 { |
|
91 OstTrace1( |
|
92 TRACE_NORMAL, |
|
93 CWSFKEEPALIVECONNMON_GETCLIENTINFO, |
|
94 "CWsfKeepaliveConnMon::GetClientInfo Client ID;aClientInfo().iUid[i].iUid=%x", |
|
95 aClientInfo().iUid[i].iUid ); |
|
96 } |
|
97 #endif |
|
98 |
|
99 OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_GETCLIENTINFO_EXIT ); |
|
100 } |
|
101 |
|
102 // --------------------------------------------------------------------------- |
|
103 // Default constructor |
|
104 // --------------------------------------------------------------------------- |
|
105 // |
|
106 CWsfKeepaliveConnMon::CWsfKeepaliveConnMon( CWsfKeepalive& aNotify ) : |
|
107 iNotify( aNotify ), |
|
108 iMonitoringConnectionId( CWsfKeepalive::KInvalidConnectionId ) |
|
109 { |
|
110 OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_ENTRY ); |
|
111 OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_CWSFKEEPALIVECONNMON_EXIT ); |
|
112 } |
|
113 |
|
114 // --------------------------------------------------------------------------- |
|
115 // Leaving constructor |
|
116 // --------------------------------------------------------------------------- |
|
117 // |
|
118 void CWsfKeepaliveConnMon::ConstructL() |
|
119 { |
|
120 OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_CONSTRUCTL_ENTRY ); |
|
121 |
|
122 iMonitor.ConnectL(); |
|
123 // Start monitoring observer events |
|
124 iMonitor.NotifyEventL( *this ); |
|
125 |
|
126 OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_CONSTRUCTL_EXIT ); |
|
127 } |
|
128 |
|
129 // --------------------------------------------------------------------------- |
|
130 // Event method is called every time an observer event occures |
|
131 // --------------------------------------------------------------------------- |
|
132 // |
|
133 void CWsfKeepaliveConnMon::EventL( const CConnMonEventBase& aConnMonEvent ) |
|
134 { |
|
135 OstTraceFunctionEntry0( CWSFKEEPALIVECONNMON_EVENTL_ENTRY ); |
|
136 |
|
137 TUint connectionId = aConnMonEvent.ConnectionId(); |
|
138 TInt bearer; |
|
139 TRequestStatus status; |
|
140 |
|
141 OstTraceExt2( |
|
142 TRACE_NORMAL, |
|
143 CWSFKEEPALIVECONNMON_EVENTL_EVENTTYPE, |
|
144 "CWsfKeepaliveConnMon::EventL;connectionId=%u;aConnMonEvent.EventType()=%{ConnMonEvent}", |
|
145 connectionId, |
|
146 aConnMonEvent.EventType() ); |
|
147 |
|
148 const CConnMonConnectionStatusChange* connectionStatusChangeEvent; |
|
149 switch ( aConnMonEvent.EventType() ) |
|
150 { |
|
151 case EConnMonDeleteConnection: |
|
152 // We are only interested in one connection |
|
153 if ( connectionId == iMonitoringConnectionId ) |
|
154 { |
|
155 iNotify.WlanConnectionClosed(); |
|
156 iMonitoringConnectionId = CWsfKeepalive::KInvalidConnectionId; |
|
157 } |
|
158 break; |
|
159 |
|
160 case EConnMonConnectionStatusChange: |
|
161 connectionStatusChangeEvent = |
|
162 static_cast< |
|
163 const CConnMonConnectionStatusChange* >( &aConnMonEvent ); |
|
164 |
|
165 OstTrace1( |
|
166 TRACE_NORMAL, |
|
167 CWSFKEEPALIVECONNMON_EVENTL_CONNSTATUS, |
|
168 "CWsfKeepaliveConnMon::EventL;connectionStatusChangeEvent->ConnectionStatus()=%{ConnMonConnStatus}", |
|
169 connectionStatusChangeEvent->ConnectionStatus() ); |
|
170 |
|
171 // We are only interested in connected event |
|
172 if ( connectionStatusChangeEvent->ConnectionStatus() |
|
173 == KLinkLayerOpen ) |
|
174 { |
|
175 // Get the connection bearer type. |
|
176 iMonitor.GetIntAttribute( |
|
177 connectionId, |
|
178 0, |
|
179 KBearer, |
|
180 bearer, |
|
181 status ); |
|
182 User::WaitForRequest( status ); |
|
183 |
|
184 // We are only interested in WLAN connections |
|
185 if ( status.Int() == KErrNone && bearer == EBearerWLAN ) |
|
186 { |
|
187 // Get connection IAP ID. |
|
188 TUint iapId = 0; |
|
189 iMonitor.GetUintAttribute( |
|
190 connectionId, |
|
191 0, |
|
192 KIAPId, |
|
193 iapId, |
|
194 status ); |
|
195 User::WaitForRequest( status ); |
|
196 |
|
197 if ( status == KErrNone ) |
|
198 { |
|
199 iNotify.WlanConnectionOpenedL( connectionId, iapId ); |
|
200 // Remember this connection |
|
201 iMonitoringConnectionId = connectionId; |
|
202 } |
|
203 } |
|
204 } |
|
205 break; |
|
206 |
|
207 default: |
|
208 // Not interesting |
|
209 break; |
|
210 } |
|
211 |
|
212 OstTraceFunctionExit0( CWSFKEEPALIVECONNMON_EVENTL_EXIT ); |
|
213 } |