|
1 /* |
|
2 * ============================================================================== |
|
3 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 * All rights reserved. |
|
5 * This component and the accompanying materials are made available |
|
6 * under the terms of "Eclipse Public License v1.0" |
|
7 * which accompanies this distribution, and is available |
|
8 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
9 * |
|
10 * Initial Contributors: |
|
11 * Nokia Corporation - initial contribution. |
|
12 * |
|
13 * Contributors: |
|
14 * |
|
15 * Description: |
|
16 * |
|
17 * ============================================================================== |
|
18 */ |
|
19 |
|
20 #include <e32base.h> |
|
21 #include <cmconnectionmethoddef.h> |
|
22 #include <nsmldmtreedbclient.h> |
|
23 |
|
24 #include "ProxyBranch.h" |
|
25 #include "Utils.h" |
|
26 |
|
27 #include "OstTraceDefinitions.h" |
|
28 #ifdef OST_TRACE_COMPILER_IN_USE |
|
29 #include "ProxyBranchTraces.h" |
|
30 #endif |
|
31 |
|
32 // ------------------------------------------------------------------------------------------------ |
|
33 // Constants |
|
34 // ------------------------------------------------------------------------------------------------ |
|
35 _LIT8( KCMProxyDdf, "Proxy" ); |
|
36 _LIT8( KCMProxyDdfProxyId, "ProxyId" ); |
|
37 _LIT8( KCMProxyDdfName, "Name" ); |
|
38 _LIT8( KCMProxyDdfAddr, "Addr" ); |
|
39 _LIT8( KCMProxyDdfToConRef, "ToConRef" ); |
|
40 _LIT8( KCMProxyDdfConRef, "ConRef" ); |
|
41 _LIT8( KCMProxyDdfPorts, "Ports" ); |
|
42 _LIT8( KCMProxyDdfPortNbr, "PortNbr" ); |
|
43 _LIT8( KCMProxyDdfProxyParams, "ProxyParams" ); |
|
44 _LIT8( KCMProxyDdfProxyType, "ProxyType" ); |
|
45 _LIT8( KCMProxyDdfWap, "WAP" ); |
|
46 _LIT8( KCMProxyDdfStartpg, "Startpg" ); |
|
47 |
|
48 _LIT8( KCMProxyFields, "ProxyId/Addr/ToConRef/Ports/ProxyType/ProxyParams" ); |
|
49 _LIT8( KCMProxyParamsFields, "WAP" ); |
|
50 _LIT8( KCMProxyWapFields, "Startpg" ); |
|
51 _LIT8( KCMProxyNodeSeparator, "/" ); |
|
52 |
|
53 _LIT8( KDynamicProxyNodePattern, "Proxy/*" ); |
|
54 _LIT8( KDynamicProxyNodeChildUri, "Proxy/*/*" ); |
|
55 _LIT8( KDynamicToConrefNode, "Proxy/*/ToConRef" ); |
|
56 _LIT8( KDynamicToConrefNodeChildUri, "Proxy/*/ToConRef/*" ); |
|
57 _LIT8( KDynamicToConrefNodeChildUriNodes, "Proxy/*/ToConRef/*/*" ); |
|
58 _LIT8( KDynamicPortsNode, "Proxy/*/Ports" ); |
|
59 _LIT8( KDynamicPortsNodeChildUri, "Proxy/*/Ports/*" ); |
|
60 _LIT8( KDynamicPortsNodeChildUriNodes, "Proxy/*/Ports/*/*" ); |
|
61 _LIT8( KDynamicProxyParamsNode, "Proxy/*/ProxyParams" ); |
|
62 _LIT8( KDynamicProxyParamsNodeChildUri, "Proxy/*/ProxyParams/*" ); |
|
63 _LIT8( KDynamicProxyParamsWapNode, "Proxy/*/ProxyParams/WAP" ); |
|
64 |
|
65 _LIT8( KProxyAddrUri, "Proxy/*/Addr"); |
|
66 _LIT8( KProxyConrefUri, "Proxy/*/ConRef"); |
|
67 |
|
68 _LIT8( KRoot, "./"); |
|
69 |
|
70 TInt const KBufferExpandSize = 128; |
|
71 TInt const KNumOfProxyNodes = 8; |
|
72 |
|
73 _LIT8( KDynamicNodePrefix, "ProxyId"); |
|
74 |
|
75 // ======== LOCAL FUNCTIONS ========= |
|
76 |
|
77 //----------------------------------------------------------------------------- |
|
78 // CSmlDmAdapter::TError CProxyBranch::FetchLeafObjectL() |
|
79 //----------------------------------------------------------------------------- |
|
80 CSmlDmAdapter::TError CProxyBranch::FetchLeafObjectL( const TDesC8& aURI, |
|
81 const TDesC8& aLUID, |
|
82 CBufBase& aLeafObject ) |
|
83 { |
|
84 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECTL_ENTRY, |
|
85 "ENTRY: CProxyBranch::FetchLeafObjectL;aURI=%s", aURI ); |
|
86 |
|
87 RCmConnectionMethodExt cm; |
|
88 CSmlDmAdapter::TError status = CSmlDmAdapter::ENotAllowed; |
|
89 TPtrC8 leafNode = CUtils::GetLastURISeg( aURI ); |
|
90 TInt cmId( KErrNotFound ); |
|
91 if ( aLUID.Length() > 0 ) |
|
92 { |
|
93 cmId = CUtils::IntLUID( aLUID ); |
|
94 } |
|
95 else |
|
96 { |
|
97 // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx) |
|
98 cmId = GetCmIdFromURIL( aURI ); |
|
99 } |
|
100 |
|
101 if ( cmId == KErrNotFound || !GetConnectionMethodLC( *iCmManager, cm, cmId ) || |
|
102 !cm.GetBoolAttributeL(CMManager::ECmProxyUsageEnabled) ) |
|
103 { |
|
104 if ( cmId != KErrNotFound ) |
|
105 { |
|
106 CleanupStack::PopAndDestroy( &cm ); |
|
107 } |
|
108 status = CSmlDmAdapter::ENotFound; |
|
109 |
|
110 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECTL_NOT_FOUND, |
|
111 "CProxyBranch::FetchLeafObjectL;status=%{TError}", status ); |
|
112 |
|
113 return status; |
|
114 } |
|
115 |
|
116 if ( leafNode.Compare( KCMProxyDdfAddr ) == 0 ) |
|
117 { |
|
118 HBufC* serverName = cm.GetStringAttributeL( CMManager::ECmProxyServerName ); |
|
119 |
|
120 CleanupStack::PushL( serverName ); |
|
121 aLeafObject.InsertL( 0, CUtils::ConvertTo8LC( *serverName ) ); |
|
122 |
|
123 CleanupStack::PopAndDestroy(); // CUtils::ConvertTo8LC |
|
124 CleanupStack::PopAndDestroy( serverName ); |
|
125 |
|
126 status = CSmlDmAdapter::EOk; |
|
127 } |
|
128 else if ( leafNode.Compare( KCMProxyDdfConRef ) == 0 ) |
|
129 { |
|
130 TBuf8<KBufferExpandSize> conRef; |
|
131 TBuf8<KBufferExpandSize> napChildList; |
|
132 CBufBase* napChildListBuf = CBufFlat::NewL( KSmlMaxURISegLen ); |
|
133 CleanupStack::PushL( napChildListBuf ); |
|
134 |
|
135 // Get all NAP node childs |
|
136 iCallback->FetchLinkL( _L8("./NAP"), *napChildListBuf, status ); |
|
137 napChildListBuf->Read( 0, napChildList, napChildListBuf->Size() ); |
|
138 |
|
139 if ( status == CSmlDmAdapter::EOk) |
|
140 { |
|
141 // Reset operation end status |
|
142 status = CSmlDmAdapter::EError; |
|
143 |
|
144 // Find correct Uri |
|
145 while ( napChildList.Length() > 0 && status != CSmlDmAdapter::EOk ) |
|
146 { |
|
147 conRef.Append( _L("NAP/") ); |
|
148 CUtils::AppendFirstURISeg( napChildList, conRef ); |
|
149 HBufC8* napLuid = iCallback->GetLuidAllocL( conRef ); |
|
150 if ( cmId == CUtils::IntLUID( *napLuid ) ) |
|
151 { |
|
152 status = CSmlDmAdapter::EOk; |
|
153 aLeafObject.InsertL( 0, conRef ); |
|
154 } |
|
155 delete napLuid; |
|
156 conRef.Delete( 0, conRef.Length() ); |
|
157 } |
|
158 } |
|
159 |
|
160 CleanupStack::PopAndDestroy( napChildListBuf ); |
|
161 } |
|
162 else if ( leafNode.Compare( KCMProxyDdfPortNbr ) == 0 ) |
|
163 { |
|
164 TInt proxyPort = cm.GetIntAttributeL( CMManager::ECmProxyPortNumber ); |
|
165 |
|
166 aLeafObject.InsertL( 0, CUtils::IntToCharL( proxyPort ) ); |
|
167 CleanupStack::PopAndDestroy(); |
|
168 |
|
169 status = CSmlDmAdapter::EOk; |
|
170 } |
|
171 else if ( leafNode.Compare( KCMProxyDdfStartpg ) == 0 ) |
|
172 { |
|
173 HBufC* startPage = cm.GetStringAttributeL( CMManager::ECmStartPage ); |
|
174 |
|
175 CleanupStack::PushL( startPage ); |
|
176 aLeafObject.InsertL( 0, CUtils::ConvertTo8LC( *startPage ) ); |
|
177 |
|
178 CleanupStack::PopAndDestroy(); // CUtils::ConvertTo8LC |
|
179 CleanupStack::PopAndDestroy( startPage ); |
|
180 |
|
181 status = CSmlDmAdapter::EOk; |
|
182 } |
|
183 else if ( leafNode.Compare( KCMProxyDdfProxyType ) == 0 ) |
|
184 { |
|
185 HBufC* protocolName = cm.GetStringAttributeL( CMManager::ECmProxyProtocolName ); |
|
186 |
|
187 CleanupStack::PushL( protocolName ); |
|
188 aLeafObject.InsertL( 0, CUtils::ConvertTo8LC( *protocolName ) ); |
|
189 |
|
190 CleanupStack::PopAndDestroy(); // CUtils::ConvertTo8LC |
|
191 CleanupStack::PopAndDestroy( protocolName ); |
|
192 |
|
193 status = CSmlDmAdapter::EOk; |
|
194 } |
|
195 else if ( leafNode.Compare( KCMProxyDdfProxyId ) == 0 ) |
|
196 { |
|
197 TPtrC8 dynamicNode = GetDynamicProxyNodeUri( aURI ); |
|
198 aLeafObject.InsertL( 0, dynamicNode ); |
|
199 status = CSmlDmAdapter::EOk; |
|
200 } |
|
201 |
|
202 CleanupStack::PopAndDestroy( &cm ); |
|
203 |
|
204 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECTL_EXIT, |
|
205 "EXIT: CProxyBranch::FetchLeafObjectL;status=%{TError}", status ); |
|
206 return status; |
|
207 } |
|
208 |
|
209 //----------------------------------------------------------------------------- |
|
210 // TUint32 CProxyBranch::CheckForUnmodifiableField() |
|
211 //----------------------------------------------------------------------------- |
|
212 CSmlDmAdapter::TError CProxyBranch::CheckForUnmodifiableField(const TDesC8& aUri) |
|
213 { |
|
214 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_CHECKFORUNMODIFIABLEFIELD_ENTRY, |
|
215 "ENTRY: CProxyBranch::CheckForUnmodifiableField;aUri=%s", aUri ); |
|
216 |
|
217 CSmlDmAdapter::TError retval(CSmlDmAdapter::ENotFound); |
|
218 TPtrC8 nodeName = CUtils::GetLastURISeg(aUri); |
|
219 |
|
220 if ( nodeName.Match(KCMProxyDdfName) != KErrNotFound || |
|
221 nodeName.Match(KCMProxyDdfConRef) != KErrNotFound ) |
|
222 { |
|
223 retval = CSmlDmAdapter::EOk; |
|
224 } |
|
225 |
|
226 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_CHECKFORUNMODIFIABLEFIELD_EXIT, |
|
227 "EXIT: CProxyBranch::CheckForUnmodifiableField;retval=%{TError}", retval ); |
|
228 |
|
229 return retval; |
|
230 } |
|
231 //----------------------------------------------------------------------------- |
|
232 // TBool CProxyBranch::MapUriToCmAttribute() |
|
233 //----------------------------------------------------------------------------- |
|
234 TUint32 CProxyBranch::MapUriToCmAttribute( const TDesC8& aUri ) |
|
235 { |
|
236 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_MAPURITOCMATTRIBUTE_ENTRY, |
|
237 "ENTRY: CProxyBranch::MapUriToCmAttribute;aUri=%s", aUri ); |
|
238 |
|
239 TUint32 retval(0); |
|
240 |
|
241 TPtrC8 nodeName = CUtils::GetLastURISeg( aUri ); |
|
242 |
|
243 if ( nodeName.Match( KCMProxyDdfAddr )!= KErrNotFound ) |
|
244 { |
|
245 retval = CMManager::ECmProxyServerName; |
|
246 } |
|
247 else if ( nodeName.Match( KCMProxyDdfPortNbr ) != KErrNotFound ) |
|
248 { |
|
249 retval = CMManager::ECmProxyPortNumber; |
|
250 } |
|
251 else if ( nodeName.Match( KCMProxyDdfStartpg ) != KErrNotFound ) |
|
252 { |
|
253 retval = CMManager::ECmStartPage; |
|
254 } |
|
255 else if ( nodeName.Match( KCMProxyDdfProxyType ) != KErrNotFound ) |
|
256 { |
|
257 retval = CMManager::ECmProxyProtocolName; |
|
258 } |
|
259 |
|
260 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_MAPURITOCMATTRIBUTE_EXIT, |
|
261 "EXIT: CProxyBranch::MapUriToCmAttribute;retval=%{TConnectionMethodCommonAttributes}", |
|
262 retval ); |
|
263 |
|
264 return retval; |
|
265 } |
|
266 //----------------------------------------------------------------------------- |
|
267 // TInt32 CProxyBranch::FindConnectionMethodL() |
|
268 //----------------------------------------------------------------------------- |
|
269 TInt32 CProxyBranch::FindConnectionMethodL() |
|
270 { |
|
271 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_FINDCONNECTIONMETHODL_ENTRY, |
|
272 "ENTRY: CProxyBranch::FindConnectionMethod" ); |
|
273 |
|
274 TInt32 retval = KErrNotFound; |
|
275 |
|
276 CConnMoNodeElement* processNode = iBuffer->CacheFind( KProxyConrefUri ); |
|
277 |
|
278 if ( processNode ) |
|
279 { |
|
280 |
|
281 HBufC8* luid; |
|
282 |
|
283 // Ignore root part ("./") of the URI if present in the beginning |
|
284 if ( processNode->iObject.Mid( 0, 2 ).Match( KRoot ) != KErrNotFound ) |
|
285 { |
|
286 luid = iCallback->GetLuidAllocL( processNode->iObject.Mid( 2 ) ); |
|
287 } |
|
288 else |
|
289 { |
|
290 luid = iCallback->GetLuidAllocL( processNode->iObject ); |
|
291 } |
|
292 |
|
293 retval = CUtils::IntLUID( *luid ); |
|
294 |
|
295 delete luid; |
|
296 |
|
297 } |
|
298 |
|
299 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_FINDCONNECTIONMETHODL_EXIT, |
|
300 "EXIT: CProxyBranch::FindConnectionMethod;CmId=%d", retval ); |
|
301 |
|
302 return retval; |
|
303 } |
|
304 //----------------------------------------------------------------------------- |
|
305 // TBool CProxyBranch::AllMandatoryProxyFieldsFound() |
|
306 //----------------------------------------------------------------------------- |
|
307 TBool CProxyBranch::AllMandatoryProxyFieldsFound() |
|
308 { |
|
309 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_ALLMANDATORYPROXYFIELDSFOUND_ENTRY, |
|
310 "ENTRY: CProxyBranch::AllMandatoryProxyFieldsFound" ); |
|
311 |
|
312 TBool retval = ETrue; |
|
313 |
|
314 // Check that NAP Address addition is found |
|
315 if ( !iBuffer->CacheFind(KProxyAddrUri) ) |
|
316 { |
|
317 retval = EFalse; |
|
318 } |
|
319 if ( !iBuffer->CacheFind(KProxyConrefUri) ) |
|
320 { |
|
321 retval = EFalse; |
|
322 } |
|
323 // Check that dynamic nap node addition is found |
|
324 if ( !iBuffer->CacheFindDynamicNode(KDynamicProxyNodePattern) ) |
|
325 { |
|
326 retval = EFalse; |
|
327 } |
|
328 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_ALLMANDATORYPROXYFIELDSFOUND_EXIT, |
|
329 "EXIT: CProxyBranch::AllMandatoryProxyFieldsFound;retval=%d", retval ); |
|
330 |
|
331 return retval; |
|
332 } |
|
333 //----------------------------------------------------------------------------- |
|
334 // TBool CProxyBranch::SetLeafData() |
|
335 //----------------------------------------------------------------------------- |
|
336 void CProxyBranch::SetLeafDataL(const TDesC8& aURI, |
|
337 const TDesC8& /*aLUID*/, |
|
338 const TDesC8& aObject, |
|
339 TInt aStatusRef, |
|
340 RCmConnectionMethodExt& aCm) |
|
341 { |
|
342 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_SETLEAFDATAL_ENTRY, |
|
343 "ENTRY: CProxyBranch::SetLeafDataL;aURI=%s", aURI ); |
|
344 |
|
345 TUint32 attributeRef = ( 0 ); |
|
346 TLex8 lex( aObject ); |
|
347 TInt value = 0; |
|
348 CSmlDmAdapter::TError status = CSmlDmAdapter::EOk; |
|
349 |
|
350 attributeRef = MapUriToCmAttribute( aURI ); |
|
351 |
|
352 switch ( attributeRef ) |
|
353 { |
|
354 case CMManager::ECmProxyServerName: |
|
355 case CMManager::ECmStartPage: |
|
356 case CMManager::ECmProxyProtocolName: |
|
357 aCm.SetStringAttributeL( attributeRef, CUtils::ConvertTo16LC( aObject ) ); |
|
358 CleanupStack::PopAndDestroy(); // CUtils::ConvertTo16LC |
|
359 break; |
|
360 case CMManager::ECmProxyPortNumber: |
|
361 if ( lex.Val( value ) == KErrNone ) |
|
362 { |
|
363 aCm.SetIntAttributeL( attributeRef, value ); |
|
364 } |
|
365 else |
|
366 { |
|
367 status = CSmlDmAdapter::EInvalidObject; |
|
368 } |
|
369 break; |
|
370 default: |
|
371 status = CheckForUnmodifiableField( aURI ); |
|
372 break; |
|
373 } |
|
374 iCallback->SetStatusL( aStatusRef, status ); |
|
375 |
|
376 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_SETLEAFDATAL_EXIT, |
|
377 "EXIT: CProxyBranch::SetLeafDataL;status=%{TError}", status ); |
|
378 } |
|
379 //----------------------------------------------------------------------------- |
|
380 // TBool CProxyBranch::SetNodeData() |
|
381 //----------------------------------------------------------------------------- |
|
382 void CProxyBranch::SetNodeDataL(CConnMoNodeElement* aNode, RCmConnectionMethodExt& aCm) |
|
383 { |
|
384 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_SETNODEDATAL_ENTRY, "ENTRY: CProxyBranch::SetNodeDataL;aNode->iUri=%s", aNode->iUri ); |
|
385 |
|
386 if ( aNode->iParentLUID.Length() == 0 ) |
|
387 { |
|
388 TBuf8<16> addLUID; |
|
389 _LIT8( KFormat, "%d" ); |
|
390 addLUID.Format( KFormat, aCm.GetIntAttributeL( CMManager::ECmId ) ); |
|
391 |
|
392 iCallback->SetMappingL( aNode->iUri, addLUID ); |
|
393 iCallback->SetStatusL( aNode->iStatusRef, CSmlDmAdapter::EOk ); |
|
394 } |
|
395 else |
|
396 { |
|
397 iCallback->SetStatusL( aNode->iStatusRef, CSmlDmAdapter::EAlreadyExists ); |
|
398 } |
|
399 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_SETNODEDATAL_EXIT, "EXIT: CProxyBranch::SetNodeDataL" ); |
|
400 |
|
401 } |
|
402 //------------------------------------------------------------------------------ |
|
403 // void CProxyBranch::GetAllDynamicProxyNodes() |
|
404 //------------------------------------------------------------------------------ |
|
405 void CProxyBranch::GetAllDynamicProxyNodesL( const TDesC8& aURI, |
|
406 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
407 TInt aResultsRef, |
|
408 TInt aStatusRef, |
|
409 CBufBase& aCurrentURISegmentList ) |
|
410 { |
|
411 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_GETALLDYNAMICPROXYNODESL_ENTRY, |
|
412 "ENTRY: CProxyBranch::GetAllDynamicProxyNodesL;aURI=%s", aURI ); |
|
413 |
|
414 // Array for connection methods |
|
415 RArray <TUint32> cmArray; |
|
416 |
|
417 CleanupClosePushL( cmArray ); |
|
418 cmArray.Reset(); |
|
419 |
|
420 GetAllConnectionMethodsL( cmArray, *iCmManager ); |
|
421 |
|
422 // Loop through all connection methods |
|
423 for ( TInt i = 0; i < cmArray.Count(); i++ ) |
|
424 { |
|
425 RCmConnectionMethodExt cm = iCmManager->ConnectionMethodL( cmArray[i] ); |
|
426 CleanupClosePushL( cm ); |
|
427 |
|
428 // If proxy is enabled for connection method |
|
429 if ( cm.GetBoolAttributeL( CMManager::ECmProxyUsageEnabled ) ) |
|
430 { |
|
431 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_GETALLDYNAMICPROXYNODESL_PROXY, |
|
432 "CProxyBranch::GetAllDynamicProxyNodesL;Proxy enabled for Cm Id=%u", |
|
433 cmArray[i] ); |
|
434 |
|
435 TBuf8<KSmlMaxURISegLen>addCmName; |
|
436 // Check if node exists in aPreviousURISegmentList |
|
437 if ( !CheckPreviousURIList( aPreviousURISegmentList, cmArray[i], addCmName ) ) |
|
438 { |
|
439 // Connection Method not found in previous URI list |
|
440 addCmName.Append( aURI ); |
|
441 addCmName.Append( KCMProxyNodeSeparator ); |
|
442 addCmName.Append( KDynamicNodePrefix ); |
|
443 |
|
444 addCmName.AppendNumFixedWidth( cmArray[i], EDecimal, 3); |
|
445 |
|
446 TBuf8<16> addLUID; |
|
447 _LIT8( KFormat, "%d" ); |
|
448 addLUID.Format( KFormat, cmArray[i] ); |
|
449 |
|
450 OstTraceExt1( TRACE_NORMAL, |
|
451 CPROXYBRANCH_GETALLDYNAMICPROXYNODES_ADDED_TO_LIST, |
|
452 "CProxyBranch::GetAllDynamicProxyNodesL;Added to list: URI=%s", addCmName ); |
|
453 |
|
454 iCallback->SetMappingL( addCmName, addLUID ); |
|
455 } |
|
456 aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(), CUtils::GetLastURISeg( addCmName ) ); |
|
457 aCurrentURISegmentList.InsertL( aCurrentURISegmentList.Size(), KCMProxyNodeSeparator ); |
|
458 } |
|
459 CleanupStack::PopAndDestroy( &cm ); |
|
460 } |
|
461 |
|
462 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
463 iCallback->SetResultsL( aResultsRef, aCurrentURISegmentList, KNullDesC8 ); |
|
464 |
|
465 CleanupStack::PopAndDestroy( &cmArray ); |
|
466 |
|
467 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_GETALLDYNAMICPROXYNODESL_EXIT, |
|
468 "EXI: CProxyBranch::GetAllDynamicProxyNodesLT" ); |
|
469 } |
|
470 |
|
471 // ======== MEMBER FUNCTIONS ======== |
|
472 //----------------------------------------------------------------------------- |
|
473 // CProxyBranch* CProxyBranch::NewL( ) |
|
474 //----------------------------------------------------------------------------- |
|
475 CProxyBranch* CProxyBranch::NewL(MSmlDmCallback* aDmCallback, |
|
476 CAddBuffer* aBuffer, |
|
477 RCmManagerExt* aCmManagerExt ) |
|
478 { |
|
479 OstTraceFunctionEntry1( CPROXYBRANCH_NEWL_ENTRY, ( TUint )( aDmCallback ) ); |
|
480 |
|
481 CProxyBranch* self = new (ELeave) CProxyBranch(aDmCallback, aBuffer, aCmManagerExt ); |
|
482 |
|
483 OstTraceFunctionExit1( CPROXYBRANCH_NEWL_EXIT, ( TUint )( self ) ); |
|
484 return self; |
|
485 } |
|
486 |
|
487 //------------------------------------------------------------------------------ |
|
488 // CProxyBranch::CProxyBranch() |
|
489 //------------------------------------------------------------------------------ |
|
490 CProxyBranch::CProxyBranch(MSmlDmCallback* aDmCallback, |
|
491 CAddBuffer* aBuffer, |
|
492 RCmManagerExt* aCmManagerExt ) |
|
493 : CBranchBase( aDmCallback ) |
|
494 { |
|
495 OstTraceFunctionEntry1( CPROXYBRANCH_CONSTRUCTOR_ENTRY, this ); |
|
496 |
|
497 iCallback = aDmCallback; |
|
498 iBuffer = aBuffer; |
|
499 iCmManager = aCmManagerExt; |
|
500 |
|
501 OstTraceFunctionExit1( CPROXYBRANCH_CONSTRUCTOR_EXIT, this ); |
|
502 } |
|
503 |
|
504 //------------------------------------------------------------------------------ |
|
505 // CProxyBranch::~CProxyBranch() |
|
506 //------------------------------------------------------------------------------ |
|
507 CProxyBranch::~CProxyBranch() |
|
508 { |
|
509 OstTraceFunctionEntry1( CPROXYBRANCH_DESTRUCTOR_ENTRY, this ); |
|
510 |
|
511 OstTraceFunctionExit1( CPROXYBRANCH_DESTRUCTOR_EXIT, this ); |
|
512 } |
|
513 |
|
514 //------------------------------------------------------------------------------ |
|
515 // void CProxyBranch::DDFStructureL() |
|
516 //------------------------------------------------------------------------------ |
|
517 void CProxyBranch::DDFStructureL( MSmlDmDDFObject& aDDF ) |
|
518 { |
|
519 OstTraceFunctionEntry0( CPROXYBRANCH_DDFSTRUCTUREL_ENTRY ); |
|
520 |
|
521 // |
|
522 // Set rest acceptable operations for data itself |
|
523 // |
|
524 TSmlDmAccessTypes aclTypesNoDelete; |
|
525 aclTypesNoDelete.SetGet(); |
|
526 aclTypesNoDelete.SetReplace(); |
|
527 aclTypesNoDelete.SetAdd(); |
|
528 |
|
529 TSmlDmAccessTypes aclTypesAddGet; |
|
530 aclTypesAddGet.SetGet(); |
|
531 aclTypesAddGet.SetAdd(); |
|
532 |
|
533 TSmlDmAccessTypes aclTypesOnlyGet; |
|
534 aclTypesOnlyGet.SetGet(); |
|
535 |
|
536 MSmlDmDDFObject& nProxyIdDDF = aDDF.AddChildObjectL( KCMProxyDdfProxyId ); // ProxyId |
|
537 CUtils::FillNodeInfoL( nProxyIdDDF, |
|
538 aclTypesOnlyGet, |
|
539 MSmlDmDDFObject::EOne, |
|
540 MSmlDmDDFObject::EDynamic, |
|
541 MSmlDmDDFObject::EChr, |
|
542 KNullDesC8 ); |
|
543 |
|
544 MSmlDmDDFObject& nAddrDDF = aDDF.AddChildObjectL( KCMProxyDdfAddr ); // Addr |
|
545 CUtils::FillNodeInfoL( nAddrDDF, |
|
546 aclTypesNoDelete, |
|
547 MSmlDmDDFObject::EOne, |
|
548 MSmlDmDDFObject::EDynamic, |
|
549 MSmlDmDDFObject::EChr, |
|
550 KNullDesC8 ); |
|
551 |
|
552 MSmlDmDDFObject& nToConRefDDF = aDDF.AddChildObjectL( KCMProxyDdfToConRef ); // ToConRef |
|
553 CUtils::FillNodeInfoL( nToConRefDDF, |
|
554 aclTypesNoDelete, |
|
555 MSmlDmDDFObject::EZeroOrOne, |
|
556 MSmlDmDDFObject::EDynamic, |
|
557 MSmlDmDDFObject::ENode, |
|
558 KNullDesC8 ); |
|
559 |
|
560 MSmlDmDDFObject& nToConRefRootDDF = nToConRefDDF.AddChildObjectGroupL(); // ToConRef/<x> |
|
561 CUtils::FillNodeInfoL( nToConRefRootDDF, |
|
562 aclTypesNoDelete, |
|
563 MSmlDmDDFObject::EOneOrMore, |
|
564 MSmlDmDDFObject::EDynamic, |
|
565 MSmlDmDDFObject::ENode, |
|
566 KNullDesC8 ); |
|
567 |
|
568 MSmlDmDDFObject& nConRefDDF = nToConRefRootDDF.AddChildObjectL( KCMProxyDdfConRef ); // ToConRef/<x>/ConRef |
|
569 CUtils::FillNodeInfoL( nConRefDDF, |
|
570 aclTypesAddGet, |
|
571 MSmlDmDDFObject::EOne, |
|
572 MSmlDmDDFObject::EDynamic, |
|
573 MSmlDmDDFObject::EChr, |
|
574 KNullDesC8 ); |
|
575 |
|
576 MSmlDmDDFObject& nPortsDDF = aDDF.AddChildObjectL( KCMProxyDdfPorts ); // Ports |
|
577 CUtils::FillNodeInfoL( nPortsDDF, |
|
578 aclTypesNoDelete, |
|
579 MSmlDmDDFObject::EZeroOrOne, |
|
580 MSmlDmDDFObject::EDynamic, |
|
581 MSmlDmDDFObject::ENode, |
|
582 KNullDesC8 ); |
|
583 |
|
584 MSmlDmDDFObject& nPortsRootDDF = nPortsDDF.AddChildObjectGroupL(); // Ports/<x> |
|
585 CUtils::FillNodeInfoL( nPortsRootDDF, |
|
586 aclTypesNoDelete, |
|
587 MSmlDmDDFObject::EOneOrMore, |
|
588 MSmlDmDDFObject::EDynamic, |
|
589 MSmlDmDDFObject::ENode, |
|
590 KNullDesC8 ); |
|
591 |
|
592 MSmlDmDDFObject& nPortNbrDDF = nPortsRootDDF.AddChildObjectL( KCMProxyDdfPortNbr ); // Ports/<x>/PortNbr |
|
593 CUtils::FillNodeInfoL( nPortNbrDDF, |
|
594 aclTypesNoDelete, |
|
595 MSmlDmDDFObject::EOne, |
|
596 MSmlDmDDFObject::EDynamic, |
|
597 MSmlDmDDFObject::EInt, |
|
598 KNullDesC8 ); |
|
599 |
|
600 MSmlDmDDFObject& nProxyParamsDDF = aDDF.AddChildObjectL( KCMProxyDdfProxyParams ); // ProxyParams |
|
601 CUtils::FillNodeInfoL( nProxyParamsDDF, |
|
602 aclTypesNoDelete, |
|
603 MSmlDmDDFObject::EZeroOrOne, |
|
604 MSmlDmDDFObject::EDynamic, |
|
605 MSmlDmDDFObject::ENode, |
|
606 KNullDesC8 ); |
|
607 |
|
608 MSmlDmDDFObject& nProxyTypeDDF = aDDF.AddChildObjectL( KCMProxyDdfProxyType ); // ProxyType |
|
609 CUtils::FillNodeInfoL( nProxyTypeDDF, |
|
610 aclTypesNoDelete, |
|
611 MSmlDmDDFObject::EZeroOrOne, |
|
612 MSmlDmDDFObject::EDynamic, |
|
613 MSmlDmDDFObject::EChr, |
|
614 KNullDesC8 ); |
|
615 |
|
616 |
|
617 MSmlDmDDFObject& nWapDDF = nProxyParamsDDF.AddChildObjectL( KCMProxyDdfWap ); // WAP |
|
618 CUtils::FillNodeInfoL( nWapDDF, |
|
619 aclTypesNoDelete, |
|
620 MSmlDmDDFObject::EZeroOrOne, |
|
621 MSmlDmDDFObject::EDynamic, |
|
622 MSmlDmDDFObject::ENode, |
|
623 KNullDesC8 ); |
|
624 |
|
625 MSmlDmDDFObject& nStartpgDDF = nWapDDF.AddChildObjectL( KCMProxyDdfStartpg ); // Startpg |
|
626 CUtils::FillNodeInfoL( nStartpgDDF, |
|
627 aclTypesNoDelete, |
|
628 MSmlDmDDFObject::EZeroOrOne, |
|
629 MSmlDmDDFObject::EDynamic, |
|
630 MSmlDmDDFObject::EChr, |
|
631 KNullDesC8 ); |
|
632 |
|
633 OstTraceFunctionEntry0( CPROXYBRANCH_DDFSTRUCTUREL_EXIT ); |
|
634 } |
|
635 |
|
636 //------------------------------------------------------------------------------ |
|
637 // void CProxyBranch::UpdateLeafObjectL() |
|
638 //------------------------------------------------------------------------------ |
|
639 void CProxyBranch::UpdateLeafObjectL( const TDesC8& aURI, |
|
640 const TDesC8& aLUID, |
|
641 const TDesC8& aObject, |
|
642 const TDesC8& /*aType*/, |
|
643 TInt aStatusRef ) |
|
644 { |
|
645 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_UPDATELEAFOBJECTL_ENTRY, |
|
646 "ENTRY: CProxyBranch::UpdateLeafObjectL;aURI=%s", aURI ); |
|
647 |
|
648 // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx) |
|
649 TInt cmId = GetCmIdFromURIL( aURI ); |
|
650 |
|
651 if ( aLUID.Length() == 0 && cmId == KErrNotFound ) |
|
652 { |
|
653 // New node, add to buffer |
|
654 iBuffer->AddNodeToBufferL( aURI, aLUID, aObject, aStatusRef); |
|
655 } |
|
656 else |
|
657 { |
|
658 // Existing node, update data immediately |
|
659 TInt err( KErrNone ); |
|
660 RCmConnectionMethodExt cm; |
|
661 if ( cmId == KErrNotFound ) |
|
662 { |
|
663 cmId = CUtils::IntLUID( aLUID ); |
|
664 } |
|
665 |
|
666 TRAP( err, cm = iCmManager->ConnectionMethodL( cmId ) ); |
|
667 CleanupClosePushL( cm ); |
|
668 |
|
669 if ( !err ) |
|
670 { |
|
671 OstTrace0( TRACE_NORMAL, DUP1_CPROXYBRANCH_UPDATELEAFOBJECTL, "CProxyBranch::UpdateLeafObjectL; Existing connection method - write value immediately." ); |
|
672 SetLeafDataL( aURI, aLUID, aObject, aStatusRef, cm ); |
|
673 cm.UpdateL(); |
|
674 } |
|
675 else |
|
676 { |
|
677 //iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
678 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_UPDATELEAFOBJECTL, "CProxyBranch::UpdateLeafObjectL; Stale LUID - buffer setting." ); |
|
679 iBuffer->AddNodeToBufferL(aURI,KNullDesC8,aObject,aStatusRef); |
|
680 } |
|
681 |
|
682 CleanupStack::PopAndDestroy( &cm ); |
|
683 } |
|
684 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_UPDATELEAFOBJECTL_EXIT, |
|
685 "EXIT: CProxyBranch::UpdateLeafObjectL" ); |
|
686 |
|
687 } |
|
688 |
|
689 //------------------------------------------------------------------------------ |
|
690 // void CProxyBranch::DeleteObjectL() |
|
691 //------------------------------------------------------------------------------ |
|
692 void CProxyBranch::DeleteObjectL( const TDesC8& /*aURI*/, |
|
693 const TDesC8& /*aLUID*/, |
|
694 TInt /*aStatusRef*/ ) |
|
695 { |
|
696 |
|
697 } |
|
698 |
|
699 //------------------------------------------------------------------------------ |
|
700 // void CProxyBranch::FetchLeafObjectL() |
|
701 //------------------------------------------------------------------------------ |
|
702 void CProxyBranch::FetchLeafObjectL( const TDesC8& aURI, |
|
703 const TDesC8& aLUID, |
|
704 const TDesC8& aType, |
|
705 TInt aResultsRef, |
|
706 TInt aStatusRef ) |
|
707 { |
|
708 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECTL_PUPLIC_ENTRY, |
|
709 "ENTRY: CProxyBranch::FetchLeafObjectL;aURI=%s", aURI ); |
|
710 |
|
711 CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound; |
|
712 |
|
713 CBufBase *leafObject = CBufFlat::NewL( KBufferExpandSize ); |
|
714 CleanupStack::PushL( leafObject ); |
|
715 leafObject->Reset(); |
|
716 |
|
717 status = FetchLeafObjectL( aURI, aLUID, *leafObject ); |
|
718 |
|
719 if ( status == CSmlDmAdapter::EOk ) |
|
720 { |
|
721 iCallback->SetResultsL( aResultsRef, *leafObject, aType ); |
|
722 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECT_OK, |
|
723 "CProxyBranch::FetchLeafObjectL; EOk" ); |
|
724 } |
|
725 |
|
726 CleanupStack::PopAndDestroy( leafObject ); |
|
727 |
|
728 iCallback->SetStatusL( aStatusRef, status ); |
|
729 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECTL_PUPLIC_EXIT, |
|
730 "EXIT: CProxyBranch::FetchLeafObjectL;status=%{TError}", status ); |
|
731 |
|
732 } |
|
733 |
|
734 //------------------------------------------------------------------------------ |
|
735 // void CProxyBranch::FetchLeafObjectSizeL() |
|
736 //------------------------------------------------------------------------------ |
|
737 void CProxyBranch::FetchLeafObjectSizeL( const TDesC8& aURI, |
|
738 const TDesC8& aLUID, |
|
739 const TDesC8& aType, |
|
740 TInt aResultsRef, |
|
741 TInt aStatusRef ) |
|
742 { |
|
743 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECTSIZEL_ENTRY, |
|
744 "ENTRY: CProxyBranch::FetchLeafObjectSizeL;aURI=%s", aURI ); |
|
745 |
|
746 CSmlDmAdapter::TError status = CSmlDmAdapter::ENotFound; |
|
747 |
|
748 CBufBase *leafObject = CBufFlat::NewL( KSmlMaxURISegLen ); |
|
749 CleanupStack::PushL( leafObject ); |
|
750 leafObject->Reset(); |
|
751 |
|
752 status = FetchLeafObjectL( aURI, aLUID, *leafObject ); |
|
753 |
|
754 if ( status == CSmlDmAdapter::EOk ) |
|
755 { |
|
756 leafObject->Compress(); |
|
757 TBuf8<8> size; |
|
758 size.Num( leafObject->Size() ); |
|
759 leafObject->Reset(); |
|
760 leafObject->InsertL(0, size ); |
|
761 iCallback->SetResultsL( aResultsRef, *leafObject, aType ); |
|
762 } |
|
763 |
|
764 CleanupStack::PopAndDestroy( leafObject ); |
|
765 |
|
766 iCallback->SetStatusL( aStatusRef, status ); |
|
767 OstTrace1( TRACE_NORMAL, CPROXYBRANCH_FETCHLEAFOBJECTSIZEL_EXIT, |
|
768 "EXIT: CProxyBranch::FetchLeafObjectSizeL;status=%{TError}", status ); |
|
769 |
|
770 } |
|
771 |
|
772 //------------------------------------------------------------------------------ |
|
773 // void CProxyBranch::ChildURIListL() |
|
774 //------------------------------------------------------------------------------ |
|
775 void CProxyBranch::ChildURIListL( const TDesC8& aURI, |
|
776 const TDesC8& aLUID, |
|
777 const CArrayFix<TSmlDmMappingInfo>& aPreviousURISegmentList, |
|
778 TInt aResultsRef, |
|
779 TInt aStatusRef ) |
|
780 { |
|
781 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_CHILDURILISTL_ENTRY, |
|
782 "ENTRY: CProxyBranch::ChildURIListL;aURI=%s", aURI ); |
|
783 |
|
784 TPtrC8 proxyDdfTree = CUtils::GetEndOfURIFromSeg( aURI, KCMProxyDdf ); |
|
785 |
|
786 CBufBase* currentURISegmentList = CBufFlat::NewL( KSmlMaxURISegLen ); |
|
787 CleanupStack::PushL( currentURISegmentList ); |
|
788 |
|
789 // Proxy (handle as special case) |
|
790 if ( proxyDdfTree.Match( KCMProxyDdf ) != KErrNotFound ) |
|
791 { |
|
792 GetAllDynamicProxyNodesL( aURI, |
|
793 aPreviousURISegmentList, |
|
794 aResultsRef, |
|
795 aStatusRef, |
|
796 *currentURISegmentList ); |
|
797 CleanupStack::PopAndDestroy( currentURISegmentList ); |
|
798 return; |
|
799 } |
|
800 // Then check if the CM exists. Use LUID or predefined ID |
|
801 TInt cmId( KErrNotFound ); |
|
802 if ( aLUID.Length() > 0 ) |
|
803 { |
|
804 cmId = CUtils::IntLUID( aLUID ); |
|
805 } |
|
806 else |
|
807 { |
|
808 // If this is for pre-defined node then get CM id xxx from URI (NAP/NAPIdxxx) |
|
809 cmId = GetCmIdFromURIL( aURI ); |
|
810 } |
|
811 // If after this cmId is still not found then the branch does not exist |
|
812 if ( cmId == KErrNotFound ) |
|
813 { |
|
814 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
815 CleanupStack::PopAndDestroy( currentURISegmentList ); |
|
816 OstTrace0( TRACE_NORMAL, DUP1_CPROXYBRANCH_CHILDURILISTL, "CNapBranch::ChildURIListL; CSmlDmAdapter::ENotFound" ); |
|
817 return; |
|
818 } |
|
819 |
|
820 RCmConnectionMethodExt cm; |
|
821 // Check it the method actually can be found |
|
822 if ( !GetConnectionMethodLC( *iCmManager, cm, cmId ) || !cm.GetBoolAttributeL(CMManager::ECmProxyUsageEnabled ) ) |
|
823 { |
|
824 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
825 CleanupStack::PopAndDestroy( &cm ); |
|
826 CleanupStack::PopAndDestroy( currentURISegmentList ); |
|
827 OstTrace0( TRACE_NORMAL, DUP2_CPROXYBRANCH_CHILDURILISTL, "CNapBranch::ChildURIListL; CSmlDmAdapter::ENotFound" ); |
|
828 return; |
|
829 } |
|
830 CleanupStack::PopAndDestroy( &cm ); |
|
831 |
|
832 |
|
833 // Proxy/<x> |
|
834 if ( proxyDdfTree.Match( KDynamicProxyNodePattern ) != KErrNotFound && |
|
835 proxyDdfTree.Match( KDynamicProxyNodeChildUri ) == KErrNotFound ) |
|
836 { |
|
837 currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMProxyFields ); |
|
838 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
839 iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
840 } |
|
841 |
|
842 // Proxy/<x>/ToConRef/<x> |
|
843 else if ( proxyDdfTree.Match( KDynamicToConrefNodeChildUri ) != KErrNotFound && |
|
844 proxyDdfTree.Match( KDynamicToConrefNodeChildUriNodes ) == KErrNotFound ) |
|
845 { |
|
846 currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMProxyDdfConRef ); |
|
847 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
848 iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
849 } |
|
850 |
|
851 // Proxy/<x>/ToConRef |
|
852 else if ( proxyDdfTree.Match( KDynamicToConrefNode ) != KErrNotFound ) |
|
853 { |
|
854 GetAllDynamicNodesL( aURI, |
|
855 aLUID, |
|
856 aPreviousURISegmentList, |
|
857 aResultsRef, |
|
858 aStatusRef, |
|
859 *iCmManager, |
|
860 *currentURISegmentList, |
|
861 KCMProxyDdfToConRef, |
|
862 1, |
|
863 iCallback ); |
|
864 } |
|
865 |
|
866 // Proxy/<x>/Ports/<x> |
|
867 else if ( proxyDdfTree.Match( KDynamicPortsNodeChildUri ) != KErrNotFound && |
|
868 proxyDdfTree.Match( KDynamicPortsNodeChildUriNodes ) == KErrNotFound ) |
|
869 { |
|
870 currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMProxyDdfPortNbr ); |
|
871 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
872 iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
873 } |
|
874 |
|
875 // Proxy/<x>/Ports |
|
876 else if ( proxyDdfTree.Match( KDynamicPortsNode ) != KErrNotFound ) |
|
877 { |
|
878 GetAllDynamicNodesL( aURI, |
|
879 aLUID, |
|
880 aPreviousURISegmentList, |
|
881 aResultsRef, |
|
882 aStatusRef, |
|
883 *iCmManager, |
|
884 *currentURISegmentList, |
|
885 KCMProxyDdfPorts, |
|
886 1, |
|
887 iCallback ); |
|
888 } |
|
889 |
|
890 // Proxy/<x>/ProxyParams |
|
891 else if ( proxyDdfTree.Match( KDynamicProxyParamsNode ) != KErrNotFound && |
|
892 proxyDdfTree.Match( KDynamicProxyParamsNodeChildUri ) == KErrNotFound ) |
|
893 { |
|
894 currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMProxyParamsFields ); |
|
895 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
896 iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
897 } |
|
898 |
|
899 // Proxy/<x>/ProxyParams/WAP |
|
900 else if ( proxyDdfTree.Match( KDynamicProxyParamsWapNode ) != KErrNotFound ) |
|
901 { |
|
902 currentURISegmentList->InsertL( currentURISegmentList->Size(), KCMProxyWapFields ); |
|
903 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EOk ); |
|
904 iCallback->SetResultsL( aResultsRef, *currentURISegmentList, KNullDesC8 ); |
|
905 } |
|
906 |
|
907 // Not found |
|
908 else |
|
909 { |
|
910 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::ENotFound ); |
|
911 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_CHILDURILISTL_NOT_FOUND, |
|
912 "CProxyBranch::ChildURIListL;CSmlDmAdapter::ENotFound" ); |
|
913 |
|
914 } |
|
915 |
|
916 CleanupStack::PopAndDestroy( currentURISegmentList ); |
|
917 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_CHILDURILISTL_EXIT, |
|
918 "EXIT: CProxyBranch::ChildURIListL" ); |
|
919 |
|
920 } |
|
921 |
|
922 //------------------------------------------------------------------------------ |
|
923 // void CProxyBranch::AddNodeObjectL() |
|
924 //------------------------------------------------------------------------------ |
|
925 void CProxyBranch::AddNodeObjectL( const TDesC8& aURI, |
|
926 const TDesC8& aParentLUID, |
|
927 TInt aStatusRef ) |
|
928 { |
|
929 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_ADDNODEOBJECTL_ENTRY, |
|
930 "ENTRY: CProxyBranch::AddNodeObjectL;aURI=%s", aURI ); |
|
931 |
|
932 if ( aParentLUID.Length() == 0 ) |
|
933 { |
|
934 // If this is for pre-defined node then get CM id xxx from URI (Proxy/ProxyIdxxx) |
|
935 TInt cmId = GetCmIdFromURIL( aURI ); |
|
936 RCmConnectionMethodExt cm; |
|
937 // Check if CM exists |
|
938 if ( cmId != KErrNotFound && GetConnectionMethodLC( *iCmManager, cm, cmId ) |
|
939 && cm.GetBoolAttributeL(CMManager::ECmProxyUsageEnabled)) |
|
940 { |
|
941 CleanupStack::PopAndDestroy( &cm ); |
|
942 // Pre-defined CM already exists for this ID. |
|
943 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EAlreadyExists ); |
|
944 return; |
|
945 } |
|
946 if ( cmId != KErrNotFound ) |
|
947 { |
|
948 CleanupStack::PopAndDestroy( &cm ); |
|
949 } |
|
950 // New node, add to buffer |
|
951 iBuffer->AddNodeToBufferL( aURI, aParentLUID, aStatusRef ); |
|
952 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_ADDNODEOBJECTL_NEW_NODE, |
|
953 "CProxyBranch::AddNodeObjectL;New node -> Add to buffer." ); |
|
954 } |
|
955 else |
|
956 { |
|
957 // Sanity check: If the dynamic name of the Proxy node has is the same as deleted previously and |
|
958 // DM Framework hasn't updated the tree, it will give the LUID when calling this method. Thus, |
|
959 // it's needed to check that the connection method really exists. |
|
960 RCmConnectionMethodExt cm; |
|
961 |
|
962 |
|
963 if ( !GetConnectionMethodLC( *iCmManager, cm, CUtils::IntLUID( aParentLUID ) ) ) |
|
964 { |
|
965 // New node, add to buffer |
|
966 iBuffer->AddNodeToBufferL( aURI, KNullDesC8, aStatusRef ); |
|
967 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_ADDNODEOBJECTL_NEW_NODE2, |
|
968 "CProxyBranch::AddNodeObjectL;New node -> Add to buffer." ); |
|
969 } |
|
970 else |
|
971 { |
|
972 // Proxies must be added in one message. If luid is given add is done to existing AP or node |
|
973 iCallback->SetStatusL( aStatusRef, CSmlDmAdapter::EAlreadyExists ); |
|
974 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_ADDNODEOBJECTL_ALREADY_EXISTS, |
|
975 "CProxyBranch::AddNodeObjectL;CSmlDmAdapter::EAlreadyExists" ); |
|
976 } |
|
977 |
|
978 CleanupStack::PopAndDestroy( &cm ); |
|
979 } |
|
980 |
|
981 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_ADDNODEOBJECTL_EXIT, "EXIT: CProxyBranch::AddNodeObjectL" ); |
|
982 } |
|
983 |
|
984 // ------------------------------------------------------------------------------------- |
|
985 // CProxyBranch::ProcessNodeBufferL() |
|
986 // ------------------------------------------------------------------------------------- |
|
987 void CProxyBranch::ProcessBufferL() |
|
988 { |
|
989 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_PROCESSBUFFERL_ENTRY, "ENTRY: CProxyBranch::ProcessBufferL" ); |
|
990 |
|
991 RPointerArray<CConnMoNodeElement> proxyNodes( KNumOfProxyNodes ); |
|
992 CleanupClosePushL( proxyNodes ); |
|
993 while ( iBuffer->GetGroup( KCMDdfProxy, &proxyNodes ) != KErrNotFound ) |
|
994 { |
|
995 TInt32 cmId = FindConnectionMethodL(); |
|
996 |
|
997 if ( AllMandatoryProxyFieldsFound() && cmId != KErrNotFound ) |
|
998 { |
|
999 // Open connection method, enable proxy and update nodes |
|
1000 RCmConnectionMethodExt cm; |
|
1001 TRAPD( err, cm = iCmManager->ConnectionMethodL( cmId ) ); |
|
1002 CleanupClosePushL( cm ); |
|
1003 |
|
1004 if ( !err ) |
|
1005 { |
|
1006 cm.SetBoolAttributeL( CMManager::ECmProxyUsageEnabled, ETrue ); |
|
1007 |
|
1008 for ( TInt i = 0; i < proxyNodes.Count(); ++i ) |
|
1009 { |
|
1010 if ( proxyNodes[i]->iLeaf ) |
|
1011 { |
|
1012 // Leaf data found |
|
1013 SetLeafDataL( proxyNodes[i]->iUri, |
|
1014 proxyNodes[i]->iParentLUID, |
|
1015 proxyNodes[i]->iObject, |
|
1016 proxyNodes[i]->iStatusRef, cm ); |
|
1017 proxyNodes[i]->iProcessed = ETrue; |
|
1018 } |
|
1019 else |
|
1020 { |
|
1021 // Node has no leaf data |
|
1022 SetNodeDataL( proxyNodes[i], cm ); |
|
1023 proxyNodes[i]->iProcessed = ETrue; |
|
1024 } |
|
1025 } |
|
1026 cm.UpdateL(); |
|
1027 } |
|
1028 else |
|
1029 { |
|
1030 for ( TInt i = 0; i < proxyNodes.Count(); ++i ) |
|
1031 { |
|
1032 iCallback->SetStatusL( proxyNodes[i]->iStatusRef, CSmlDmAdapter::EError ); |
|
1033 proxyNodes[i]->iProcessed = ETrue; |
|
1034 } |
|
1035 } |
|
1036 CleanupStack::PopAndDestroy( &cm ); |
|
1037 } |
|
1038 else |
|
1039 { |
|
1040 for ( TInt i = 0; i < proxyNodes.Count(); ++i ) |
|
1041 { |
|
1042 iCallback->SetStatusL( proxyNodes[i]->iStatusRef, CSmlDmAdapter::EError ); |
|
1043 proxyNodes[i]->iProcessed = ETrue; |
|
1044 } |
|
1045 } |
|
1046 proxyNodes.Reset(); |
|
1047 } |
|
1048 CleanupStack::Pop( &proxyNodes ); |
|
1049 proxyNodes.Close(); |
|
1050 |
|
1051 OstTrace0( TRACE_NORMAL, CPROXYBRANCH_PROCESSBUFFERL_EXIT, "EXIT: CProxyBranch::ProcessBufferL" ); |
|
1052 } |
|
1053 |
|
1054 |
|
1055 //------------------------------------------------------------------------------ |
|
1056 // TPtrC8 CUtils::GetDynamicAPNodeUri( const TDesC8& aURI ) |
|
1057 // returns NAP/xxx URI |
|
1058 //------------------------------------------------------------------------------ |
|
1059 TPtrC8 CProxyBranch::GetDynamicProxyNodeUri( const TDesC8& aURI ) |
|
1060 { |
|
1061 OstTraceExt1( TRACE_NORMAL, CPROXYBRANCH_GETDYNAMICPROXYNODEURI, "CProxyBranch::GetDynamicProxyNodeUri;aURI=%s", aURI ); |
|
1062 TInt i= 0; |
|
1063 for ( i = aURI.Find( KCMDdfProxy ) + 6; i < aURI.Length(); i++ ) |
|
1064 { |
|
1065 if( aURI[i] == '/' ) |
|
1066 { |
|
1067 break; |
|
1068 } |
|
1069 } |
|
1070 OstTraceExt1( TRACE_NORMAL, DUP1_CPROXYRANCH_GETDYNAMICPROXYNODEURI, "CProxyBranch::GetDynamicProxyNodeUri;return URI=%s", aURI.Left( i ) ); |
|
1071 return aURI.Left( i ); |
|
1072 } |
|
1073 |
|
1074 //-------------------------------------------------------------------- |
|
1075 //TInt CProxyBranch::IsNAPUriFormatMatchPredefined(const TDesC8 & aURI) |
|
1076 // |
|
1077 //------------------------------------------------------------------- |
|
1078 |
|
1079 |
|
1080 TBool CProxyBranch::IsProxyUriFormatMatchPredefined(const TDesC8 & aURI) |
|
1081 { |
|
1082 if( aURI.Match( _L8( "Proxy/ProxyId*" ) ) != KErrNotFound ) |
|
1083 { |
|
1084 return ETrue; |
|
1085 } |
|
1086 else |
|
1087 { |
|
1088 return EFalse; |
|
1089 } |
|
1090 } |
|
1091 //------------------------------------------------------------------------------ |
|
1092 // TUint32 CProxyBranch::GetAPIdFromURIL(const TDesC8& aURI) |
|
1093 // Get NAP id for given aURI |
|
1094 //------------------------------------------------------------------------------ |
|
1095 TInt CProxyBranch::GetCmIdFromURIL(const TDesC8& aURI) |
|
1096 { |
|
1097 TInt ret(KErrNotFound); |
|
1098 |
|
1099 if( !IsProxyUriFormatMatchPredefined( aURI ) ) |
|
1100 { |
|
1101 // Cannot get CmIds from any other format URIs than predefined |
|
1102 return ret; |
|
1103 } |
|
1104 |
|
1105 TLex8 lex; |
|
1106 // Find xxx from ./Proxy/ProxyIdxxx/... |
|
1107 TInt start = aURI.Find( KDynamicNodePrefix ) + KDynamicNodePrefix().Length(); |
|
1108 lex = aURI.Mid( start, 3 ); |
|
1109 lex.Val( ret ); |
|
1110 |
|
1111 return ret; |
|
1112 } |