|
1 /* |
|
2 * Copyright (c) 2001-2009 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 the License "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: Implementation of RWiFiProtSession |
|
15 * |
|
16 */ |
|
17 |
|
18 /* |
|
19 * %version: tr1cfwln#10 % |
|
20 */ |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "wifiprotsession.h" |
|
24 #include "e32ver.h" |
|
25 #include <wifiprotuiddefs.h> |
|
26 #include "wifiprotlogger.h" |
|
27 |
|
28 using namespace WiFiProt; |
|
29 |
|
30 // -------------------------------------------------------------------------- |
|
31 // RWiFiProtSession::RWiFiProtSession() |
|
32 // -------------------------------------------------------------------------- |
|
33 // |
|
34 RWiFiProtSession::RWiFiProtSession() : |
|
35 RSessionBase(), |
|
36 iNotifier( NULL ), |
|
37 iWiFiProtActiveResp( NULL ) |
|
38 { |
|
39 CLOG_ENTERFN( "RWiFiProtSession::RWiFiProtSession" ); |
|
40 CLOG_LEAVEFN( "RWiFiProtSession::RWiFiProtSession" ); |
|
41 } |
|
42 |
|
43 |
|
44 // -------------------------------------------------------------------------- |
|
45 // ~RWiFiProtSession |
|
46 // -------------------------------------------------------------------------- |
|
47 // |
|
48 RWiFiProtSession::~RWiFiProtSession() |
|
49 { |
|
50 CLOG_ENTERFN( "RWiFiProtSession::~RWiFiProtSession" ); |
|
51 Close(); |
|
52 CLOG_LEAVEFN( "RWiFiProtSession::~RWiFiProtSession" ); |
|
53 } |
|
54 |
|
55 |
|
56 // -------------------------------------------------------------------------- |
|
57 // Connect |
|
58 // |
|
59 // Create a session to the extended notifier framework |
|
60 // -------------------------------------------------------------------------- |
|
61 // |
|
62 TInt RWiFiProtSession::Connect() |
|
63 { |
|
64 CLOG_ENTERFN( "RWiFiProtSession::Connect" ); |
|
65 |
|
66 TInt error( KErrNone ); |
|
67 if ( !iNotifier ) |
|
68 { |
|
69 TRAP( error, iNotifier = new (ELeave) RNotifier() ); |
|
70 } |
|
71 if ( !error && iNotifier ) |
|
72 { |
|
73 error = iNotifier->Connect(); |
|
74 } |
|
75 CLOG_LEAVEFN( "RWiFiProtSession::Connect" ); |
|
76 return error; |
|
77 } |
|
78 |
|
79 // -------------------------------------------------------------------------- |
|
80 // Close |
|
81 // -------------------------------------------------------------------------- |
|
82 // |
|
83 void RWiFiProtSession::Close() |
|
84 { |
|
85 CLOG_ENTERFN( "RWiFiProtSession::Close" ); |
|
86 |
|
87 RSessionBase::Close(); |
|
88 |
|
89 if (iWiFiProtActiveResp) |
|
90 { |
|
91 iWiFiProtActiveResp->Cancel(); |
|
92 delete iWiFiProtActiveResp; |
|
93 iWiFiProtActiveResp = NULL; |
|
94 } |
|
95 if ( iNotifier ) |
|
96 { |
|
97 iNotifier->Close(); |
|
98 delete iNotifier; |
|
99 iNotifier = NULL; |
|
100 } |
|
101 |
|
102 CLOG_LEAVEFN( "RWiFiProtSession::Close" ); |
|
103 } |
|
104 |
|
105 // -------------------------------------------------------------------------- |
|
106 // StartWiFiProtL |
|
107 // -------------------------------------------------------------------------- |
|
108 // |
|
109 void RWiFiProtSession::StartWiFiProtL( const TWlanSsid& aSSid, |
|
110 TBool aConnectionNeeded, |
|
111 RArray<TUint32>& aUidsReturned, |
|
112 WiFiProt::TWiFiReturn& aReturnValue, |
|
113 TRequestStatus& aStatus ) |
|
114 { |
|
115 CLOG_ENTERFN( "RWiFiProtSession::StartWiFiProtL" ); |
|
116 |
|
117 aConnectionNeeded = EFalse; // this parameter is not supported anymore |
|
118 // to be set from the API, but it is used |
|
119 // internally from StartWiFiProtConnL |
|
120 TRAPD( err, iWiFiProtActiveResp = |
|
121 CWiFiProtActiveResp::NewL( aSSid, |
|
122 aConnectionNeeded, |
|
123 aUidsReturned, |
|
124 aReturnValue ) ); |
|
125 |
|
126 |
|
127 if ( err != KErrNone ) |
|
128 { |
|
129 TRequestStatus* pS = &aStatus; |
|
130 User::RequestComplete( pS, err ); |
|
131 } |
|
132 else |
|
133 { |
|
134 iWiFiProtActiveResp->Observe( aStatus ); |
|
135 |
|
136 TPckgBuf<TWiFiOutputParams>* outputParams = |
|
137 iWiFiProtActiveResp->OutputBuffer(); |
|
138 TPckgBuf<TWiFiInputParams>* inputParams = |
|
139 iWiFiProtActiveResp->InputBuffer(); |
|
140 |
|
141 if ( iNotifier ) |
|
142 { |
|
143 TRequestStatus& status = iWiFiProtActiveResp->iStatus; |
|
144 iNotifier->StartNotifierAndGetResponse( status, |
|
145 KUidWiFiProtSetup, |
|
146 *inputParams, |
|
147 *outputParams ); |
|
148 } |
|
149 } |
|
150 |
|
151 CLOG_LEAVEFN( "RWiFiProtSession::StartWiFiProtL" ); |
|
152 } |
|
153 |
|
154 // -------------------------------------------------------------------------- |
|
155 // StartWiFiProtConnL |
|
156 // -------------------------------------------------------------------------- |
|
157 // |
|
158 void RWiFiProtSession::StartWiFiProtConnL( const TWlanSsid& aSSid, |
|
159 TWlanProtectedSetupCredentialAttribute& |
|
160 aNetworkSettings, |
|
161 WiFiProt::TWiFiReturn& aReturnValue, |
|
162 TRequestStatus& aStatus ) |
|
163 { |
|
164 CLOG_ENTERFN( "RWiFiProtSession::StartWiFiProtConnL" ); |
|
165 |
|
166 TRAPD( err, iWiFiProtActiveResp = |
|
167 CWiFiProtActiveResp::NewL( aSSid, |
|
168 aNetworkSettings, |
|
169 aReturnValue ) ); |
|
170 |
|
171 |
|
172 if ( err != KErrNone ) |
|
173 { |
|
174 TRequestStatus* pS = &aStatus; |
|
175 User::RequestComplete( pS, err ); |
|
176 } |
|
177 else |
|
178 { |
|
179 iWiFiProtActiveResp->Observe( aStatus ); |
|
180 |
|
181 TPckgBuf<TWiFiConnOutputParams>* connoutputParams = |
|
182 iWiFiProtActiveResp->ConnOutputBuffer(); |
|
183 TPckgBuf<TWiFiInputParams>* inputParams = |
|
184 iWiFiProtActiveResp->InputBuffer(); |
|
185 |
|
186 if ( iNotifier ) |
|
187 { |
|
188 TRequestStatus& status = iWiFiProtActiveResp->iStatus; |
|
189 iNotifier->StartNotifierAndGetResponse( status, |
|
190 KUidWiFiProtSetup, |
|
191 *inputParams, |
|
192 *connoutputParams ); |
|
193 } |
|
194 } |
|
195 |
|
196 CLOG_LEAVEFN( "RWiFiProtSession::StartWiFiProtConnL" ); |
|
197 } |
|
198 |
|
199 // -------------------------------------------------------------------------- |
|
200 // CancelWiFiProt |
|
201 // -------------------------------------------------------------------------- |
|
202 // |
|
203 void RWiFiProtSession::CancelWiFiProt() |
|
204 { |
|
205 CLOG_ENTERFN( "RWiFiProtSession::CancelWiFiProt()" ); |
|
206 iNotifier->CancelNotifier( KUidWiFiProtSetup ); |
|
207 iWiFiProtActiveResp->Cancel(); |
|
208 delete iWiFiProtActiveResp ; |
|
209 iWiFiProtActiveResp = NULL; |
|
210 CLOG_LEAVEFN( "RWiFiProtSession::CancelWiFiProt()" ); |
|
211 } |
|
212 |
|
213 // End of File |