|
1 /* |
|
2 * Copyright (c) 2008 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: Geographical cellular area class definition |
|
15 * |
|
16 */ |
|
17 |
|
18 #include "lbtgeocell.h" |
|
19 #include "lbterrors.h" |
|
20 |
|
21 |
|
22 // ======== LOCAL FUNCTIONS ======== |
|
23 |
|
24 // --------------------------------------------------------------------------- |
|
25 // CLbtGeoCell::NewL() |
|
26 // |
|
27 // (other items were commented in a header). |
|
28 // --------------------------------------------------------------------------- |
|
29 // |
|
30 EXPORT_C CLbtGeoCell* CLbtGeoCell::NewL() |
|
31 { |
|
32 CLbtGeoCell* self = CLbtGeoCell::NewLC(); |
|
33 CleanupStack::Pop( self ); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // --------------------------------------------------------------------------- |
|
38 // CLbtGeoCell::NewLC() |
|
39 // |
|
40 // (other items were commented in a header). |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C CLbtGeoCell* CLbtGeoCell::NewLC() |
|
44 { |
|
45 CLbtGeoCell* self = new( ELeave ) CLbtGeoCell; |
|
46 CleanupStack::PushL( self ); |
|
47 self->ConstructL(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 // --------------------------------------------------------------------------- |
|
52 // CLbtGeoCell::NewL() |
|
53 // |
|
54 // (other items were commented in a header). |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CLbtGeoCell* CLbtGeoCell::NewL(RMobilePhone::TMobilePhoneNetworkMode aNetworkType, |
|
58 TNetworkCountryCode aCountryCode, |
|
59 TNetworkIdentity aNetworkId, |
|
60 TUint aLocationAreaCode, |
|
61 TUint aCellId) |
|
62 { |
|
63 CLbtGeoCell* self = CLbtGeoCell::NewLC(aNetworkType,aCountryCode,aNetworkId,aLocationAreaCode, |
|
64 aCellId); |
|
65 CleanupStack::Pop( self ); |
|
66 return self; |
|
67 } |
|
68 |
|
69 // --------------------------------------------------------------------------- |
|
70 // CLbtGeoCell::NewLC() |
|
71 // |
|
72 // (other items were commented in a header). |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 EXPORT_C CLbtGeoCell* CLbtGeoCell::NewLC(RMobilePhone::TMobilePhoneNetworkMode aNetworkType, |
|
76 TNetworkCountryCode aCountryCode, |
|
77 TNetworkIdentity aNetworkId, |
|
78 TUint aLocationAreaCode, |
|
79 TUint aCellId) |
|
80 { |
|
81 CLbtGeoCell* self = new( ELeave ) CLbtGeoCell(); |
|
82 CleanupStack::PushL( self ); |
|
83 self->ConstructL( aNetworkType,aCountryCode,aNetworkId,aLocationAreaCode,aCellId); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // --------------------------------------------------------------------------- |
|
88 // CLbtGeoCell::CLbtGeoCell() |
|
89 // |
|
90 // Default constructor |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 CLbtGeoCell::CLbtGeoCell() |
|
94 { |
|
95 |
|
96 } |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CLbtGeoCell::ConstructL() |
|
100 // |
|
101 // --------------------------------------------------------------------------- |
|
102 // |
|
103 void CLbtGeoCell::ConstructL(RMobilePhone::TMobilePhoneNetworkMode aNetworkType, |
|
104 TNetworkCountryCode aCountryCode, |
|
105 TNetworkIdentity aNetworkId, |
|
106 TUint aLocationAreaCode, |
|
107 TUint aCellId) |
|
108 { |
|
109 SetNetworkType( aNetworkType ); |
|
110 SetNetworkCountryCode( aCountryCode ); |
|
111 SetNetworkIdentityCode( aNetworkId ); |
|
112 SetLocationAreaCode( aLocationAreaCode ); |
|
113 SetCellId( aCellId ); |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CLbtGeoCell::ConstructL() |
|
118 // |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 void CLbtGeoCell::ConstructL() |
|
122 { |
|
123 iNetworkType = RMobilePhone::ENetworkModeUnknown; |
|
124 iCountryCode = 0; |
|
125 iNetworkId = 0; |
|
126 iLocationAreaCode = 0; |
|
127 iCellId = 0; |
|
128 } |
|
129 |
|
130 |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // CLbtGeoCell::~CLbtGeoCell() |
|
134 // |
|
135 // Destructor. |
|
136 // --------------------------------------------------------------------------- |
|
137 // |
|
138 EXPORT_C CLbtGeoCell::~CLbtGeoCell() |
|
139 { |
|
140 |
|
141 } |
|
142 |
|
143 // --------------------------------------------------------------------------- |
|
144 // CLbtGeoCell::Type() |
|
145 // |
|
146 // (other items were commented in a header). |
|
147 // --------------------------------------------------------------------------- |
|
148 // |
|
149 CLbtGeoAreaBase::TGeoAreaType CLbtGeoCell::Type() const |
|
150 { |
|
151 return CLbtGeoAreaBase::ECellular; |
|
152 } |
|
153 |
|
154 // --------------------------------------------------------------------------- |
|
155 // CLbtGeoCell::SetNetworkType() |
|
156 // |
|
157 // (other items were commented in a header). |
|
158 // --------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C void CLbtGeoCell::SetNetworkType( RMobilePhone::TMobilePhoneNetworkMode aNetworkType ) |
|
161 { |
|
162 if( aNetworkType != RMobilePhone::ENetworkModeGsm && aNetworkType != RMobilePhone::ENetworkModeWcdma && |
|
163 aNetworkType != RMobilePhone::ENetworkModeTdcdma ) |
|
164 |
|
165 User::Panic(KLbtClientPanicCategory,ELbtErrArgument); |
|
166 |
|
167 iNetworkType = aNetworkType; |
|
168 } |
|
169 |
|
170 // --------------------------------------------------------------------------- |
|
171 // CLbtGeoCell::NetworkType() |
|
172 // |
|
173 // (other items were commented in a header). |
|
174 // --------------------------------------------------------------------------- |
|
175 // |
|
176 EXPORT_C RMobilePhone::TMobilePhoneNetworkMode CLbtGeoCell::NetworkType() const |
|
177 { |
|
178 return iNetworkType; |
|
179 } |
|
180 |
|
181 // --------------------------------------------------------------------------- |
|
182 // CLbtGeoCell::SetNetworkCountryCode() |
|
183 // |
|
184 // (other items were commented in a header). |
|
185 // --------------------------------------------------------------------------- |
|
186 // |
|
187 EXPORT_C void CLbtGeoCell::SetNetworkCountryCode( TNetworkCountryCode aCountryCode ) |
|
188 { |
|
189 TInt countryCode ; |
|
190 TLex valLex( aCountryCode ); |
|
191 TInt error = valLex.Val( countryCode ); |
|
192 |
|
193 if( countryCode <= 0 || error!=KErrNone ) |
|
194 |
|
195 User::Panic(KLbtClientPanicCategory,ELbtErrArgument); |
|
196 |
|
197 iCountryCode = countryCode; |
|
198 } |
|
199 |
|
200 // --------------------------------------------------------------------------- |
|
201 // CLbtGeoCell::NetworkCountryCode() |
|
202 // |
|
203 // (other items were commented in a header). |
|
204 // --------------------------------------------------------------------------- |
|
205 // |
|
206 EXPORT_C TNetworkCountryCode CLbtGeoCell::NetworkCountryCode() const |
|
207 { |
|
208 TNetworkCountryCode countryCode; |
|
209 countryCode.AppendNum( iCountryCode ); |
|
210 return countryCode; |
|
211 } |
|
212 |
|
213 // --------------------------------------------------------------------------- |
|
214 // CLbtGeoCell::SetNetworkIdentityCode() |
|
215 // |
|
216 // (other items were commented in a header). |
|
217 // --------------------------------------------------------------------------- |
|
218 // |
|
219 EXPORT_C void CLbtGeoCell::SetNetworkIdentityCode( TNetworkIdentity aNetworkId ) |
|
220 { |
|
221 TInt networkCode ; |
|
222 TLex valLex( aNetworkId ); |
|
223 TInt error = valLex.Val( networkCode ); |
|
224 |
|
225 if( networkCode<= 0 || error!=KErrNone ) |
|
226 |
|
227 User::Panic(KLbtClientPanicCategory,ELbtErrArgument); |
|
228 |
|
229 iNetworkId = networkCode; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // CLbtGeoCell::NetworkIdentityCode() |
|
234 // |
|
235 // (other items were commented in a header). |
|
236 // --------------------------------------------------------------------------- |
|
237 // |
|
238 EXPORT_C TNetworkIdentity CLbtGeoCell::NetworkIdentityCode() const |
|
239 { |
|
240 TNetworkIdentity networkCode; |
|
241 networkCode.AppendNum( iNetworkId ); |
|
242 |
|
243 return networkCode; |
|
244 } |
|
245 |
|
246 // --------------------------------------------------------------------------- |
|
247 // CLbtGeoCell::SetLocationAreaCode() |
|
248 // |
|
249 // (other items were commented in a header). |
|
250 // --------------------------------------------------------------------------- |
|
251 // |
|
252 EXPORT_C void CLbtGeoCell::SetLocationAreaCode(TUint aLocationAreaCode) |
|
253 { |
|
254 if( aLocationAreaCode == 0 ) |
|
255 |
|
256 User::Panic(KLbtClientPanicCategory,ELbtErrArgument); |
|
257 |
|
258 iLocationAreaCode = aLocationAreaCode; |
|
259 } |
|
260 |
|
261 // --------------------------------------------------------------------------- |
|
262 // CLbtGeoCell::LocationAreaCode() |
|
263 // |
|
264 // (other items were commented in a header). |
|
265 // --------------------------------------------------------------------------- |
|
266 // |
|
267 EXPORT_C TUint CLbtGeoCell::LocationAreaCode() const |
|
268 { |
|
269 return iLocationAreaCode; |
|
270 } |
|
271 |
|
272 // --------------------------------------------------------------------------- |
|
273 // CLbtGeoCell::SetCellId() |
|
274 // |
|
275 // (other items were commented in a header). |
|
276 // --------------------------------------------------------------------------- |
|
277 // |
|
278 EXPORT_C void CLbtGeoCell::SetCellId( TUint aCellId ) |
|
279 { |
|
280 if( aCellId == 0 ) |
|
281 |
|
282 User::Panic(KLbtClientPanicCategory,ELbtErrArgument); |
|
283 |
|
284 iCellId = aCellId; |
|
285 } |
|
286 |
|
287 // --------------------------------------------------------------------------- |
|
288 // CLbtGeoCell::CellId() |
|
289 // |
|
290 // (other items were commented in a header). |
|
291 // --------------------------------------------------------------------------- |
|
292 // |
|
293 EXPORT_C TUint CLbtGeoCell::CellId() const |
|
294 { |
|
295 return iCellId; |
|
296 } |
|
297 |
|
298 // --------------------------------------------------------------------------- |
|
299 // CLbtGeoCell::CGISpecifiedDuringCreation() |
|
300 // |
|
301 // (other items were commented in a header). |
|
302 // --------------------------------------------------------------------------- |
|
303 // |
|
304 TBool CLbtGeoCell::CGISpecifiedDuringCreation() const |
|
305 { |
|
306 return ETrue; |
|
307 } |
|
308 |
|
309 // --------------------------------------------------------------------------- |
|
310 // CLbtGeoCell::DoExternalizeL() |
|
311 // |
|
312 // (other items were commented in a header). |
|
313 // --------------------------------------------------------------------------- |
|
314 // |
|
315 void CLbtGeoCell::DoExternalizeL( RWriteStream& aStream ) const |
|
316 { |
|
317 RMobilePhone::TMobilePhoneNetworkMode networkType = NetworkType(); |
|
318 if( networkType == RMobilePhone::ENetworkModeGsm ) |
|
319 aStream.WriteUint8L( 1 ); |
|
320 else if( networkType == RMobilePhone::ENetworkModeWcdma ) |
|
321 aStream.WriteUint8L( 2 ); |
|
322 else if( networkType == RMobilePhone::ENetworkModeTdcdma) |
|
323 aStream.WriteUint8L( 3 ); |
|
324 else |
|
325 aStream.WriteUint8L( 0 ); |
|
326 |
|
327 aStream.WriteUint32L( iCountryCode ); |
|
328 aStream.WriteUint32L(iNetworkId ); |
|
329 aStream.WriteUint32L( iLocationAreaCode ); |
|
330 aStream.WriteUint32L( iCellId ); |
|
331 } |
|
332 |
|
333 // --------------------------------------------------------------------------- |
|
334 // CLbtGeoCell::DoInternalizeL() |
|
335 // |
|
336 // (other items were commented in a header). |
|
337 // --------------------------------------------------------------------------- |
|
338 // |
|
339 void CLbtGeoCell::DoInternalizeL( RReadStream& aStream ) |
|
340 { |
|
341 TInt networkType = aStream.ReadUint8L(); |
|
342 if( networkType == 1 ) |
|
343 iNetworkType = RMobilePhone::ENetworkModeGsm; |
|
344 else if ( networkType == 2 ) |
|
345 iNetworkType = RMobilePhone::ENetworkModeWcdma; |
|
346 else if ( networkType == 3 ) |
|
347 iNetworkType = RMobilePhone::ENetworkModeTdcdma; |
|
348 else |
|
349 iNetworkType = RMobilePhone::ENetworkModeUnknown; |
|
350 |
|
351 |
|
352 iCountryCode = aStream.ReadUint32L(); |
|
353 iNetworkId = aStream.ReadUint32L(); |
|
354 iLocationAreaCode = aStream.ReadUint32L(); |
|
355 iCellId = aStream.ReadUint32L(); |
|
356 |
|
357 } |
|
358 |
|
359 |
|
360 // --------------------------------------------------------------------------- |
|
361 // CLbtGeoCell::ValidateCreateCellInformationL() |
|
362 // |
|
363 // (other items were commented in a header). |
|
364 // --------------------------------------------------------------------------- |
|
365 // |
|
366 void CLbtGeoCell::ValidateCreateCellInformationL() |
|
367 { |
|
368 if( ( iNetworkType == RMobilePhone::ENetworkModeUnknown ) || !iCountryCode |
|
369 || !iNetworkId || !iLocationAreaCode || !iCellId ) |
|
370 User::Leave( KErrArgument ); |
|
371 } |
|
372 |
|
373 |
|
374 // --------------------------------------------------------------------------- |
|
375 // CLbtGeoCell::ValidateCellInformationL() |
|
376 // |
|
377 // (other items were commented in a header). |
|
378 // --------------------------------------------------------------------------- |
|
379 // |
|
380 void CLbtGeoCell::ValidateCellInformationL() |
|
381 { |
|
382 if( iNetworkType != RMobilePhone::ENetworkModeGsm && iNetworkType != RMobilePhone::ENetworkModeWcdma |
|
383 && iNetworkType != RMobilePhone::ENetworkModeTdcdma ) |
|
384 User::Leave( KErrArgument ); |
|
385 |
|
386 if( iCellId && (!iLocationAreaCode || !iNetworkId || !iCountryCode ) ) |
|
387 User::Leave( KErrArgument ); |
|
388 |
|
389 if( iLocationAreaCode && ( !iNetworkId || !iCountryCode ) ) |
|
390 User::Leave( KErrArgument ); |
|
391 |
|
392 if( iNetworkId && !iCountryCode ) |
|
393 User::Leave( KErrArgument ); |
|
394 } |
|
395 |
|
396 // end of file |
|
397 |