|
1 /* |
|
2 * Copyright (c) 2002-2004 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: ?Description |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include <e32base.h> |
|
22 #include "Base64.h" |
|
23 #include "RoapParser.h" |
|
24 #include "RegistrationResp.h" |
|
25 #include "RegistrationRespParser.h" |
|
26 |
|
27 using namespace Roap; |
|
28 |
|
29 // LOCAL CONSTANTS AND MACROS |
|
30 _LIT8(KStatus, "status"); |
|
31 _LIT8(KSessionId, "sessionId"); |
|
32 _LIT8(KErrorUrl, "errorRedirectURL"); |
|
33 |
|
34 // ============================ MEMBER FUNCTIONS =============================== |
|
35 |
|
36 // ----------------------------------------------------------------------------- |
|
37 // TRegistrationRespParser::TRegistrationRespParser |
|
38 // C++ default constructor can NOT contain any code, that |
|
39 // might leave. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 TRegistrationRespParser::TRegistrationRespParser( |
|
43 CRegistrationResp* aResponse) |
|
44 { |
|
45 iResponse = aResponse; |
|
46 } |
|
47 |
|
48 // ----------------------------------------------------------------------------- |
|
49 // TRegistrationRespParser::?member_function |
|
50 // ?implementation_description |
|
51 // (other items were commented in a header). |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void TRegistrationRespParser::OnStartElementL( |
|
55 CRoapParser& aParser, |
|
56 TInt aState, |
|
57 const RTagInfo& /*aElement*/, |
|
58 const RAttributeArray& aAttributes) |
|
59 { |
|
60 HBufC8* buffer = NULL; |
|
61 |
|
62 switch (aState) |
|
63 { |
|
64 case ERegistrationResponseState: |
|
65 buffer = aParser.GetAttributeValueL(aAttributes, KStatus); |
|
66 if (buffer != NULL) |
|
67 { |
|
68 iResponse->iStatus = aParser.ConvertRoapStatus(*buffer); |
|
69 delete buffer; |
|
70 } |
|
71 else |
|
72 { |
|
73 iResponse->iStatus = EUnknownStatus; |
|
74 } |
|
75 iResponse->iSession = |
|
76 aParser.GetAttributeValueL(aAttributes, KSessionId); |
|
77 |
|
78 iResponse->iErrorUrl = aParser.GetAttributeValueL(aAttributes, KErrorUrl); |
|
79 break; |
|
80 } |
|
81 } |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // TRegistrationRespParser::?member_function |
|
85 // ?implementation_description |
|
86 // (other items were commented in a header). |
|
87 // ----------------------------------------------------------------------------- |
|
88 // |
|
89 void TRegistrationRespParser::OnEndElementL( |
|
90 CRoapParser& aParser, |
|
91 TInt aState, |
|
92 const RTagInfo& /*aElement*/) |
|
93 { |
|
94 switch (aState) |
|
95 { |
|
96 case ECertificateState: |
|
97 if( aParser.iContent->Length() ) |
|
98 iResponse->iCertificateChain.Append( |
|
99 Base64DecodeL(*aParser.iContent)); |
|
100 break; |
|
101 case EOcspResponseState: |
|
102 if( aParser.iContent->Length() ) |
|
103 iResponse->iOcspResponse.Append(Base64DecodeL(*aParser.iContent)); |
|
104 break; |
|
105 case ERiUrlState: |
|
106 if( aParser.iContent->Length() ) |
|
107 iResponse->iRiUrl = aParser.iContent->AllocL(); |
|
108 break; |
|
109 case ESignatureState: |
|
110 if( aParser.iContent->Length() ) |
|
111 iResponse->iSignature = Base64DecodeL(*aParser.iContent); |
|
112 break; |
|
113 case EWhiteListState: |
|
114 if( aParser.iContent->Length() ) |
|
115 iResponse->iWhiteList.Append(aParser.iContent->AllocL()); |
|
116 break; |
|
117 } |
|
118 } |
|
119 |
|
120 // End of File |