|
1 // Copyright (c) 2004-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // Name : CSIPSecurityClientHeader.cpp |
|
15 // Part of : SIP Codec |
|
16 // Version : SIP/4.0 |
|
17 // |
|
18 |
|
19 |
|
20 |
|
21 #include "sipsecurityclientheader.h" |
|
22 #include "CSIPTokenizer.h" |
|
23 #include "sipcodecerr.h" |
|
24 #include "SIPSyntaxCheck.h" |
|
25 #include "sipstrings.h" |
|
26 #include "sipstrconsts.h" |
|
27 #include "_sipcodecdefs.h" |
|
28 |
|
29 |
|
30 // ----------------------------------------------------------------------------- |
|
31 // CSIPSecurityClientHeader::DecodeL |
|
32 // ----------------------------------------------------------------------------- |
|
33 // |
|
34 EXPORT_C RPointerArray<CSIPSecurityClientHeader> |
|
35 CSIPSecurityClientHeader::DecodeL (const TDesC8& aValue) |
|
36 { |
|
37 RPointerArray<CSIPHeaderBase> baseheaders = BaseDecodeL(aValue); |
|
38 CSIPHeaderBase::PushLC(&baseheaders); |
|
39 RPointerArray<CSIPSecurityClientHeader> clientHeaders; |
|
40 CleanupClosePushL(clientHeaders); |
|
41 TInt count = baseheaders.Count(); |
|
42 for (TInt i=0; i < count; i++) |
|
43 { |
|
44 CSIPSecurityClientHeader* header = |
|
45 static_cast<CSIPSecurityClientHeader*>(baseheaders[i]); |
|
46 User::LeaveIfError (clientHeaders.Append(header)); |
|
47 } |
|
48 CleanupStack::Pop(2); //clientHeaders, baseheaders |
|
49 baseheaders.Close(); |
|
50 return clientHeaders; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CSIPSecurityClientHeader::NewL |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 EXPORT_C CSIPSecurityClientHeader* CSIPSecurityClientHeader::NewL( |
|
58 const TDesC8& aMechanismName) |
|
59 { |
|
60 CSIPSecurityClientHeader* self = |
|
61 CSIPSecurityClientHeader::NewLC(aMechanismName); |
|
62 CleanupStack::Pop(self); |
|
63 return self; |
|
64 } |
|
65 |
|
66 // ----------------------------------------------------------------------------- |
|
67 // CSIPSecurityClientHeader::NewLC |
|
68 // ----------------------------------------------------------------------------- |
|
69 // |
|
70 EXPORT_C CSIPSecurityClientHeader* CSIPSecurityClientHeader::NewLC( |
|
71 const TDesC8& aMechanismName) |
|
72 { |
|
73 CSIPSecurityClientHeader* self = new(ELeave)CSIPSecurityClientHeader; |
|
74 CleanupStack::PushL(self); |
|
75 self->CSIPSecurityHeaderBase::ConstructL(aMechanismName); |
|
76 return self; |
|
77 } |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CSIPSecurityClientHeader::CSIPSecurityClientHeader |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CSIPSecurityClientHeader::CSIPSecurityClientHeader() |
|
84 { |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSIPSecurityClientHeader::~CSIPSecurityClientHeader |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 EXPORT_C CSIPSecurityClientHeader::~CSIPSecurityClientHeader() |
|
92 { |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CSIPSecurityClientHeader::CloneL |
|
97 // From CSIPHeaderBase: |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 EXPORT_C CSIPHeaderBase* CSIPSecurityClientHeader::CloneL () const |
|
101 { |
|
102 CSIPSecurityClientHeader* clone = new(ELeave) CSIPSecurityClientHeader; |
|
103 CleanupStack::PushL(clone); |
|
104 clone->ConstructL(*this); |
|
105 CleanupStack::Pop(clone); |
|
106 return clone; |
|
107 } |
|
108 |
|
109 // ---------------------------------------------------------------------------- |
|
110 // CSIPSecurityClientHeader::Name |
|
111 // ---------------------------------------------------------------------------- |
|
112 // |
|
113 EXPORT_C RStringF CSIPSecurityClientHeader::Name () const |
|
114 { |
|
115 return SIPStrings::StringF(SipStrConsts::ESecurityClientHeader); |
|
116 } |
|
117 |
|
118 // ----------------------------------------------------------------------------- |
|
119 // CSIPSecurityClientHeader::BaseDecodeL |
|
120 // From CSIPHeaderBase: |
|
121 // ----------------------------------------------------------------------------- |
|
122 // |
|
123 RPointerArray<CSIPHeaderBase> |
|
124 CSIPSecurityClientHeader::BaseDecodeL(const TDesC8& aValue) |
|
125 { |
|
126 __ASSERT_ALWAYS (aValue.Length() > 0, |
|
127 User::Leave(KErrSipCodecSecurityHeader)); |
|
128 |
|
129 RPointerArray<CSIPHeaderBase> headers; |
|
130 CSIPHeaderBase::PushLC(&headers); |
|
131 CSIPTokenizer* tokenizer = CSIPTokenizer::NewLC(aValue, ','); |
|
132 for (TInt i=0; i < tokenizer->Tokens().Count(); i++) |
|
133 { |
|
134 CSIPSecurityClientHeader* header = |
|
135 new(ELeave) CSIPSecurityClientHeader; |
|
136 CleanupStack::PushL(header); |
|
137 header->ConstructL(); |
|
138 header->ParseL (tokenizer->Tokens()[i]); |
|
139 headers.AppendL(header); |
|
140 CleanupStack::Pop(header); |
|
141 } |
|
142 CleanupStack::PopAndDestroy(tokenizer); |
|
143 CleanupStack::Pop(); // headers |
|
144 return headers; |
|
145 } |
|
146 |
|
147 // ----------------------------------------------------------------------------- |
|
148 // CSIPSecurityClientHeader::InternalizeValueL |
|
149 // ----------------------------------------------------------------------------- |
|
150 // |
|
151 EXPORT_C CSIPHeaderBase* CSIPSecurityClientHeader::InternalizeValueL( |
|
152 RReadStream& aReadStream) |
|
153 { |
|
154 CSIPSecurityClientHeader* self = new(ELeave)CSIPSecurityClientHeader(); |
|
155 CleanupStack::PushL(self); |
|
156 self->DoInternalizeValueL(aReadStream); |
|
157 CleanupStack::Pop(self); |
|
158 return self; |
|
159 } |
|
160 |