|
1 /* |
|
2 * Copyright (c) 2009 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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 #include "primitiveassertion.h" |
|
26 #include "policyassertion.h" |
|
27 #include "xorcompositeassertion.h" |
|
28 #include "andcompositeassertion.h" |
|
29 #include "wspolicyreader.h" |
|
30 #include "wspolicyutils.h" |
|
31 using namespace WSPolicy; |
|
32 |
|
33 CPrimitiveAssertion* CPrimitiveAssertion::NewL() |
|
34 { |
|
35 CPrimitiveAssertion* pSelf = CPrimitiveAssertion::NewLC(); |
|
36 CleanupStack::Pop(pSelf); |
|
37 return pSelf; |
|
38 |
|
39 } |
|
40 CPrimitiveAssertion* CPrimitiveAssertion::NewLC() |
|
41 { |
|
42 CPrimitiveAssertion* pSelf = new (ELeave) CPrimitiveAssertion(); |
|
43 CleanupStack::PushL(pSelf); |
|
44 pSelf->ConstructL(); |
|
45 return pSelf; |
|
46 |
|
47 } |
|
48 CPrimitiveAssertion* CPrimitiveAssertion::NewL(CPrimitiveAssertion* aValue) |
|
49 { |
|
50 CPrimitiveAssertion* pSelf = CPrimitiveAssertion::NewLC(aValue); |
|
51 CleanupStack::Pop(pSelf); |
|
52 return pSelf; |
|
53 |
|
54 } |
|
55 CPrimitiveAssertion* CPrimitiveAssertion::NewLC(CPrimitiveAssertion* aValue) |
|
56 { |
|
57 CPrimitiveAssertion* pSelf = new (ELeave) CPrimitiveAssertion(); |
|
58 CleanupStack::PushL(pSelf); |
|
59 pSelf->ConstructL(aValue); |
|
60 return pSelf; |
|
61 } |
|
62 |
|
63 CPrimitiveAssertion* CPrimitiveAssertion::NewL(TDesC8& aName, TDesC8& aPrefix, TDesC8& aUri) |
|
64 { |
|
65 CPrimitiveAssertion* pSelf = CPrimitiveAssertion::NewLC(aName,aPrefix, aUri); |
|
66 CleanupStack::Pop(pSelf); |
|
67 return pSelf; |
|
68 |
|
69 } |
|
70 CPrimitiveAssertion* CPrimitiveAssertion::NewLC(TDesC8& aName, TDesC8& aPrefix, TDesC8& aUri) |
|
71 { |
|
72 CPrimitiveAssertion* pSelf = new (ELeave) CPrimitiveAssertion(); |
|
73 CleanupStack::PushL(pSelf); |
|
74 pSelf->ConstructL(aName, aPrefix, aUri); |
|
75 return pSelf; |
|
76 |
|
77 } |
|
78 |
|
79 CPrimitiveAssertion::~CPrimitiveAssertion() |
|
80 { |
|
81 delete iQname;// QName qname; |
|
82 if(iAttr != NULL) |
|
83 { |
|
84 iAttr->Reset(); //Hashtable attributes = new Hashtable(); |
|
85 delete iAttr; |
|
86 } |
|
87 delete iStrValue; |
|
88 } |
|
89 |
|
90 CPrimitiveAssertion::CPrimitiveAssertion(): |
|
91 iOwner(NULL), iIsOptional(EFalse),iStrValue(NULL) |
|
92 { |
|
93 |
|
94 } |
|
95 void CPrimitiveAssertion::ConstructL() |
|
96 { |
|
97 iAttr = new (ELeave) RAttributeMap(ETrue, ETrue); |
|
98 } |
|
99 void CPrimitiveAssertion::ConstructL(CPrimitiveAssertion* aValue) |
|
100 { |
|
101 CQName* temp = aValue->QName(); |
|
102 if(temp) |
|
103 { |
|
104 TPtrC8 name = temp->Name(); |
|
105 TPtrC8 prefix = temp->Prefix(); |
|
106 TPtrC8 uri = temp->Uri(); |
|
107 ConstructL(name, prefix,uri); |
|
108 |
|
109 SetAttributesL(aValue->Attributes()); |
|
110 |
|
111 TPtrC8 strval = aValue->StrValue(); |
|
112 iStrValue = strval.AllocL(); |
|
113 |
|
114 RPolicyTerms terms = aValue->GetTerms(); |
|
115 |
|
116 if(terms.Count() > 0) |
|
117 AddTermsCopyL(terms); |
|
118 } |
|
119 |
|
120 } |
|
121 |
|
122 void CPrimitiveAssertion::ConstructL(TDesC8& aName, TDesC8& aPrefix, TDesC8& aUri) |
|
123 { |
|
124 iQname = CQName::NewL(aName, aPrefix, aUri); |
|
125 ConstructL(); |
|
126 } |
|
127 MAssertion* CPrimitiveAssertion::GetParent() |
|
128 { |
|
129 return iOwner; |
|
130 } |
|
131 RPolicyTerms& CPrimitiveAssertion::GetTerms() |
|
132 { |
|
133 return CAssertion::GetTerms(); |
|
134 } |
|
135 TAssertionType CPrimitiveAssertion::Type() |
|
136 { |
|
137 return EPrimitiveType; |
|
138 } |
|
139 TBool CPrimitiveAssertion::HasParent() |
|
140 { |
|
141 if(iOwner) |
|
142 return ETrue; |
|
143 else |
|
144 return EFalse; |
|
145 } |
|
146 TBool CPrimitiveAssertion::IsEmpty() |
|
147 { |
|
148 if(Size() > 0) |
|
149 return EFalse; |
|
150 else |
|
151 return ETrue; |
|
152 } |
|
153 void AppendAll(RPolicyTerms& aSource, RPolicyTerms& aDest) |
|
154 { |
|
155 TInt count = aSource.Count(); |
|
156 if(count > 0) |
|
157 { |
|
158 for (TInt i = 0; i < count; i++) |
|
159 { |
|
160 MAssertion* term = aSource[i]; |
|
161 aDest.Append(term); |
|
162 } |
|
163 } |
|
164 } |
|
165 MAssertion* CPrimitiveAssertion::NormalizeL() |
|
166 { |
|
167 return NormalizeL(NULL); |
|
168 } |
|
169 MAssertion* CPrimitiveAssertion::NormalizeL(CPolicyRegistry* aRegistry) |
|
170 { |
|
171 if (IsNormalized()) |
|
172 { |
|
173 return this; |
|
174 } |
|
175 |
|
176 if (IsOptional()) |
|
177 { |
|
178 |
|
179 CXorCompositeAssertion* XOR = CXorCompositeAssertion::NewL(); |
|
180 CAndCompositeAssertion* AND = CAndCompositeAssertion::NewL(); |
|
181 |
|
182 CPrimitiveAssertion* PRIM = GetSelfWithoutTermsL(); |
|
183 PRIM->RemoveAttribute(KWspOptinal); |
|
184 PRIM->SetOptional(false); |
|
185 RPolicyTerms terms1 = GetTerms(); |
|
186 PRIM->SetTermsL(terms1); |
|
187 |
|
188 AND->AddTerm(PRIM); |
|
189 XOR->AddTerm(AND); |
|
190 XOR->AddTerm(CAndCompositeAssertion::NewL()); |
|
191 |
|
192 MAssertion* result = XOR->NormalizeL(aRegistry); |
|
193 delete XOR; |
|
194 return result; |
|
195 |
|
196 } |
|
197 RPolicyTerms terms2 = GetTerms(); |
|
198 if (terms2.Count() == 0) |
|
199 { |
|
200 CPrimitiveAssertion* PRIM = GetSelfWithoutTermsL(); |
|
201 PRIM->SetNormalized(true); |
|
202 return PRIM; |
|
203 } |
|
204 |
|
205 RPolicyTerms policyTerms; |
|
206 RPolicyTerms nonPolicyTerms; |
|
207 for(TInt i =0 ; i < terms2.Count(); i++) |
|
208 { |
|
209 MAssertion* term = terms2[i]; |
|
210 |
|
211 if (dynamic_cast<CPolicyAssertion*>(term)) |
|
212 { |
|
213 policyTerms.Append(term); |
|
214 |
|
215 } |
|
216 else if (dynamic_cast<CPrimitiveAssertion*>(term)) |
|
217 { |
|
218 nonPolicyTerms.Append(term); |
|
219 |
|
220 } |
|
221 else |
|
222 { |
|
223 } |
|
224 } |
|
225 |
|
226 if (policyTerms.Count() == 0) { |
|
227 CPrimitiveAssertion* PRIM = CPrimitiveAssertion::NewL(this); |
|
228 PRIM->SetNormalized(true); |
|
229 policyTerms.Close(); |
|
230 nonPolicyTerms.Close(); |
|
231 return PRIM; |
|
232 } |
|
233 |
|
234 CPolicyAssertion* policyTerm = CWSPolicyUtils::GetSinglePolicyL(policyTerms, aRegistry); |
|
235 RPolicyTerms polTerms = policyTerm->GetTerms(); |
|
236 if(polTerms.Count() > 0) |
|
237 { |
|
238 MAssertion* xorTerm = polTerms[0]; |
|
239 RPolicyTerms ANDs = xorTerm->GetTerms(); |
|
240 |
|
241 if (ANDs.Count() == 0) |
|
242 { |
|
243 delete policyTerm; |
|
244 policyTerms.Close(); |
|
245 nonPolicyTerms.Close(); |
|
246 return CXorCompositeAssertion::NewL(); |
|
247 } |
|
248 |
|
249 if (ANDs.Count() == 1) |
|
250 { |
|
251 //DONE |
|
252 CAndCompositeAssertion* term = (CAndCompositeAssertion*) ANDs[0]; |
|
253 term->AddTermsCopyL(nonPolicyTerms); |
|
254 CPrimitiveAssertion* PRIM = GetSelfWithoutTermsL(); |
|
255 PRIM->AddTerm(policyTerm); |
|
256 policyTerms.Close(); |
|
257 nonPolicyTerms.Close(); |
|
258 return PRIM; |
|
259 } |
|
260 |
|
261 CPolicyAssertion* nPOLICY = CPolicyAssertion::NewL(); |
|
262 CXorCompositeAssertion* nXOR = CXorCompositeAssertion::NewL(); |
|
263 nPOLICY->AddTerm(nXOR); |
|
264 |
|
265 RPolicyTerms list; |
|
266 |
|
267 for (TInt j = 0; j < ANDs.Count(); j++) |
|
268 { |
|
269 CPrimitiveAssertion* nPRIM = GetSelfWithoutTermsL(); |
|
270 |
|
271 CAndCompositeAssertion* andTerm = (CAndCompositeAssertion*)ANDs[j]; |
|
272 RPolicyTerms terms3 = andTerm->GetTerms(); |
|
273 AppendAll(terms3, list); |
|
274 |
|
275 if (nonPolicyTerms.Count() > 0) |
|
276 { |
|
277 AppendAll(nonPolicyTerms, list); |
|
278 } |
|
279 CPolicyAssertion* pol = GetSinglePolicyL(list); |
|
280 nPRIM->AddTerm(pol); |
|
281 |
|
282 CAndCompositeAssertion* AND = CAndCompositeAssertion::NewL(); |
|
283 AND->AddTerm(nPRIM); |
|
284 nXOR->AddTerm(AND); |
|
285 list.Close(); |
|
286 } |
|
287 |
|
288 delete policyTerm; |
|
289 policyTerms.Close(); |
|
290 nonPolicyTerms.Close(); |
|
291 |
|
292 nPOLICY->SetNormalized(ETrue); |
|
293 return nPOLICY; |
|
294 } |
|
295 |
|
296 return NULL; |
|
297 } |
|
298 MAssertion* CPrimitiveAssertion::IntersectL(MAssertion* aAssertion) |
|
299 { |
|
300 return IntersectL(aAssertion, NULL); |
|
301 } |
|
302 MAssertion* CPrimitiveAssertion::IntersectL(MAssertion* aAssertion, CPolicyRegistry* aRegistry) |
|
303 { |
|
304 MAssertion* normalizedMe = (IsNormalized()) ? this : NormalizeL(aRegistry); |
|
305 |
|
306 if (!(dynamic_cast<CPrimitiveAssertion*>(normalizedMe))) |
|
307 { |
|
308 return normalizedMe->IntersectL(aAssertion, aRegistry); |
|
309 } |
|
310 |
|
311 MAssertion* target = (aAssertion->IsNormalized()) ? aAssertion : aAssertion->NormalizeL(aRegistry); |
|
312 |
|
313 // Am not a primitive assertion anymore .. |
|
314 if (!(dynamic_cast<CPrimitiveAssertion*>(aAssertion))) |
|
315 { |
|
316 return normalizedMe->IntersectL(aAssertion, aRegistry); |
|
317 } |
|
318 |
|
319 // argument is not primitive type .. |
|
320 if (!(dynamic_cast<CPrimitiveAssertion*>(target))) |
|
321 { |
|
322 return target->IntersectL(normalizedMe, aRegistry); |
|
323 } |
|
324 |
|
325 CPrimitiveAssertion* arg = (CPrimitiveAssertion*) target; |
|
326 CPrimitiveAssertion* self = (CPrimitiveAssertion*) normalizedMe; |
|
327 |
|
328 if (!self->Name().Compare(arg->Name()) == 0) |
|
329 { |
|
330 return CXorCompositeAssertion::NewL(); // no bahaviour is admisible |
|
331 } |
|
332 |
|
333 if (self->GetTerms().Count() == 0 && arg->GetTerms().Count() == 0) |
|
334 { |
|
335 CAndCompositeAssertion* assertion2 = CAndCompositeAssertion::NewL(); |
|
336 assertion2->AddTermCopyL(self); |
|
337 assertion2->AddTermCopyL(arg); |
|
338 return assertion2; |
|
339 } |
|
340 |
|
341 if (self->GetTerms().Count() == 0 || arg->GetTerms().Count() == 0) |
|
342 { |
|
343 return CXorCompositeAssertion::NewL(); // no |
|
344 } |
|
345 |
|
346 RPolicyTerms argChildTerms; |
|
347 TBool closeArrayarg = EFalse; |
|
348 if (dynamic_cast<CPolicyAssertion*>(arg->GetTerms()[0])) |
|
349 { |
|
350 CWSPolicyUtils::GetPrimTermsListL((CPolicyAssertion*) arg->GetTerms()[0], argChildTerms); |
|
351 closeArrayarg = ETrue; |
|
352 } |
|
353 else |
|
354 { |
|
355 argChildTerms = arg->GetTerms(); |
|
356 } |
|
357 |
|
358 RPolicyTerms selfChildTerms; |
|
359 TBool closeArrayself = EFalse; |
|
360 if (dynamic_cast<CPolicyAssertion*>(self->GetTerms()[0])) |
|
361 { |
|
362 CWSPolicyUtils::GetPrimTermsListL((CPolicyAssertion*) self->GetTerms()[0], selfChildTerms); |
|
363 closeArrayself = ETrue; |
|
364 } |
|
365 else |
|
366 { |
|
367 selfChildTerms = self->GetTerms(); |
|
368 } |
|
369 |
|
370 /////////////////////////////////////////////////////////////////////// |
|
371 /////////////////////////////////////////////////////////////////////// |
|
372 |
|
373 CPrimitiveAssertion* PRIMITIVE_A = NULL; |
|
374 CPrimitiveAssertion* PRIMITIVE_B = NULL; |
|
375 RPolicyTerms primListA, primListB; |
|
376 |
|
377 if (selfChildTerms.Count() > argChildTerms.Count()) { |
|
378 primListA = selfChildTerms; |
|
379 primListB = argChildTerms; |
|
380 } else { |
|
381 primListA = argChildTerms; |
|
382 primListB = selfChildTerms; |
|
383 } |
|
384 |
|
385 for (TInt i = 0 ; i < primListA.Count(); i++) |
|
386 { |
|
387 PRIMITIVE_A = (CPrimitiveAssertion*) primListA[i]; |
|
388 |
|
389 TBool found = EFalse; |
|
390 for (TInt j = 0 ; j < primListB.Count(); j++) |
|
391 { |
|
392 PRIMITIVE_B = (CPrimitiveAssertion*) primListB[j]; |
|
393 if (PRIMITIVE_A->Name().Compare(PRIMITIVE_B->Name()) == 0) |
|
394 { |
|
395 found = ETrue; |
|
396 break; |
|
397 } |
|
398 } |
|
399 |
|
400 if (!found) |
|
401 { |
|
402 if(closeArrayarg) |
|
403 argChildTerms.Close(); |
|
404 if(closeArrayself) |
|
405 selfChildTerms.Close(); |
|
406 |
|
407 return CXorCompositeAssertion::NewL(); |
|
408 } |
|
409 |
|
410 MAssertion* assert = PRIMITIVE_A->IntersectL(PRIMITIVE_B); |
|
411 if (dynamic_cast<CXorCompositeAssertion*>(assert)) |
|
412 { |
|
413 if(closeArrayarg) |
|
414 argChildTerms.Close(); |
|
415 if(closeArrayself) |
|
416 selfChildTerms.Close(); |
|
417 |
|
418 DeleteAssertion(assert); |
|
419 return CXorCompositeAssertion::NewL(); |
|
420 } |
|
421 else |
|
422 { |
|
423 DeleteAssertion(assert); |
|
424 } |
|
425 } |
|
426 |
|
427 CAndCompositeAssertion* andCompositeAssertion = CAndCompositeAssertion::NewL(); |
|
428 andCompositeAssertion->AddTermCopyL(arg); |
|
429 andCompositeAssertion->AddTermCopyL(self); |
|
430 |
|
431 if(closeArrayarg) |
|
432 argChildTerms.Close(); |
|
433 if(closeArrayself) |
|
434 selfChildTerms.Close(); |
|
435 |
|
436 return andCompositeAssertion; |
|
437 |
|
438 } |
|
439 MAssertion* CPrimitiveAssertion::MergeL(MAssertion* aAssertion) |
|
440 { |
|
441 return MergeL(aAssertion, NULL); |
|
442 } |
|
443 MAssertion* CPrimitiveAssertion::MergeL(MAssertion* aAssertion, CPolicyRegistry* aRegistry) |
|
444 { |
|
445 MAssertion* normalizedMe = (IsNormalized()) ? this : NormalizeL(aRegistry); |
|
446 |
|
447 if (!(dynamic_cast<CPrimitiveAssertion*>(normalizedMe))) |
|
448 { |
|
449 return normalizedMe->MergeL(aAssertion, aRegistry); |
|
450 } |
|
451 |
|
452 MAssertion* target = (aAssertion->IsNormalized()) ? aAssertion : aAssertion->NormalizeL(aRegistry); |
|
453 |
|
454 if (!(dynamic_cast<CPrimitiveAssertion*>(target))) |
|
455 { |
|
456 return target->MergeL(normalizedMe, aRegistry); |
|
457 } |
|
458 |
|
459 /* |
|
460 * both self and the argument are primitive assertions. Hence both |
|
461 * should be wrapped in an AndCompositeType |
|
462 */ |
|
463 CAndCompositeAssertion* AND = CAndCompositeAssertion::NewL(); |
|
464 AND->AddTermCopyL(target); |
|
465 AND->AddTermCopyL(normalizedMe); |
|
466 return AND; |
|
467 |
|
468 } |
|
469 TBool CPrimitiveAssertion::Remove(MAssertion* aAssertion) |
|
470 { |
|
471 if(aAssertion) |
|
472 { |
|
473 CAssertion::Remove(aAssertion); |
|
474 } |
|
475 return ETrue; |
|
476 |
|
477 } |
|
478 TInt CPrimitiveAssertion::Size() |
|
479 { |
|
480 return CAssertion::Size(); |
|
481 } |
|
482 |
|
483 |
|
484 TInt CPrimitiveAssertion::SetTermsL(RPolicyTerms& aTerms) |
|
485 { |
|
486 this->AddTermsCopyL(aTerms); |
|
487 return KErrNone; |
|
488 } |
|
489 void CPrimitiveAssertion::AddAttributeL(TDesC8& aQname, TDesC8& aValue) |
|
490 { |
|
491 TInt indx = iAttr->Find(aQname); |
|
492 if(indx == KErrNotFound) |
|
493 { |
|
494 iAttr->Append(aQname.AllocL(),aValue.AllocL()); |
|
495 } |
|
496 else |
|
497 { |
|
498 iAttr->UpdateValue(aQname.AllocL(),aValue.AllocL()); |
|
499 } |
|
500 } |
|
501 TPtrC8 CPrimitiveAssertion::GetAttributeValue(const TDesC8& aQname) |
|
502 { |
|
503 TInt indx = iAttr->Find(aQname); |
|
504 if(indx != KErrNotFound) |
|
505 { |
|
506 const TDesC8* value = iAttr->ValueAt(indx); |
|
507 return *value; //->Ptr(); |
|
508 } |
|
509 return KNullDesC8(); |
|
510 } |
|
511 RAttributeMap& CPrimitiveAssertion::Attributes() |
|
512 { |
|
513 // aAttributes.Copy(iAttr); |
|
514 return *iAttr; |
|
515 } |
|
516 TInt CPrimitiveAssertion::SetAttributesL(RAttributeMap& aAttributes) |
|
517 { |
|
518 |
|
519 TInt count = aAttributes.Count(); |
|
520 for (TInt i=0; i< count; i++) |
|
521 { |
|
522 const TDesC8* name = aAttributes.KeyAt(i); |
|
523 const TDesC8* value = aAttributes.ValueAt(i); |
|
524 HBufC8* tt = name->AllocL(); |
|
525 HBufC8* tt2 = value->AllocL(); |
|
526 TPtrC8 namePtr = tt->Des(); |
|
527 TPtrC8 valPtr = tt2->Des(); |
|
528 AddAttributeL(namePtr, valPtr); |
|
529 delete tt; |
|
530 delete tt2; |
|
531 } |
|
532 return KErrNone; |
|
533 } |
|
534 TInt CPrimitiveAssertion::RemoveAttribute(const TDesC8& aQname) |
|
535 { |
|
536 TInt indx = iAttr->Find(aQname); |
|
537 if(indx != KErrNotFound) |
|
538 { |
|
539 iAttr->RemoveByKey(aQname); |
|
540 return KErrNone; |
|
541 } |
|
542 return KErrNotFound; |
|
543 } |
|
544 |
|
545 CQName* CPrimitiveAssertion::QName() |
|
546 { if(iQname) |
|
547 return iQname; |
|
548 else |
|
549 return NULL; |
|
550 } |
|
551 TPtrC8 CPrimitiveAssertion::Name() |
|
552 { if(iQname) |
|
553 return iQname->QName(); |
|
554 else |
|
555 return KNullDesC8(); |
|
556 } |
|
557 TPtrC8 CPrimitiveAssertion::StrValue() |
|
558 { |
|
559 if(iStrValue) |
|
560 return iStrValue->Des(); |
|
561 else |
|
562 return KNullDesC8(); |
|
563 } |
|
564 void CPrimitiveAssertion::SetStrValueL(TDesC8& aStrValue) |
|
565 { |
|
566 if(aStrValue.Length() > 0) |
|
567 iStrValue = aStrValue.AllocL(); |
|
568 } |
|
569 TAny* CPrimitiveAssertion::Value() |
|
570 { |
|
571 return NULL; |
|
572 } |
|
573 |
|
574 TBool CPrimitiveAssertion::IsOptional() |
|
575 { |
|
576 return iIsOptional; |
|
577 } |
|
578 TInt CPrimitiveAssertion::SetOptional(TBool aOptional) |
|
579 { |
|
580 iIsOptional = aOptional; |
|
581 return KErrNone; |
|
582 } |
|
583 |
|
584 CPolicyAssertion* CPrimitiveAssertion::GetSinglePolicyL(RPolicyTerms aChildTerms) |
|
585 { |
|
586 |
|
587 CPolicyAssertion* policy = CPolicyAssertion::NewL(); |
|
588 CXorCompositeAssertion* pXor = CXorCompositeAssertion::NewL(); |
|
589 CAndCompositeAssertion* pAnd = CAndCompositeAssertion::NewL(); |
|
590 pAnd->AddTermsCopyL(aChildTerms); |
|
591 pXor->AddTerm(pAnd); |
|
592 policy->AddTerm(pXor); |
|
593 return policy; |
|
594 |
|
595 } |
|
596 |
|
597 TBool CPrimitiveAssertion::IsEmptyPolicy(CPolicyAssertion* aPolicy) |
|
598 { |
|
599 |
|
600 RPolicyTerms terms = aPolicy->GetTerms(); |
|
601 if(terms.Count() > 0) |
|
602 { |
|
603 CXorCompositeAssertion* xorTerm = (CXorCompositeAssertion* )terms[0]; |
|
604 return xorTerm->IsEmpty(); |
|
605 } |
|
606 else |
|
607 return EFalse; |
|
608 |
|
609 } |
|
610 |
|
611 RPolicyTerms CPrimitiveAssertion::GetTerms(CPolicyAssertion* aPolicy) |
|
612 { |
|
613 |
|
614 RPolicyTerms terms1 = aPolicy->GetTerms(); |
|
615 if(terms1.Count() > 0) |
|
616 { |
|
617 CXorCompositeAssertion* xorTerm = (CXorCompositeAssertion*)terms1[0]; |
|
618 if(xorTerm) |
|
619 { |
|
620 RPolicyTerms terms2 = xorTerm->GetTerms(); |
|
621 if(terms2.Count() > 0) |
|
622 { |
|
623 CAndCompositeAssertion* andTerm= (CAndCompositeAssertion*) terms2[0]; |
|
624 if(andTerm) |
|
625 return andTerm->GetTerms(); |
|
626 } |
|
627 } |
|
628 } |
|
629 RPolicyTerms empty_terms; |
|
630 return empty_terms; |
|
631 } |
|
632 |
|
633 CPrimitiveAssertion* CPrimitiveAssertion::GetSelfWithoutTermsL() |
|
634 { |
|
635 TPtrC8 name = iQname->Name(); |
|
636 TPtrC8 prefix = iQname->Prefix(); |
|
637 TPtrC8 uri = iQname->Uri(); |
|
638 |
|
639 CPrimitiveAssertion* prim = CPrimitiveAssertion::NewL(name, prefix, uri); |
|
640 prim->SetAttributesL(*iAttr); |
|
641 TPtrC8 strval = StrValue(); |
|
642 prim->SetStrValueL(strval); |
|
643 return prim; |
|
644 } |
|
645 |
|
646 |
|
647 CQName* CQName::NewL(TDesC8& aName, TDesC8& aPrefix, TDesC8& aUri) |
|
648 { |
|
649 CQName* pSelf = CQName::NewLC(aName, aPrefix, aUri); |
|
650 CleanupStack::Pop(pSelf); |
|
651 return pSelf; |
|
652 |
|
653 } |
|
654 CQName* CQName::NewLC(TDesC8& aName, TDesC8& aPrefix, TDesC8& aUri) |
|
655 { |
|
656 CQName* pSelf = new (ELeave) CQName(); |
|
657 CleanupStack::PushL(pSelf); |
|
658 pSelf->ConstructL(aName, aPrefix, aUri); |
|
659 return pSelf; |
|
660 |
|
661 } |
|
662 CQName::~CQName() |
|
663 { |
|
664 delete iName; |
|
665 delete iQName; |
|
666 delete iPrefix; |
|
667 delete iUri; |
|
668 } |
|
669 TPtrC8 CQName::Name() |
|
670 { |
|
671 return iName->Des(); |
|
672 } |
|
673 TPtrC8 CQName::QName() |
|
674 { |
|
675 return iQName->Des(); |
|
676 } |
|
677 TPtrC8 CQName::Prefix() |
|
678 { |
|
679 return iPrefix->Des(); |
|
680 } |
|
681 TPtrC8 CQName::Uri() |
|
682 { |
|
683 return iUri->Des(); |
|
684 } |
|
685 CQName::CQName() |
|
686 { |
|
687 |
|
688 } |
|
689 |
|
690 void CQName::ConstructL(TDesC8& aName, TDesC8& aPrefix, TDesC8& aUri) |
|
691 { |
|
692 _LIT8(KColon, ":"); |
|
693 iName = aName.AllocL(); |
|
694 iPrefix = aPrefix.AllocL(); |
|
695 iUri = aUri.AllocL(); |
|
696 iQName = HBufC8::NewL( aPrefix.Length() + KColon().Length() + aName.Length() ); |
|
697 TPtr8 qname = iQName->Des(); |
|
698 qname.Append( aPrefix ); |
|
699 qname.Append( KColon ); |
|
700 qname.Append( aName ); |
|
701 } |
|
702 // End of File |
|
703 |
|
704 |