|
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: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 // INCLUDE FILES |
|
26 #include <SenDateUtils.h> |
|
27 #include <SenXmlUtils.h> |
|
28 #include <SenXmlElement.h> // check if this include is needed(?) |
|
29 #include "senwsdescription.h" // state constants for credentials |
|
30 |
|
31 #include "idwsfsiuheader.h" |
|
32 |
|
33 CIdWsfSiuHeader* CIdWsfSiuHeader::NewL() |
|
34 { |
|
35 CIdWsfSiuHeader* pNew = new (ELeave) CIdWsfSiuHeader; |
|
36 CleanupStack::PushL(pNew); |
|
37 pNew->ConstructL(); |
|
38 CleanupStack::Pop(); // pNew; |
|
39 return pNew; |
|
40 } |
|
41 |
|
42 CIdWsfSiuHeader::CIdWsfSiuHeader() |
|
43 { |
|
44 } |
|
45 |
|
46 void CIdWsfSiuHeader::ConstructL() |
|
47 { |
|
48 BaseConstructL(KSiuXmlns, KSiuName); |
|
49 iNotOnOrAfter = Time::NullTTime(); |
|
50 } |
|
51 |
|
52 CIdWsfSiuHeader::~CIdWsfSiuHeader() |
|
53 { |
|
54 delete ipCredential; |
|
55 } |
|
56 |
|
57 TPtrC8 CIdWsfSiuHeader::Endpoint() |
|
58 { |
|
59 MSenElement* pElement = this->AsElement().Element(KEndpointName); |
|
60 if(!pElement) |
|
61 { |
|
62 return KNullDesC8(); |
|
63 } |
|
64 else |
|
65 { |
|
66 return pElement->Content(); |
|
67 } |
|
68 } |
|
69 |
|
70 TPtrC8 CIdWsfSiuHeader::SecurityMechId() |
|
71 { |
|
72 MSenElement* pElement = this->AsElement().Element(KSecurityMechIdName); |
|
73 if(!pElement) |
|
74 { |
|
75 return KNullDesC8(); |
|
76 } |
|
77 else |
|
78 { |
|
79 return pElement->Content(); |
|
80 } |
|
81 } |
|
82 |
|
83 const TTime& CIdWsfSiuHeader::NotOnOrAfter() |
|
84 { |
|
85 return iNotOnOrAfter; |
|
86 } |
|
87 |
|
88 TBool CIdWsfSiuHeader::IsNotOnOrAfterSet() |
|
89 { |
|
90 return (iNotOnOrAfter.Int64() != 0); |
|
91 } |
|
92 |
|
93 CSenCredential* CIdWsfSiuHeader::Credential() |
|
94 { |
|
95 return ipCredential; |
|
96 } |
|
97 |
|
98 void CIdWsfSiuHeader::StartElementL( |
|
99 const TDesC8& aNsUri, |
|
100 const TDesC8& aLocalName, |
|
101 const TDesC8& aQName, |
|
102 const RAttributeArray& aAttributes |
|
103 ) |
|
104 { |
|
105 switch (iState) |
|
106 { |
|
107 case KStateParsingCredentials: |
|
108 { |
|
109 // change to even state which ignores and does not save content |
|
110 iState = KStateParsingSingleCredential; |
|
111 |
|
112 CSenCredential* pCredential = CSenCredential::NewL(aNsUri, |
|
113 aLocalName, aQName, aAttributes, AsElement()); |
|
114 delete ipCredential; |
|
115 ipCredential = pCredential; |
|
116 if (iNotOnOrAfter != Time::NullTTime()) |
|
117 { |
|
118 ipCredential->SetValidUntil(iNotOnOrAfter); |
|
119 } |
|
120 DelegateParsingL(*ipCredential); |
|
121 break; |
|
122 } |
|
123 default: |
|
124 { |
|
125 if ((aLocalName == KEndpointName) || |
|
126 (aLocalName == KSecurityMechIdName)) |
|
127 { |
|
128 DelegateParsingL(aNsUri, aLocalName, aQName, aAttributes); |
|
129 } |
|
130 else if (aLocalName == KCredentialElementLocalNameName || |
|
131 aLocalName == KCredentialsName) |
|
132 { |
|
133 TPtrC8 notOnOrAfter = |
|
134 SenXmlUtils::AttrValue(aAttributes, KNotOnOrAfterName); |
|
135 if (notOnOrAfter.Length() > 0) |
|
136 { |
|
137 iNotOnOrAfter = |
|
138 SenDateUtils::FromXmlDateTimeL(notOnOrAfter); |
|
139 } |
|
140 else |
|
141 { |
|
142 iNotOnOrAfter = Time::NullTTime(); |
|
143 } |
|
144 |
|
145 // even state stops saving content |
|
146 iState = KStateParsingCredentials; |
|
147 CSenBaseFragment::StartElementL(aNsUri, aLocalName, |
|
148 aQName, aAttributes); |
|
149 } |
|
150 else |
|
151 { |
|
152 CSenBaseFragment::StartElementL(aNsUri, aLocalName, |
|
153 aQName, aAttributes); |
|
154 } |
|
155 break; |
|
156 } |
|
157 } |
|
158 } |
|
159 |
|
160 void CIdWsfSiuHeader::EndElementL( |
|
161 const TDesC8& aNsUri, |
|
162 const TDesC8& aLocalName, |
|
163 const TDesC8& aQName |
|
164 ) |
|
165 { |
|
166 switch (iState) |
|
167 { |
|
168 // this is due the SAX parsing nature of CXMLReader: |
|
169 // in start element delegateparsing(), |
|
170 // AO is blocked, and thats why the state really is |
|
171 // PARSING single CREDENTIAL, |
|
172 // when we arrive to the end element </Credential> |
|
173 case KStateParsingSingleCredential: |
|
174 { |
|
175 |
|
176 if (aLocalName == KCredentialElementLocalNameName || |
|
177 aLocalName == KCredentialsName) |
|
178 |
|
179 { |
|
180 iState = KStateIgnore; |
|
181 } |
|
182 break; |
|
183 } |
|
184 default: |
|
185 break; |
|
186 } |
|
187 CSenBaseFragment::EndElementL(aNsUri, aLocalName, aQName); |
|
188 } |
|
189 |
|
190 // End of File |
|
191 |