1 /* |
|
2 * Copyright (c) 2002 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: Base for WAP adapters. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include <commdb.h> |
|
23 #include <cmmanagerext.h> |
|
24 #include <cmconnectionmethodext.h> |
|
25 #include <CWPAdapter.h> |
|
26 #include <CWPCharacteristic.h> |
|
27 #include <CWPParameter.h> |
|
28 #include <wpwapadapterresource.rsg> |
|
29 #include "CWPWAPItemBAse.h" |
|
30 #include "CWPWAPAdapterBase.h" |
|
31 #include "WPWAPDebug.h" |
|
32 |
|
33 // ============================ MEMBER FUNCTIONS =============================== |
|
34 |
|
35 // ----------------------------------------------------------------------------- |
|
36 // CWPWAPAdapterBase::CWPWAPAdapterBase |
|
37 // C++ default constructor can NOT contain any code, that |
|
38 // might leave. |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 CWPWAPAdapterBase::CWPWAPAdapterBase() |
|
42 : CWPAdapter() |
|
43 { |
|
44 } |
|
45 |
|
46 // ----------------------------------------------------------------------------- |
|
47 // CWPWAPAdapterBase::BaseConstructL |
|
48 // 2nd phase base class constructor. |
|
49 // ----------------------------------------------------------------------------- |
|
50 // |
|
51 void CWPWAPAdapterBase::BaseConstructL() |
|
52 { |
|
53 } |
|
54 |
|
55 // Destructor |
|
56 CWPWAPAdapterBase::~CWPWAPAdapterBase() |
|
57 { |
|
58 iItems.ResetAndDestroy(); |
|
59 iHiddenItems.ResetAndDestroy(); |
|
60 delete iCommsDb; |
|
61 |
|
62 if ( iCmManager != NULL ) |
|
63 { |
|
64 iCmManager->Close(); |
|
65 delete iCmManager; |
|
66 } |
|
67 } |
|
68 |
|
69 // ----------------------------------------------------------------------------- |
|
70 // CWPWAPAdapterBase::SummaryCount |
|
71 // ----------------------------------------------------------------------------- |
|
72 // |
|
73 TInt CWPWAPAdapterBase::ItemCount() const |
|
74 { |
|
75 return iItems.Count(); |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CWPWAPAdapterBase::SummaryTitle |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 const TDesC16& CWPWAPAdapterBase::SummaryTitle(TInt aIndex) const |
|
83 { |
|
84 return iItems[aIndex]->Title(); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CWPWAPAdapterBase::SummaryText |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 const TDesC& CWPWAPAdapterBase::SummaryText(TInt aIndex) const |
|
92 { |
|
93 return iItems[aIndex]->Name(); |
|
94 } |
|
95 |
|
96 // ----------------------------------------------------------------------------- |
|
97 // CWPWAPAdapterBase::SaveL |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 void CWPWAPAdapterBase::SaveL(TInt aIndex) |
|
101 { |
|
102 iItems[aIndex]->SaveL(); |
|
103 } |
|
104 |
|
105 // ----------------------------------------------------------------------------- |
|
106 // CWPWAPAdapterBase::CanSetAsDefault |
|
107 // ----------------------------------------------------------------------------- |
|
108 // |
|
109 TBool CWPWAPAdapterBase::CanSetAsDefault(TInt aIndex) const |
|
110 { |
|
111 return iItems[aIndex]->CanSetAsDefault(); |
|
112 } |
|
113 |
|
114 // ----------------------------------------------------------------------------- |
|
115 // CWPWAPAdapterBase::SetAsDefaultL |
|
116 // ----------------------------------------------------------------------------- |
|
117 // |
|
118 void CWPWAPAdapterBase::SetAsDefaultL(TInt aIndex) |
|
119 { |
|
120 iItems[aIndex]->SetAsDefaultL(); |
|
121 } |
|
122 |
|
123 // ----------------------------------------------------------------------------- |
|
124 // CWPWAPAdapterBase::DetailsL |
|
125 // ----------------------------------------------------------------------------- |
|
126 // |
|
127 TInt CWPWAPAdapterBase::DetailsL( TInt /*aItem*/, MWPPairVisitor& /*aVisitor*/ ) |
|
128 { |
|
129 return KErrNotSupported; |
|
130 } |
|
131 |
|
132 // ----------------------------------------------------------------------------- |
|
133 // CWPWAPAdapterBase::VisitL |
|
134 // ----------------------------------------------------------------------------- |
|
135 // |
|
136 void CWPWAPAdapterBase::VisitL( CWPCharacteristic& aCharacteristic ) |
|
137 { |
|
138 switch( aCharacteristic.Type() ) |
|
139 { |
|
140 case KWPApplication: |
|
141 { |
|
142 aCharacteristic.AcceptL( *this ); |
|
143 ApplicationL( aCharacteristic ); |
|
144 iAppID.Set( KNullDesC ); |
|
145 break; |
|
146 } |
|
147 |
|
148 default: |
|
149 { |
|
150 break; |
|
151 } |
|
152 } |
|
153 } |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CWPWAPAdapterBase::VisitL |
|
157 // ----------------------------------------------------------------------------- |
|
158 // |
|
159 void CWPWAPAdapterBase::VisitL( CWPParameter& aParameter ) |
|
160 { |
|
161 if( aParameter.ID() == EWPParameterAppID ) |
|
162 { |
|
163 iAppID.Set( aParameter.Value() ); |
|
164 } |
|
165 } |
|
166 |
|
167 // ----------------------------------------------------------------------------- |
|
168 // CWPWAPAdapterBase::VisitL |
|
169 // ----------------------------------------------------------------------------- |
|
170 // |
|
171 void CWPWAPAdapterBase::VisitLinkL( CWPCharacteristic& /*aLink*/ ) |
|
172 { |
|
173 } |
|
174 |
|
175 // ----------------------------------------------------------------------------- |
|
176 // CWPWAPAdapterBase::ContextExtension |
|
177 // ----------------------------------------------------------------------------- |
|
178 // |
|
179 TInt CWPWAPAdapterBase::ContextExtension( MWPContextExtension*& aExtension ) |
|
180 { |
|
181 aExtension = this; |
|
182 return KErrNone; |
|
183 } |
|
184 |
|
185 // ----------------------------------------------------------------------------- |
|
186 // CWPWAPAdapterBase::SaveDataL |
|
187 // ----------------------------------------------------------------------------- |
|
188 // |
|
189 const TDesC8& CWPWAPAdapterBase::SaveDataL( TInt aIndex ) const |
|
190 { |
|
191 return iItems[aIndex]->SaveData(); |
|
192 } |
|
193 |
|
194 // ----------------------------------------------------------------------------- |
|
195 // CWPWAPAdapterBase::DeleteL |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 void CWPWAPAdapterBase::DeleteL( const TDesC8& aSaveData ) |
|
199 { |
|
200 CreateDbL(); |
|
201 |
|
202 TPckgBuf<MWPWAPItemBase::TWPWAPSaveItem> pckg; |
|
203 pckg.Copy( aSaveData ); |
|
204 |
|
205 // Base class handles only access point deletion |
|
206 if( pckg().iSaveItemType == KWPWAPItemTypeAccesspoint ) |
|
207 { |
|
208 DVA( "DeleteL: Deleting access point %08x", pckg().iUID ); |
|
209 TRAPD( err, iCmManager->ConnectionMethodL( pckg().iUID).DeleteL()); |
|
210 DVA( "DeleteL: Deleted, %d", err ); |
|
211 |
|
212 switch( err ) |
|
213 { |
|
214 case KErrNotFound: |
|
215 { |
|
216 // Item not existing is what we want, so this error is ok |
|
217 break; |
|
218 } |
|
219 |
|
220 case KErrLocked: |
|
221 { |
|
222 // Transform the code so that the caller can retry |
|
223 User::Leave( EWPCommsDBLocked ); |
|
224 break; |
|
225 } |
|
226 |
|
227 default: |
|
228 { |
|
229 User::LeaveIfError( err ); |
|
230 break; |
|
231 } |
|
232 } |
|
233 } |
|
234 } |
|
235 |
|
236 // ----------------------------------------------------------------------------- |
|
237 // CWPWAPAdapterBase::Uid |
|
238 // ----------------------------------------------------------------------------- |
|
239 // |
|
240 TUint32 CWPWAPAdapterBase::Uid() const |
|
241 { |
|
242 return iDtor_ID_Key.iUid; |
|
243 } |
|
244 |
|
245 // ----------------------------------------------------------------------------- |
|
246 // CWPWAPAdapterBase::CreateDbL |
|
247 // ----------------------------------------------------------------------------- |
|
248 // |
|
249 void CWPWAPAdapterBase::CreateDbL() |
|
250 { |
|
251 if( !iCommsDb ) |
|
252 { |
|
253 iCommsDb = CCommsDatabase::NewL(); |
|
254 } |
|
255 iCmManager = new RCmManagerExt; |
|
256 iCmManager->OpenL(); |
|
257 |
|
258 |
|
259 } |
|
260 |
|
261 // End of File |
|