|
1 /* |
|
2 * Copyright (c) 2004 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 the class CWlanTables |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 // INCLUDE FILES |
|
22 #include "cdclogger.h" |
|
23 #include "cdcwlantables.h" |
|
24 |
|
25 #include <wlancontainer.h> |
|
26 |
|
27 // CONSTANTS |
|
28 /// Modem bearer names for WLAN connection methods |
|
29 _LIT( KWlanBearerName, "WLANBearer" ); |
|
30 _LIT( KWlanBearerAgent, "wlanagt.agt" ); |
|
31 _LIT( KWlanBearerNif, "wlannif" ); |
|
32 |
|
33 _LIT( KWlanLDDName, "not used" ); |
|
34 _LIT( KWlanPDDName, "not used" ); |
|
35 const TInt KWlanLastSocketActivityTimeout = -1; |
|
36 const TInt KWlanLastSessionClosedTimeout = 1; |
|
37 const TInt KWlanLastSocketClosedTimeout = -1; |
|
38 |
|
39 |
|
40 // ================= MEMBER FUNCTIONS ======================= |
|
41 |
|
42 // --------------------------------------------------------- |
|
43 // CWlanTables::NewL |
|
44 // --------------------------------------------------------- |
|
45 // |
|
46 CWlanTables* CWlanTables::NewL() |
|
47 { |
|
48 |
|
49 CWlanTables* self = new ( ELeave ) CWlanTables; |
|
50 |
|
51 CleanupStack::PushL( self ); |
|
52 self->ConstructL(); |
|
53 CleanupStack::Pop( self ); |
|
54 |
|
55 return self; |
|
56 } |
|
57 |
|
58 |
|
59 // --------------------------------------------------------- |
|
60 // CWlanTables::CWlanTables |
|
61 // --------------------------------------------------------- |
|
62 // |
|
63 CWlanTables::CWlanTables() |
|
64 { |
|
65 //no implementation needed |
|
66 } |
|
67 |
|
68 |
|
69 // --------------------------------------------------------- |
|
70 // CWlanTables::ConstructL |
|
71 // --------------------------------------------------------- |
|
72 // |
|
73 void CWlanTables::ConstructL() |
|
74 { |
|
75 iSession = CMDBSession::NewL( CMDBSession::LatestVersion() ); |
|
76 } |
|
77 |
|
78 |
|
79 // --------------------------------------------------------- |
|
80 // CWlanTables::~CWlanTables |
|
81 // --------------------------------------------------------- |
|
82 // |
|
83 CWlanTables::~CWlanTables() |
|
84 { |
|
85 if ( iSession ) |
|
86 { |
|
87 iSession->Close(); |
|
88 delete iSession; |
|
89 } |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------- |
|
94 // CreateWlanServiceTableL |
|
95 // --------------------------------------------------------- |
|
96 // |
|
97 void CWlanTables::CheckAndCreateTablesL() |
|
98 { |
|
99 // Check WLAN Device Settings Table (creates if does not exist). |
|
100 CreateWlanDeviceSettingsTableL(); |
|
101 |
|
102 // Check WLAN Service Table (creates if does not exist). |
|
103 CreateWlanServiceTableL(); |
|
104 |
|
105 // Check WLAN Secondary SSID Table (creates if does not exist). |
|
106 CreateWlanSecSSIDTableL(); |
|
107 |
|
108 // Check WLAN bearer record (creates if does not exist). |
|
109 CreateWlanBearerRecordL(); |
|
110 } |
|
111 |
|
112 // --------------------------------------------------------- |
|
113 // CreateWlanServiceTableL |
|
114 // --------------------------------------------------------- |
|
115 // |
|
116 void CWlanTables::CreateWlanServiceTableL() |
|
117 { |
|
118 //checks whether table exists |
|
119 TInt error( KErrNone ); |
|
120 |
|
121 TRAP( error, CCDWlanServiceRecord::TableIdL( *iSession ) ); |
|
122 if( error == KErrNotFound ) |
|
123 { |
|
124 //table not found -- add new table |
|
125 CCDWlanServiceRecord::CreateTableL( *iSession ); |
|
126 |
|
127 //check result |
|
128 TRAP( error, CCDWlanServiceRecord::TableIdL( *iSession ) ); |
|
129 |
|
130 if ( error == KErrNone ) |
|
131 { |
|
132 CLOG_WRITE( "Added WLAN service table" ) |
|
133 } |
|
134 } |
|
135 else if ( error == KErrNone) |
|
136 { |
|
137 CLOG_WRITE( "WLAN service table already exists" ) |
|
138 } |
|
139 else |
|
140 { |
|
141 //do nothing |
|
142 } |
|
143 } |
|
144 |
|
145 |
|
146 // --------------------------------------------------------- |
|
147 // CreateWlanDeviceTableL |
|
148 // --------------------------------------------------------- |
|
149 // |
|
150 void CWlanTables::CreateWlanDeviceSettingsTableL() |
|
151 { |
|
152 //checks whether table exists |
|
153 TInt error( KErrNone ); |
|
154 |
|
155 TRAP( error, CCDWlanDeviceSettingsRecord::TableIdL( *iSession ) ); |
|
156 if( error == KErrNotFound ) |
|
157 { |
|
158 //table not found -- add new table |
|
159 CCDWlanDeviceSettingsRecord::CreateTableL( *iSession ); |
|
160 |
|
161 //check result |
|
162 TRAP( error, CCDWlanDeviceSettingsRecord::TableIdL( *iSession ) ); |
|
163 if ( error == KErrNone ) |
|
164 { |
|
165 CLOG_WRITE( "Added Device Settings table" ) |
|
166 } |
|
167 } |
|
168 else if ( error == KErrNone) |
|
169 { |
|
170 CLOG_WRITE( "Device Settings table already exists" ) |
|
171 } |
|
172 else |
|
173 { |
|
174 //do nothing |
|
175 } |
|
176 } |
|
177 |
|
178 |
|
179 // --------------------------------------------------------- |
|
180 // CreateWlanSecSSIDTableL |
|
181 // --------------------------------------------------------- |
|
182 // |
|
183 void CWlanTables::CreateWlanSecSSIDTableL() |
|
184 { |
|
185 //checks whether table exists |
|
186 TInt error( KErrNone ); |
|
187 |
|
188 TRAP( error, CCDWLANSecSSIDTable::TableIdL( *iSession ) ); |
|
189 if( error == KErrNotFound ) |
|
190 { |
|
191 //table not found -- add new table |
|
192 CCDWLANSecSSIDTable::CreateTableL( *iSession ); |
|
193 |
|
194 //check result |
|
195 TRAP( error, CCDWLANSecSSIDTable::TableIdL( *iSession ) ); |
|
196 |
|
197 if ( error == KErrNone ) |
|
198 { |
|
199 CLOG_WRITE( "Added Secondary SSID table" ) |
|
200 } |
|
201 } |
|
202 else if ( error == KErrNone) |
|
203 { |
|
204 CLOG_WRITE( "Secondary SSID table already exists" ) |
|
205 } |
|
206 else |
|
207 { |
|
208 //do nothing |
|
209 } |
|
210 } |
|
211 |
|
212 // --------------------------------------------------------- |
|
213 // CreateWlanBearerRecordL |
|
214 // --------------------------------------------------------- |
|
215 // |
|
216 void CWlanTables::CreateWlanBearerRecordL() |
|
217 { |
|
218 CCDLANBearerRecord* record = static_cast<CCDLANBearerRecord*> |
|
219 ( CCDRecordBase::RecordFactoryL( KCDTIdLANBearerRecord ) ); |
|
220 CleanupStack::PushL( record ); |
|
221 |
|
222 record->iRecordName.SetL( TPtrC( KWlanBearerName ) ); |
|
223 |
|
224 if ( !record->FindL( *iSession ) ) |
|
225 { // bearer not found -> create dummy values. Copied from CmManager initialization. |
|
226 record->SetRecordId( KCDNewRecordRequest ); |
|
227 |
|
228 record->iBearerAgent.SetL( KWlanBearerAgent ); |
|
229 record->iRecordName.SetL( KWlanBearerName ); |
|
230 record->iLanBearerNifName.SetL( KWlanBearerNif ); |
|
231 record->iLanBearerLddName.SetL( KWlanLDDName ); |
|
232 record->iLanBearerPddName.SetL( KWlanPDDName ); |
|
233 record->iLastSocketActivityTimeout.SetL( |
|
234 ( TUint32 )KWlanLastSocketActivityTimeout ); |
|
235 record->iLastSessionClosedTimeout.SetL( |
|
236 (TUint32 )KWlanLastSessionClosedTimeout ); |
|
237 record->iLastSocketClosedTimeout.SetL( |
|
238 ( TUint32 )KWlanLastSocketClosedTimeout ); |
|
239 record->StoreL( *iSession ); |
|
240 CLOG_WRITE( "Added WLAN bearer record" ); |
|
241 } |
|
242 else |
|
243 { |
|
244 CLOG_WRITE( "WLAN bearer record already exists" ); |
|
245 } |
|
246 |
|
247 CleanupStack::PopAndDestroy( record ); |
|
248 } |
|
249 |
|
250 |
|
251 |
|
252 // End of File. |