|
1 /* |
|
2 * Copyright (c) 2002-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: This class represents the policy information |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 // INCLUDE FILES |
|
26 #include <e32std.h> |
|
27 #include <s32strm.h> |
|
28 #include "sendebug.h" |
|
29 #include "senservicepolicy.h" |
|
30 #include "SenXmlElement.h" |
|
31 #include "senguidgen.h" |
|
32 #include "SenXmlServiceDescription.h" |
|
33 #include "senlogger.h" |
|
34 |
|
35 // ============================= LOCAL FUNCTIONS =============================== |
|
36 |
|
37 namespace |
|
38 { |
|
39 _LIT8(KServicePolicyLocalName, "ServicePolicy"); |
|
40 _LIT8(KSenNsUri, "urn:com.nokia.Sen.config.1.0"); |
|
41 _LIT8(KPolicyLocalName, "Policy"); |
|
42 _LIT8(KPolicyArrayLocalName, "PolicyArray"); |
|
43 _LIT8(KWsPolicyNsUri , "http://schemas.xmlsoap.org/ws/2004/09/policy"); // Namespace of WS-Policy |
|
44 _LIT8(KClientServicePolicyLocalName, "ClientPolicy"); |
|
45 } |
|
46 |
|
47 |
|
48 CSenServicePolicy* CSenServicePolicy::NewL() |
|
49 { |
|
50 CSenServicePolicy* pNew = NewLC(); |
|
51 CleanupStack::Pop(); |
|
52 return(pNew) ; |
|
53 } |
|
54 |
|
55 CSenServicePolicy* CSenServicePolicy::NewLC() |
|
56 { |
|
57 CSenServicePolicy* pNew = new (ELeave) CSenServicePolicy(); |
|
58 CleanupStack::PushL(pNew); |
|
59 pNew->BaseConstructL(); |
|
60 return pNew; |
|
61 } |
|
62 |
|
63 CSenServicePolicy::CSenServicePolicy() |
|
64 { |
|
65 } |
|
66 |
|
67 CSenServicePolicy::~CSenServicePolicy() |
|
68 { |
|
69 } |
|
70 |
|
71 void CSenServicePolicy::BaseConstructL() |
|
72 { |
|
73 CServicePolicy::BaseConstructL(KServicePolicyLocalName()); |
|
74 } |
|
75 |
|
76 //Rebuild both client and Service Policy from the given Template |
|
77 TInt CSenServicePolicy::RebuildServicePolicyFrom(MSenServicePolicy& aTemplate) |
|
78 { |
|
79 TInt retVal(KErrNone); |
|
80 TInt err( KErrNone ); |
|
81 // check for possible policies definition |
|
82 CSenServicePolicy* policy = (CSenServicePolicy*)&aTemplate; |
|
83 CSenElement& pServicePolicyElement = policy->AsElement(); |
|
84 CSenElement* copy = NULL; |
|
85 TRAP( err, copy = CSenXmlElement::NewL(KServicePolicyLocalName); ) |
|
86 if( !copy ) |
|
87 { |
|
88 return KErrNoMemory; |
|
89 } |
|
90 else if( !err ) |
|
91 { |
|
92 TRAP( err, copy->CopyFromL( pServicePolicyElement ); ) |
|
93 if( !err ) |
|
94 { |
|
95 #ifdef _SENDEBUG |
|
96 { // parenthesis -pair added to avoid local variable visibility scope collision |
|
97 TLSLOG_L(KSenServConnLogChannelBase,KMaxLogLevel,"TInt CSenServicePolicy::RebuildServicePolicyFrom POLICY"); |
|
98 TLSLOG_L(KSenServConnLogChannelBase,KMaxLogLevel,"-----------COPY----------------------------------------"); |
|
99 TLSLOG_L(KSenServConnLogChannelBase,KMaxLogLevel,"-------------------------------------------------------"); |
|
100 TLSLOG_L(KSenServConnLogChannelBase,KMaxLogLevel,"-------------------------------------------------------"); |
|
101 HBufC8* pXml = NULL; |
|
102 TRAP_IGNORE |
|
103 ( |
|
104 pXml = copy->AsXmlL(); |
|
105 if( pXml ) |
|
106 { |
|
107 TLSLOG_ALL(KSenServConnLogChannelBase,KMaxLogLevel,( *pXml )); |
|
108 } |
|
109 ) |
|
110 delete pXml; |
|
111 } |
|
112 #endif // _SENDEBUG |
|
113 // UpdateClientPolicy |
|
114 CSenElement* pClientPolicy = copy->Element( KClientServicePolicyLocalName ); |
|
115 if(!pClientPolicy) |
|
116 { |
|
117 pClientPolicy = copy->Element( KSenNsUri, KClientServicePolicyLocalName ); |
|
118 } |
|
119 if( pClientPolicy ) |
|
120 { |
|
121 TRAP( err, retVal = AddClientPolicyL( pClientPolicy ); ) |
|
122 //if( err ) |
|
123 // { |
|
124 // retVal = err; |
|
125 // } |
|
126 } |
|
127 |
|
128 // UpdateServicePolicyArray |
|
129 CSenElement* pPolicyArray = copy->Element( KPolicyArrayLocalName ); |
|
130 if(!pPolicyArray) |
|
131 { |
|
132 pPolicyArray = copy->Element( KSenNsUri, KPolicyArrayLocalName ); |
|
133 } |
|
134 |
|
135 if(!pPolicyArray) |
|
136 { |
|
137 pPolicyArray = copy->Element( KNullDesC8, KPolicyArrayLocalName ); |
|
138 } |
|
139 |
|
140 if(pPolicyArray) |
|
141 { |
|
142 RPointerArray<CSenElement> elements; |
|
143 TRAP( err, pPolicyArray->ElementsL( elements, KWsPolicyNsUri, KPolicyLocalName ); ) |
|
144 // -- CleanupClosePushL(elements); // not needed, since array is living in non-leaving code |
|
145 if( !err ) |
|
146 { |
|
147 TInt count = elements.Count(); |
|
148 CSenElement* pPolicy = NULL; |
|
149 for( TInt i = 0; i < count; i++ ) |
|
150 { |
|
151 pPolicy = elements[i]; |
|
152 if( pPolicy ) |
|
153 { |
|
154 TRAP( err, AddPolicyL( pPolicy ); ) |
|
155 } |
|
156 } |
|
157 // -- CleanupStack::PopAndDestroy(&elements); |
|
158 } |
|
159 } |
|
160 } |
|
161 } |
|
162 delete copy; |
|
163 return retVal; |
|
164 } |
|
165 |
|
166 //Do nuthing |
|
167 TBool CSenServicePolicy::Accepts(MSenServicePolicy& aPolicyPattern) |
|
168 { |
|
169 return Accepts(aPolicyPattern); |
|
170 } |
|
171 |
|
172 CSenElement* CSenServicePolicy::ClientPolicy() |
|
173 { |
|
174 CSenElement* pClientPolicyElement = AsElement().Element(KClientServicePolicyLocalName); |
|
175 |
|
176 if(!pClientPolicyElement) |
|
177 { |
|
178 pClientPolicyElement = AsElement().Element(KSenNsUri, KClientServicePolicyLocalName); |
|
179 } |
|
180 |
|
181 return pClientPolicyElement; |
|
182 } |
|
183 |
|
184 // End of file |