|
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: SUPL settings class |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 #include <CWPParameter.h> |
|
22 #include <WPAdapterUtil.h> |
|
23 #include <ApUtils.h> |
|
24 |
|
25 #include "epos_comasupltrace.h" |
|
26 #include "epos_comasuplsettings.h" |
|
27 #include "epos_comasuplsettingsrepository.h" |
|
28 #include "epos_comasuplparameters.h" |
|
29 #include "epos_omasuplprovhandler.pan" |
|
30 #include "epos_omasuplprovhandler.hrh" |
|
31 #include <epos_omasuplprovhandlerres.rsg> |
|
32 |
|
33 |
|
34 _LIT( KTraceSuplSettings, "epos_comasuplsettings.cpp" ); |
|
35 |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // COMASuplSettings::NewL |
|
39 // Factory method that creates an instance of COMASuplSettings |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 COMASuplSettings* COMASuplSettings::NewL( COMASuplParameters* aItem, COMASuplTrace* aTrace ) |
|
43 { |
|
44 COMASuplSettings* self = new ( ELeave ) COMASuplSettings( aItem, aTrace ); |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL(); |
|
47 CleanupStack::Pop(); |
|
48 return self; |
|
49 } |
|
50 |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // Destructor |
|
54 // |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 COMASuplSettings::~COMASuplSettings() |
|
58 { |
|
59 delete iDefaultName; |
|
60 delete iItem; |
|
61 } |
|
62 |
|
63 |
|
64 // ----------------------------------------------------------------------------- |
|
65 // COMASuplSettings::SaveL |
|
66 // |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 void COMASuplSettings::SaveL( COMASuplSettingsRepository* aRepository ) |
|
70 { |
|
71 iTrace->Trace( _L( "COMASuplSettings::SaveL() Start" ), KTraceSuplSettings, __LINE__ ); |
|
72 |
|
73 HBufC* iapn = NULL; |
|
74 _LIT(KNull, ""); |
|
75 TUint32 iapID = 0; |
|
76 // Retrieve APN from Comms DB |
|
77 TRAPD(err, iapID = IapIdFromWapIdL( iItem->AssociatedIapId() ) ); |
|
78 if(err == KErrNone) |
|
79 { |
|
80 iapn = iItem->AssociatedIapNameL( iapID, iCommsDb ); |
|
81 if ( iapn == NULL ) |
|
82 { |
|
83 iTrace->Trace( _L( "Error Retrieving APN from CommsDB" ), |
|
84 KTraceSuplSettings, __LINE__ ); |
|
85 User::Leave(KErrNotFound); |
|
86 } |
|
87 |
|
88 |
|
89 } |
|
90 |
|
91 // Retrieve HSLP Address |
|
92 const TDesC& hslp = iItem->ParameterValue( EWPParameterAddr ); |
|
93 |
|
94 if(iapn!=NULL) |
|
95 { |
|
96 CleanupStack::PushL( iapn ); |
|
97 aRepository->SaveL(iapn->Des(), hslp); |
|
98 CleanupStack::PopAndDestroy(); |
|
99 } |
|
100 else |
|
101 aRepository->SaveL(KNull, hslp); |
|
102 |
|
103 |
|
104 } |
|
105 |
|
106 |
|
107 // ----------------------------------------------------------------------------- |
|
108 // COMASuplSettings::SummaryText |
|
109 // |
|
110 // ----------------------------------------------------------------------------- |
|
111 // |
|
112 const TDesC& COMASuplSettings::SummaryText() |
|
113 { |
|
114 return *iDefaultName; |
|
115 } |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // COMASuplSettings::SetDefaultNameL |
|
119 // |
|
120 // ----------------------------------------------------------------------------- |
|
121 // |
|
122 void COMASuplSettings::SetDefaultNameL( const TDesC& aDefaultName ) |
|
123 { |
|
124 if ( aDefaultName.Length() ) |
|
125 { |
|
126 HBufC* temp = aDefaultName.AllocL(); |
|
127 delete iDefaultName; |
|
128 iDefaultName = temp; |
|
129 } |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // COMASuplSettings::SetCommsDataBase |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void COMASuplSettings::SetCommsDataBase( CCommsDatabase& aCommsDataBase ) |
|
137 { |
|
138 iCommsDb = &aCommsDataBase; |
|
139 } |
|
140 |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // COMASuplSettings::IapIdFromWapIdL |
|
144 // |
|
145 // ----------------------------------------------------------------------------- |
|
146 // |
|
147 TUint32 COMASuplSettings::IapIdFromWapIdL( TUint32 aWapId ) const |
|
148 { |
|
149 CApUtils* apUtils = CApUtils::NewLC( *iCommsDb ); |
|
150 TUint32 iapId = NULL; |
|
151 iapId = apUtils->IapIdFromWapIdL( aWapId ); |
|
152 __ASSERT_ALWAYS( iapId, Panic( SuplAdapterInvalidId ) ); |
|
153 CleanupStack::PopAndDestroy( apUtils ); |
|
154 return iapId; |
|
155 } |
|
156 |
|
157 |
|
158 // ----------------------------------------------------------------------------- |
|
159 // COMASuplSettings::COMASuplSettings |
|
160 // C++ default constructor can NOT contain any code, that |
|
161 // might leave. |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 COMASuplSettings::COMASuplSettings( COMASuplParameters* aItem, COMASuplTrace* aTrace ) |
|
165 :iItem( aItem ) |
|
166 { |
|
167 iTrace = aTrace; |
|
168 } |
|
169 |
|
170 |
|
171 // ----------------------------------------------------------------------------- |
|
172 // COMASuplSettings::ConstructL |
|
173 // Symbian 2nd phase constructor can leave. |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 void COMASuplSettings::ConstructL() |
|
177 { |
|
178 TFileName fileName; |
|
179 Dll::FileName( fileName ); |
|
180 iDefaultName = WPAdapterUtil::ReadHBufCL( fileName, KSuplAdapter, |
|
181 R_QTN_SM_DEFAULT_SUPL_NAME ); |
|
182 } |