|
1 /* |
|
2 * Copyright (c) 2005 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: Implementation of CSelectWLanDlgPlugin |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 // INCLUDE FILES |
|
20 #include "SelectWLanDlgPlugin.h" |
|
21 #include "SelectWLANDlg.h" |
|
22 |
|
23 #include "ActiveSelectWLanDlgPlugin.h" |
|
24 #include "ConnectionDialogsLogger.h" |
|
25 #include "ConnUiUtilsNotif.h" |
|
26 |
|
27 #include <e32property.h> // For RProperty |
|
28 #include <UikonInternalPSKeys.h> // For KPSUidUikon and KUikGlobalNotesAllowed. |
|
29 |
|
30 #include <cmmanager.h> |
|
31 #include <cmmanagerext.h> |
|
32 #include <cmconnectionmethod.h> |
|
33 #include <cmpluginwlandef.h> |
|
34 |
|
35 |
|
36 // ================= MEMBER FUNCTIONS ======================= |
|
37 |
|
38 // --------------------------------------------------------- |
|
39 // CSelectWLanDlgPlugin CSelectWLanDlgPlugin() |
|
40 // --------------------------------------------------------- |
|
41 // |
|
42 CSelectWLanDlgPlugin::CSelectWLanDlgPlugin() |
|
43 : CConnectionDialogsNotifBase(), |
|
44 iActivePlugin( NULL ) |
|
45 { |
|
46 } |
|
47 |
|
48 |
|
49 // --------------------------------------------------------- |
|
50 // CSelectWLanDlgPlugin* CSelectWLanDlgPlugin::NewL() |
|
51 // --------------------------------------------------------- |
|
52 // |
|
53 CSelectWLanDlgPlugin* CSelectWLanDlgPlugin::NewL( |
|
54 const TBool aResourceFileResponsible ) |
|
55 { |
|
56 CSelectWLanDlgPlugin* self = new (ELeave) CSelectWLanDlgPlugin(); |
|
57 CleanupStack::PushL( self ); |
|
58 self->ConstructL( KResourceFileName, aResourceFileResponsible ); |
|
59 CleanupStack::Pop(); |
|
60 |
|
61 return self; |
|
62 } |
|
63 |
|
64 |
|
65 // --------------------------------------------------------- |
|
66 // CSelectWLanDlgPlugin::TNotifierInfo CSelectWLanDlgPlugin::RegisterL() |
|
67 // --------------------------------------------------------- |
|
68 // |
|
69 CSelectWLanDlgPlugin::TNotifierInfo CSelectWLanDlgPlugin::RegisterL() |
|
70 { |
|
71 iInfo.iUid = KUidSelectWLanDlg; |
|
72 iInfo.iPriority = ENotifierPriorityHigh; |
|
73 iInfo.iChannel = KUidSelectWLanDlg; |
|
74 |
|
75 return iInfo; |
|
76 } |
|
77 |
|
78 // --------------------------------------------------------- |
|
79 // void CSelectWLanDlgPlugin::StartL() |
|
80 // --------------------------------------------------------- |
|
81 // |
|
82 void CSelectWLanDlgPlugin::StartL( const TDesC8& aBuffer, TInt aReplySlot, |
|
83 const RMessagePtr2& aMessage ) |
|
84 { |
|
85 CLOG_ENTERFN( "CSelectWLanDlgPlugin::StartL " ); |
|
86 |
|
87 TPckgBuf<TBool> asyncVersion; |
|
88 asyncVersion.Copy( aBuffer ); |
|
89 |
|
90 iCancelled = EFalse; |
|
91 |
|
92 // We are about to display the Offline note. |
|
93 // Since this part of the code can be executed during the bootup, check if |
|
94 // the UI has really started up to display notes/dialogs. |
|
95 TInt notesAllowed = 0; |
|
96 User::LeaveIfError ( RProperty::Get( KPSUidUikon, KUikGlobalNotesAllowed, |
|
97 notesAllowed ) ); |
|
98 |
|
99 iReplySlot = aReplySlot; |
|
100 iMessage = aMessage; |
|
101 |
|
102 if ( notesAllowed ) |
|
103 { |
|
104 aMessage.ReadL( aReplySlot, iNetworkPrefs ); |
|
105 |
|
106 TInt err( KErrNone ); |
|
107 TRAP( err, iActivePlugin = CActiveSelectWLanDlgPlugin::NewL( this ) ); |
|
108 if ( err ) |
|
109 { |
|
110 delete iActivePlugin; |
|
111 iActivePlugin = NULL; |
|
112 iCancelled = ETrue; |
|
113 User::Leave( err ); |
|
114 } |
|
115 |
|
116 iActivePlugin->StartSearchWlanNetworkL(); |
|
117 CLOG_LEAVEFN( "CSelectWLanDlgPlugin::StartL " ); |
|
118 } |
|
119 else if ( asyncVersion() ) |
|
120 { |
|
121 CLOG_WRITE( "Completing with KErrNotReady" ); |
|
122 CompleteL( KErrNotReady ); |
|
123 } |
|
124 else |
|
125 { |
|
126 iCancelled = ETrue; |
|
127 User::Leave( KErrNotReady ); |
|
128 } |
|
129 } |
|
130 |
|
131 // --------------------------------------------------------- |
|
132 // void CSelectWLanDlgPlugin::Cancel() |
|
133 // --------------------------------------------------------- |
|
134 // |
|
135 void CSelectWLanDlgPlugin::Cancel() |
|
136 { |
|
137 CLOG_ENTERFN( "CSelectWLanDlgPlugin::Cancel " ); |
|
138 |
|
139 if ( !iCancelled ) |
|
140 { |
|
141 iCancelled = ETrue; |
|
142 if ( !iMessage.IsNull() ) |
|
143 { |
|
144 iMessage.Complete( KErrCancel ); |
|
145 } |
|
146 |
|
147 delete iActivePlugin; |
|
148 iActivePlugin = NULL; |
|
149 } |
|
150 CLOG_LEAVEFN( "CSelectWLanDlgPlugin::Cancel " ); |
|
151 |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------- |
|
155 // void CSelectWLanDlgPlugin::CompleteL( TInt aStatus ) |
|
156 // --------------------------------------------------------- |
|
157 // |
|
158 void CSelectWLanDlgPlugin::CompleteL( TInt aStatus ) |
|
159 { |
|
160 CLOG_ENTERFN( "CSelectWLanDlgPlugin::CompleteL " ); |
|
161 |
|
162 if ( ( ( aStatus == KErrNone ) || ( aStatus == KErrNotFound ) ) && !iMessage.IsNull() ) |
|
163 { |
|
164 HBufC* ssid16 = HBufC::NewLC( iNetworkPrefs().iSsId.Length() ); |
|
165 ssid16->Des().Copy( iNetworkPrefs().iSsId ); |
|
166 CLOG_WRITEF( _L( "iSSID : %S" ), ssid16 ); |
|
167 CleanupStack::PopAndDestroy( ssid16 ); |
|
168 CLOG_WRITEF( _L( "iCntMode : %d" ), iNetworkPrefs().iNetworkMode ); |
|
169 CLOG_WRITEF( _L( "iSecurityMode : %d" ), iNetworkPrefs().iSecMode ); |
|
170 |
|
171 iMessage.WriteL( iReplySlot, iNetworkPrefs ); |
|
172 } |
|
173 |
|
174 CLOG_WRITEF( _L( "aStatus in CompleteL: %d" ), aStatus ); |
|
175 |
|
176 delete iActivePlugin; |
|
177 iActivePlugin = NULL; |
|
178 |
|
179 iCancelled = ETrue; |
|
180 if ( !iMessage.IsNull() ) |
|
181 { |
|
182 iMessage.Complete( aStatus ); |
|
183 } |
|
184 Cancel(); |
|
185 |
|
186 CLOG_LEAVEFN( "CSelectWLanDlgPlugin::CompleteL " ); |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------- |
|
190 // void CSelectWLanDlgPlugin::StopTimer |
|
191 // --------------------------------------------------------- |
|
192 // |
|
193 void CSelectWLanDlgPlugin::StopTimer() |
|
194 { |
|
195 CLOG_ENTERFN( "CSelectWLanDlgPlugin::StopTimer " ); |
|
196 |
|
197 iActivePlugin->Cancel(); |
|
198 |
|
199 CLOG_LEAVEFN( "CSelectWLanDlgPlugin::StopTimer " ); |
|
200 |
|
201 } |
|
202 |
|
203 |
|
204 // --------------------------------------------------------- |
|
205 // void CSelectWLanDlgPlugin::SetNetworkPrefsL |
|
206 // --------------------------------------------------------- |
|
207 // |
|
208 void CSelectWLanDlgPlugin::SetNetworkPrefsL( TWlanSsid& aSSID, |
|
209 TWlanConnectionMode& aConnectionMode, |
|
210 TWlanConnectionSecurityMode& aSecurityMode, |
|
211 TWlanConnectionExtentedSecurityMode& aExtSecurityMode, |
|
212 TBool& aProtectedSetupSupported ) |
|
213 { |
|
214 CLOG_ENTERFN( "CSelectWLanDlgPlugin::SetNetworkPrefsL " ); |
|
215 iNetworkPrefs().iSsId = aSSID; |
|
216 iNetworkPrefs().iNetworkMode = aConnectionMode; |
|
217 iNetworkPrefs().iSecMode = aSecurityMode; |
|
218 iNetworkPrefs().iExtSecMode = aExtSecurityMode; |
|
219 iNetworkPrefs().iProtectedSetupSupported = aProtectedSetupSupported; |
|
220 |
|
221 HBufC* ssid16 = HBufC::NewLC( aSSID.Length() ); |
|
222 ssid16->Des().Copy( aSSID ); |
|
223 CLOG_WRITEF( _L( "aSSID : %S" ), ssid16 ); |
|
224 CleanupStack::PopAndDestroy( ssid16 ); |
|
225 CLOG_WRITEF( _L( "aConnectionMode : %d" ), aConnectionMode ); |
|
226 CLOG_WRITEF( _L( "aSecurityMode : %d" ), aSecurityMode ); |
|
227 CLOG_WRITEF( _L( "aExtSecurityMode : %d" ), aExtSecurityMode ); |
|
228 |
|
229 CLOG_LEAVEFN( "CSelectWLanDlgPlugin::SetNetworkPrefsL " ); |
|
230 } |
|
231 |
|
232 |
|
233 // --------------------------------------------------------- |
|
234 // void CSelectWLanDlgPlugin::SetEasyWlanToHiddenL() |
|
235 // --------------------------------------------------------- |
|
236 // |
|
237 void CSelectWLanDlgPlugin::SetEasyWlanToHiddenL( const TBool aValue ) |
|
238 { |
|
239 CLOG_ENTERFN( "CSelectWLanDlgPlugin::SetEasyWlanToHiddenL" ); |
|
240 |
|
241 RCmManagerExt cmManagerExt; |
|
242 cmManagerExt.OpenL(); |
|
243 CleanupClosePushL( cmManagerExt ); |
|
244 |
|
245 TUint32 easyWlanId = cmManagerExt.EasyWlanIdL(); |
|
246 CLOG_WRITEF( _L( "easyWlanId %d" ), easyWlanId ); |
|
247 |
|
248 if ( easyWlanId ) |
|
249 { |
|
250 RCmConnectionMethodExt cmConnMethodExt; |
|
251 cmConnMethodExt = cmManagerExt.ConnectionMethodL( easyWlanId ); |
|
252 CleanupClosePushL( cmConnMethodExt ); |
|
253 |
|
254 cmConnMethodExt.SetBoolAttributeL( CMManager::EWlanScanSSID, aValue ); |
|
255 cmConnMethodExt.UpdateL(); |
|
256 |
|
257 CleanupStack::PopAndDestroy(); // cmConnMethodExt; |
|
258 } |
|
259 |
|
260 CleanupStack::PopAndDestroy(); // cmManagerExt |
|
261 |
|
262 CLOG_LEAVEFN( "CSelectWLanDlgPlugin::SetEasyWlanToHiddenL" ); |
|
263 } |
|
264 |
|
265 // End of File |