|
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: Defines a class, which holds logical proxy information. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 |
|
24 #include "CWPAPLogicalProxy.h" |
|
25 #include <e32svr.h> |
|
26 #include <CWPCharacteristic.h> |
|
27 #include <CWPParameter.h> |
|
28 #include "CWPLog.h" |
|
29 #include "CWPAPPhysicalProxy.h" |
|
30 #include "CWPAPPort.h" |
|
31 #include "WPAPAdapter.pan" |
|
32 #include "WPAPDefs.h" |
|
33 #include <cmconnectionmethodext.h> |
|
34 |
|
35 // ============================ MEMBER FUNCTIONS =============================== |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CWPAPLogicalProxy::NewL |
|
39 // Two-phased constructor. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CWPAPLogicalProxy* CWPAPLogicalProxy::NewLC( |
|
43 const TDesC& aDefaultName, |
|
44 CWPCharacteristic& aCharacteristic ) |
|
45 { |
|
46 CWPAPLogicalProxy* self = new(ELeave) CWPAPLogicalProxy( aCharacteristic, |
|
47 aDefaultName ); |
|
48 CleanupStack::PushL( self ); |
|
49 self->ConstructL(); |
|
50 aCharacteristic.AcceptL( *self ); |
|
51 return self; |
|
52 } |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // Destructor |
|
56 // ----------------------------------------------------------------------------- |
|
57 // |
|
58 CWPAPLogicalProxy::~CWPAPLogicalProxy() |
|
59 { |
|
60 delete iPort; |
|
61 iPhysicalProxies.ResetAndDestroy(); |
|
62 iPhysicalProxies.Close(); |
|
63 } |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CWPAPLogicalProxy::ValidateL |
|
67 // ----------------------------------------------------------------------------- |
|
68 // |
|
69 TBool CWPAPLogicalProxy::ValidateL() |
|
70 { |
|
71 // Logical proxy is valid if it contains either one or more |
|
72 // physical proxies |
|
73 return iPhysicalProxies.Count() > 0; |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CWPAPLogicalProxy::AddDataL |
|
80 // ----------------------------------------------------------------------------- |
|
81 // |
|
82 void CWPAPLogicalProxy::AddDataL( RCmConnectionMethodExt& aCmItem ) |
|
83 { |
|
84 LOG("--CWPAP CWPAPLogicalProxy::AddDataL begin--"); |
|
85 // This method is called by child physical proxy. |
|
86 |
|
87 // Store name if came along with the document. If missing then access point |
|
88 // name is used. |
|
89 if ( iName ) |
|
90 { |
|
91 // CMManager |
|
92 aCmItem.SetStringAttributeL( CMManager::ECmName, iName->Value() ); |
|
93 } |
|
94 |
|
95 // Store homepage if defined. |
|
96 if ( iHomepage ) |
|
97 { |
|
98 // CMManager |
|
99 TRAPD( err, aCmItem.SetStringAttributeL( CMManager::ECmStartPage, iHomepage->Value() )); |
|
100 |
|
101 LOG2("CWPAP EApWapStartPage, value: %S, err: %d", &iHomepage->Value(), err); |
|
102 User::LeaveIfError( err ); |
|
103 } |
|
104 |
|
105 // Store port data, which overrides the data stored by child physical proxy. |
|
106 |
|
107 if ( iPort ) |
|
108 { |
|
109 //CMManager |
|
110 iPort->AddDataL (aCmItem); |
|
111 |
|
112 } |
|
113 LOG("--CWPAP CWPAPLogicalProxy::AddDataL end--"); |
|
114 } |
|
115 |
|
116 |
|
117 // ----------------------------------------------------------------------------- |
|
118 // CWPAPLogicalProxy::AddItemsL |
|
119 // ----------------------------------------------------------------------------- |
|
120 // |
|
121 TInt CWPAPLogicalProxy::AddItemsL( RPointerArray<CWPAPAccesspointItem>& aItems, |
|
122 CWPAPItemBase* /*aLogicalProxy*/, |
|
123 CWPAPItemBase* /*aPhysicalProxy*/ ) |
|
124 { |
|
125 TInt count( 0 ); |
|
126 for( TInt i( 0 ); i < iPhysicalProxies.Count(); i++ ) |
|
127 { |
|
128 CWPAPPhysicalProxy* pp = iPhysicalProxies[ i ]; |
|
129 if( pp->ValidateL() ) |
|
130 { |
|
131 count += pp->AddItemsL( aItems, this, NULL ); |
|
132 } |
|
133 } |
|
134 |
|
135 return count; |
|
136 } |
|
137 |
|
138 // ----------------------------------------------------------------------------- |
|
139 // CWPAPLogicalProxy::Name |
|
140 // ----------------------------------------------------------------------------- |
|
141 // |
|
142 const TDesC& CWPAPLogicalProxy::Name() |
|
143 { |
|
144 if ( iName ) |
|
145 { |
|
146 return iName->Value(); |
|
147 } |
|
148 else |
|
149 { |
|
150 return KNullDesC; |
|
151 } |
|
152 } |
|
153 |
|
154 // ----------------------------------------------------------------------------- |
|
155 // CWPAPLogicalProxy::VisitL |
|
156 // ----------------------------------------------------------------------------- |
|
157 // |
|
158 void CWPAPLogicalProxy::VisitL( CWPCharacteristic& aCharacteristic ) |
|
159 { |
|
160 TInt type = aCharacteristic.Type(); |
|
161 |
|
162 // KWPPort |
|
163 |
|
164 // One valid port is enough for us. |
|
165 if ( type == KWPPort && !iPort ) |
|
166 { |
|
167 CWPAPPort* port = CWPAPPort::NewLC( aCharacteristic ); |
|
168 |
|
169 if ( port->ValidateL() ) |
|
170 { |
|
171 iPort = port; |
|
172 CleanupStack::Pop( port ); |
|
173 } |
|
174 else // Data not valid. |
|
175 { |
|
176 CleanupStack::PopAndDestroy( port ); |
|
177 } |
|
178 } |
|
179 |
|
180 // KWPPxPhysical |
|
181 |
|
182 else if ( type == KWPPxPhysical ) |
|
183 { |
|
184 CWPAPPhysicalProxy* physicalProxy = CWPAPPhysicalProxy::NewLC( |
|
185 iDefaultName, |
|
186 aCharacteristic, |
|
187 iCharacteristic, |
|
188 iPort ); |
|
189 |
|
190 if ( physicalProxy->ValidateL() ) |
|
191 { |
|
192 User::LeaveIfError( iPhysicalProxies.Append( physicalProxy ) ); |
|
193 CleanupStack::Pop( physicalProxy ); |
|
194 } |
|
195 else // Data not valid. |
|
196 { |
|
197 CleanupStack::PopAndDestroy( physicalProxy ); |
|
198 } |
|
199 } |
|
200 else if ( type == KWPPxAuthInfo ) |
|
201 { |
|
202 // Not supported |
|
203 } |
|
204 } |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CWPAPLogicalProxy::VisitL |
|
208 // ----------------------------------------------------------------------------- |
|
209 // |
|
210 void CWPAPLogicalProxy::VisitL( CWPParameter& aParameter) |
|
211 { |
|
212 TInt id = aParameter.ID(); |
|
213 const TDesC& value = aParameter.Value(); |
|
214 |
|
215 if ( value.Length() == 0 ) |
|
216 { |
|
217 // No use process zero length value. |
|
218 return; |
|
219 } |
|
220 |
|
221 switch ( id ) |
|
222 { |
|
223 case EWPParameterStartPage: // iHomepage |
|
224 { |
|
225 if ( !iHomepage ) |
|
226 { |
|
227 iHomepage = &aParameter; |
|
228 } |
|
229 break; |
|
230 } |
|
231 case EWPParameterName: |
|
232 { |
|
233 if ( !iName ) |
|
234 { |
|
235 iName = &aParameter; |
|
236 } |
|
237 break; |
|
238 } |
|
239 default: |
|
240 { |
|
241 // Just let through |
|
242 } |
|
243 } |
|
244 } |
|
245 |
|
246 // ----------------------------------------------------------------------------- |
|
247 // CWPAPLogicalProxy::CWPAPLogicalProxy |
|
248 // C++ default constructor can NOT contain any code, that |
|
249 // might leave. |
|
250 // ----------------------------------------------------------------------------- |
|
251 // |
|
252 CWPAPLogicalProxy::CWPAPLogicalProxy( CWPCharacteristic& aCharacteristic, |
|
253 const TDesC& aDefaultName ) |
|
254 : CWPAPItemBase( aDefaultName ), |
|
255 iPhysicalProxies( KInitialArraySize ), |
|
256 iCharacteristic( aCharacteristic ) |
|
257 { |
|
258 } |
|
259 |
|
260 // ----------------------------------------------------------------------------- |
|
261 // CWPAPLogicalProxy::ConstructL |
|
262 // Symbian 2nd phase constructor can leave. |
|
263 // ----------------------------------------------------------------------------- |
|
264 // |
|
265 void CWPAPLogicalProxy::ConstructL() |
|
266 { |
|
267 } |
|
268 |
|
269 // End of File |