|
1 // Copyright (c) 2000-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // All comms database access is performed through a CCommsDatabase object |
|
15 // |
|
16 // |
|
17 |
|
18 /** |
|
19 @file |
|
20 */ |
|
21 |
|
22 #include <nifvar.h> |
|
23 #include <comms-infras/nifprvar.h> |
|
24 #include <commdb.h> |
|
25 #include "DbAccess.h" |
|
26 #include "AgentPanic.h" |
|
27 #include "Ni_Log.h" |
|
28 |
|
29 #include "DbAccessImplv2.h" |
|
30 |
|
31 |
|
32 #ifdef _DEBUG |
|
33 // Panic category for "absolutely impossible!" vanilla ASSERT()-type panics from this module |
|
34 // (if it could happen through user error then you should give it an explicit, documented, category + code) |
|
35 _LIT(KSpecAssert_NifManDbAccessc, "NifManDbAccess.c"); |
|
36 #endif |
|
37 |
|
38 /** |
|
39 @internalComponent |
|
40 */ |
|
41 |
|
42 // |
|
43 // TConnectionSettings |
|
44 // |
|
45 |
|
46 EXPORT_C TConnectionSettings::TConnectionSettings(): |
|
47 iRank(0), |
|
48 iDirection(ECommDbConnectionDirectionUnknown), |
|
49 iDialogPref(ECommDbDialogPrefUnknown), |
|
50 iBearerSet(0), |
|
51 iIAPId(0), |
|
52 iServiceId(0), |
|
53 iServiceType(), |
|
54 iBearerId(0), |
|
55 iBearerType(), |
|
56 iLocationId(0), |
|
57 iChargeCardId(0) |
|
58 {} |
|
59 |
|
60 |
|
61 // |
|
62 // CCommsDbAccess definitions |
|
63 // |
|
64 |
|
65 EXPORT_C CCommsDbAccess* CCommsDbAccess::NewL() |
|
66 { |
|
67 return CCommsDbAccess::NewL( EFalse ); |
|
68 } |
|
69 |
|
70 EXPORT_C CCommsDbAccess* CCommsDbAccess::NewL(TBool aShowHidden) |
|
71 { |
|
72 CCommsDbAccess* self = new(ELeave) CCommsDbAccess; |
|
73 CleanupStack::PushL(self); |
|
74 self->ConstructL(aShowHidden); |
|
75 CleanupStack::Pop(); |
|
76 return self; |
|
77 } |
|
78 |
|
79 EXPORT_C CCommsDbAccess* CCommsDbAccess::NewL( MCommsDbAccess *aPimpl ) |
|
80 { |
|
81 __ASSERT_DEBUG( aPimpl , User::Panic(KSpecAssert_NifManDbAccessc, 1)); |
|
82 CCommsDbAccess *self = new (ELeave) CCommsDbAccess( aPimpl ); |
|
83 return self; |
|
84 } |
|
85 |
|
86 CCommsDbAccess::CCommsDbAccess() |
|
87 :iPimpl(0), |
|
88 iOwnImpl(EFalse) |
|
89 { |
|
90 } |
|
91 |
|
92 CCommsDbAccess::CCommsDbAccess( MCommsDbAccess *aPimpl ) |
|
93 :iPimpl( aPimpl ), |
|
94 iOwnImpl(EFalse) |
|
95 { |
|
96 } |
|
97 |
|
98 void CCommsDbAccess::ConstructL(TBool aShowHidden) |
|
99 { |
|
100 __ASSERT_DEBUG( !iPimpl , User::Panic(KSpecAssert_NifManDbAccessc, 2)); |
|
101 iPimpl = CCommsDatAccessImpl::NewL( aShowHidden ); |
|
102 iOwnImpl = ETrue; |
|
103 } |
|
104 |
|
105 /** |
|
106 Retrieve the implementation pointer |
|
107 */ |
|
108 MCommsDbAccess* CCommsDbAccess::GetImpl() const |
|
109 { |
|
110 return iPimpl; |
|
111 } |
|
112 |
|
113 |
|
114 EXPORT_C CCommsDbAccess::~CCommsDbAccess() |
|
115 { |
|
116 Close(); |
|
117 if( iOwnImpl ) |
|
118 { |
|
119 delete iPimpl; |
|
120 } |
|
121 iPimpl = 0; |
|
122 } |
|
123 |
|
124 EXPORT_C void CCommsDbAccess::Close() |
|
125 { |
|
126 if(GetImpl()) |
|
127 { |
|
128 GetImpl()->Close(); |
|
129 } |
|
130 } |
|
131 |
|
132 EXPORT_C void CCommsDbAccess::SetOverridesL(CCommDbOverrideSettings* aOverrides) |
|
133 { |
|
134 GetImpl()->SetOverridesL( aOverrides ); |
|
135 } |
|
136 |
|
137 EXPORT_C TBool CCommsDbAccess::IsShowingHiddenRecords() |
|
138 { |
|
139 return GetImpl()->IsShowingHiddenRecords(); |
|
140 } |
|
141 |
|
142 EXPORT_C void CCommsDbAccess::GetCurrentSettingsL(TConnectionSettings& aSettings, TCommDbConnectionDirection aDirection, TUint32 aRank) |
|
143 /** |
|
144 Get default settings from overrides or database. |
|
145 No checking that the default exists yet - |
|
146 that's done in the SetCurrentSettingsL() function. |
|
147 */ |
|
148 { |
|
149 GetImpl()->GetCurrentSettingsL( aSettings, aDirection, aRank ); |
|
150 } |
|
151 |
|
152 EXPORT_C void CCommsDbAccess::GetServiceSettingsL(TConnectionSettings& aSettings) |
|
153 /** |
|
154 Get service settings from database. |
|
155 No checking that the default exists yet - |
|
156 that's done in the SetCurrentSettingsL() function. |
|
157 */ |
|
158 { |
|
159 GetImpl()->GetServiceSettingsL( aSettings ); |
|
160 } |
|
161 |
|
162 |
|
163 EXPORT_C void CCommsDbAccess::GetPreferedIapL(TUint32& aIapId, TCommDbConnectionDirection aDirection, TUint32 aRank) |
|
164 /** |
|
165 Get IapId for the connection preference of ranking aRank. |
|
166 Leaves if not found |
|
167 */ |
|
168 { |
|
169 GetImpl()->GetPreferedIapL( aIapId, aDirection, aRank ); |
|
170 } |
|
171 |
|
172 EXPORT_C void CCommsDbAccess::SetModemAndLocationL(const TConnectionSettings& /*aSettings*/) |
|
173 /** |
|
174 Set the modem and location and check that relevant records exits in the database |
|
175 rite the new values back into the database |
|
176 |
|
177 MM.TSY only supports a single modem, it cannot drive separate |
|
178 fax/data and phone/sms modems |
|
179 Added a fix so if the fax/data modem uses MM.TSY and the phone/SMS |
|
180 is some other modem also using MM.TSY, the phone/SMS modem will be |
|
181 changed to the same value as the fax/data modem |
|
182 |
|
183 Check if the fax/data modem uses MM.TSY |
|
184 If not then thats ok so return and continue connection setup |
|
185 Find out which modem is used for Phone/SMS services |
|
186 If it is the same modem, again that's ok so return and continue setup |
|
187 Check if the phone/sms modem uses MM.TSY |
|
188 If not then thats ok so return and continue connection setup |
|
189 So now we know fax/data and phone/sms use different modems but |
|
190 both modems are driven by MM.TSY |
|
191 To avoid a panic in MM.TSY, set the phone/sms modem to be the same as |
|
192 the fax/data modem |
|
193 |
|
194 */ |
|
195 |
|
196 { |
|
197 // DEPRECATED |
|
198 User::Leave(KErrNotSupported); |
|
199 } |
|
200 |
|
201 EXPORT_C void CCommsDbAccess::SetCurrentSettingsL(const TConnectionSettings& aSettings) |
|
202 /** |
|
203 Set current settings to aSettings and check that relevant |
|
204 records exist in the databases. If the settings have been changed |
|
205 (not overrides) write the new values back to the database. |
|
206 */ |
|
207 { |
|
208 GetImpl()->SetCurrentSettingsL( aSettings ); |
|
209 } |
|
210 |
|
211 EXPORT_C void CCommsDbAccess::SetPreferedIapL(TUint32& aIapId, TCommDbConnectionDirection aDirection, TUint32 aRank) |
|
212 /** |
|
213 Set current settings to aSettings and check that relevant |
|
214 records exist in the databases. If the settings have been changed |
|
215 (not overrides) write the new values back to the database. |
|
216 |
|
217 */ |
|
218 { |
|
219 GetImpl()->SetPreferedIapL( aIapId, aDirection, aRank ); |
|
220 } |
|
221 |
|
222 EXPORT_C TBool CCommsDbAccess::DoesIapExistL(TUint32 aIapId) |
|
223 /** |
|
224 Check for the presence of an IAP of record number aIapId |
|
225 */ |
|
226 { |
|
227 return GetImpl()->DoesIapExistL( aIapId ); |
|
228 } |
|
229 |
|
230 EXPORT_C void CCommsDbAccess::GetFirstValidIapL(TUint32& aIapId) |
|
231 { |
|
232 GetImpl()->GetFirstValidIapL( aIapId ); |
|
233 } |
|
234 |
|
235 EXPORT_C TBool CCommsDbAccess::IsTelNumLengthZeroForRasConnectionL(TConnectionSettings& aSettings) |
|
236 /** |
|
237 Check whether this connection is RAS connection. Default telephone |
|
238 number lenght will be zero if it is, as RAS does not need to dial up. |
|
239 Direct connection is part of CsdAgx and that's why we need to check |
|
240 if the service setting is DIAL_OUT_ISP |
|
241 */ |
|
242 { |
|
243 return GetImpl()->IsTelNumLengthZeroForRasConnectionL( aSettings ); |
|
244 } |
|
245 |
|
246 EXPORT_C TInt CCommsDbAccess::GetConnectionAttempts() |
|
247 { |
|
248 return GetImpl()->GetConnectionAttempts(); |
|
249 } |
|
250 |
|
251 EXPORT_C void CCommsDbAccess::GetBearerAvailabilityTsyNameL(TDes& aTsyName) |
|
252 /** |
|
253 Get the name of the TSY that should be used for bearer availability checking. |
|
254 If this global setting is not found then just use the TSY of the current modem |
|
255 */ |
|
256 { |
|
257 GetImpl()->GetBearerAvailabilityTsyNameL( aTsyName ); |
|
258 } |
|
259 |
|
260 EXPORT_C void CCommsDbAccess::GetTsyNameL(TDes& aTsyName) |
|
261 /** |
|
262 Get the TSY name from the override settings or from the current modem settings |
|
263 */ |
|
264 { |
|
265 GetImpl()->GetTsyNameL( aTsyName ); |
|
266 } |
|
267 |
|
268 EXPORT_C void CCommsDbAccess::SetCommPortL(const RCall::TCommPort& aCommPort) |
|
269 /** |
|
270 Set the comm port from ETEL, so that we all use the same one for |
|
271 dial up and dial in |
|
272 */ |
|
273 { |
|
274 GetImpl()->SetCommPortL( aCommPort ); |
|
275 } |
|
276 |
|
277 EXPORT_C void CCommsDbAccess::GetServiceTypeL(TDes& aServiceType) |
|
278 { |
|
279 GetImpl()->GetServiceTypeL( aServiceType ); |
|
280 } |
|
281 |
|
282 void CCommsDbAccess::GetAuthParamsL(TBool& aPromptForAuth,TDes& aUsername,TDes& aPassword) |
|
283 /** |
|
284 Get boolean PromptForAuth and authentication name and password |
|
285 Not valid for dial in ISP. |
|
286 */ |
|
287 { |
|
288 GetImpl()->GetAuthParamsL( aPromptForAuth, aUsername, aPassword ); |
|
289 } |
|
290 |
|
291 void CCommsDbAccess::GetAgentExtL(const TDesC& aServiceType, TDes& aAgentExt) |
|
292 { |
|
293 GetImpl()->GetAgentExtL( aServiceType, aAgentExt ); |
|
294 } |
|
295 |
|
296 EXPORT_C void CCommsDbAccess::SetNetworkMode(const RMobilePhone::TMobilePhoneNetworkMode aNetworkMode) |
|
297 /** |
|
298 MobileIP: used for Mobile IP to know on what network we are on. |
|
299 */ |
|
300 { |
|
301 GetImpl()->SetNetworkMode( aNetworkMode ); |
|
302 } |
|
303 |
|
304 EXPORT_C RMobilePhone::TMobilePhoneNetworkMode CCommsDbAccess::NetworkMode() const |
|
305 /** |
|
306 What type of network we are on? |
|
307 */ |
|
308 { |
|
309 return GetImpl()->NetworkMode(); |
|
310 } |
|
311 |
|
312 EXPORT_C TInt CCommsDbAccess::ReadInt(const TDesC& aField, TUint32& aValue) |
|
313 /** |
|
314 Read the integer in the field aField of the database into aValue |
|
315 */ |
|
316 { |
|
317 return GetImpl()->ReadInt( aField, aValue ); |
|
318 } |
|
319 |
|
320 EXPORT_C TInt CCommsDbAccess::ReadBool(const TDesC& aField, TBool& aValue) |
|
321 /** |
|
322 Read the boolean in the field aField of the database into aValue |
|
323 */ |
|
324 { |
|
325 return GetImpl()->ReadBool( aField, aValue ); |
|
326 } |
|
327 |
|
328 EXPORT_C TInt CCommsDbAccess::ReadDes(const TDesC& aField, TDes8& aValue) |
|
329 /** |
|
330 Read the text in the field aField of the database into aValue |
|
331 */ |
|
332 { |
|
333 return GetImpl()->ReadDes( aField, aValue ); |
|
334 } |
|
335 |
|
336 EXPORT_C TInt CCommsDbAccess::ReadDes(const TDesC& aField, TDes16& aValue) |
|
337 /** |
|
338 Read the text in the field aField of the database into aValue |
|
339 */ |
|
340 { |
|
341 return GetImpl()->ReadDes( aField, aValue ); |
|
342 } |
|
343 |
|
344 EXPORT_C HBufC* CCommsDbAccess::ReadLongDesLC(const TDesC& aField) |
|
345 /** |
|
346 Read the long text in the field aField of the database and return it |
|
347 */ |
|
348 { |
|
349 return GetImpl()->ReadLongDesLC( aField ); |
|
350 } |
|
351 |
|
352 EXPORT_C TInt CCommsDbAccess::WriteInt(const TDesC& aField, TUint32 aValue ) |
|
353 { |
|
354 return GetImpl()->WriteInt( aField, aValue ); |
|
355 } |
|
356 |
|
357 EXPORT_C TInt CCommsDbAccess::WriteBool(const TDesC& aField, TBool aValue ) |
|
358 { |
|
359 return GetImpl()->WriteBool( aField, aValue ); |
|
360 } |
|
361 |
|
362 EXPORT_C TInt CCommsDbAccess::WriteDes(const TDesC& aField, const TDesC16& aValue ) |
|
363 { |
|
364 return GetImpl()->WriteDes( aField, aValue ); |
|
365 } |
|
366 |
|
367 EXPORT_C TInt CCommsDbAccess::WriteDes(const TDesC& aField, const TDesC8& aValue ) |
|
368 { |
|
369 return GetImpl()->WriteDes( aField, aValue ); |
|
370 } |
|
371 |
|
372 EXPORT_C void CCommsDbAccess::RequestNotificationOfServiceChangeL(MServiceChangeObserver* aObserver) |
|
373 { |
|
374 GetImpl()->RequestNotificationOfServiceChangeL( aObserver ); |
|
375 } |
|
376 |
|
377 EXPORT_C void CCommsDbAccess::CancelRequestNotificationOfServiceChange(MServiceChangeObserver* aObserver) |
|
378 { |
|
379 GetImpl()->CancelRequestNotificationOfServiceChange( aObserver ); |
|
380 } |
|
381 |
|
382 EXPORT_C void CCommsDbAccess::GetIntL(const TDesC& aTable, const TDesC& aField, TUint32& aValue) |
|
383 { |
|
384 GetImpl()->GetIntL( aTable, aField, aValue ); |
|
385 } |
|
386 |
|
387 EXPORT_C void CCommsDbAccess::GetBoolL(const TDesC& aTable, const TDesC& aField, TBool& aValue) |
|
388 { |
|
389 GetImpl()->GetBoolL( aTable, aField, aValue ); |
|
390 } |
|
391 |
|
392 EXPORT_C void CCommsDbAccess::GetDesL(const TDesC& aTable, const TDesC& aField, TDes8& aValue) |
|
393 { |
|
394 GetImpl()->GetDesL( aTable, aField, aValue ); |
|
395 } |
|
396 |
|
397 EXPORT_C void CCommsDbAccess::GetDesL(const TDesC& aTable, const TDesC& aField, TDes16& aValue) |
|
398 { |
|
399 GetImpl()->GetDesL( aTable, aField, aValue ); |
|
400 } |
|
401 |
|
402 EXPORT_C HBufC* CCommsDbAccess::GetLongDesLC(const TDesC& aTable, const TDesC& aField) |
|
403 { |
|
404 return GetImpl()->GetLongDesLC( aTable, aField ); |
|
405 } |
|
406 |
|
407 EXPORT_C TInt CCommsDbAccess::GetLengthOfLongDesL(const TDesC& aTable, const TDesC& aField) |
|
408 { |
|
409 return GetImpl()->GetLengthOfLongDesL( aTable, aField ); |
|
410 } |
|
411 |
|
412 EXPORT_C void CCommsDbAccess::GetGlobalL(const TDesC& aName,TUint32& aVal) |
|
413 { |
|
414 GetImpl()->GetGlobalL( aName, aVal ); |
|
415 } |
|
416 |
|
417 EXPORT_C CCommsDbAccess::CCommsDbAccessModemTable* CCommsDbAccess::ModemTable() |
|
418 { |
|
419 return GetImpl()->ModemTable(); |
|
420 } |
|
421 |
|
422 EXPORT_C TUint32 CCommsDbAccess::LocationId() const |
|
423 { |
|
424 return GetImpl()->LocationId(); |
|
425 } |
|
426 |
|
427 EXPORT_C TCommDbConnectionDirection CCommsDbAccess::GetConnectionDirection() const |
|
428 { |
|
429 return GetImpl()->GetConnectionDirection(); |
|
430 } |
|
431 |
|
432 |
|
433 /** Data capability checking */ |
|
434 EXPORT_C TInt CCommsDbAccess::CheckReadCapability( const TDesC& aField, const RMessagePtr2* aMessage ) |
|
435 { |
|
436 return GetImpl()->CheckReadCapability( aField, aMessage ); |
|
437 } |
|
438 |
|
439 EXPORT_C TInt CCommsDbAccess::CheckWriteCapability( const TDesC& aField, const RMessagePtr2* aMessage ) |
|
440 { |
|
441 return GetImpl()->CheckWriteCapability( aField, aMessage ); |
|
442 } |
|
443 |