|
1 /* |
|
2 * Copyright (c) 2006-2007 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 #include "natfwunsafrealmattribute.h" |
|
22 #include "natfwunsafutils.h" |
|
23 |
|
24 // ----------------------------------------------------------------------------- |
|
25 // CNATFWUNSAFRealmAttribute::NewL |
|
26 // ----------------------------------------------------------------------------- |
|
27 // |
|
28 EXPORT_C CNATFWUNSAFRealmAttribute* CNATFWUNSAFRealmAttribute::NewL( |
|
29 const TDesC8& aRealm) |
|
30 { |
|
31 CNATFWUNSAFRealmAttribute* self = CNATFWUNSAFRealmAttribute::NewLC( |
|
32 aRealm); |
|
33 CleanupStack::Pop(self); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CNATFWUNSAFRealmAttribute::NewLC |
|
39 // ----------------------------------------------------------------------------- |
|
40 // |
|
41 EXPORT_C CNATFWUNSAFRealmAttribute* CNATFWUNSAFRealmAttribute::NewLC( |
|
42 const TDesC8& aRealm) |
|
43 { |
|
44 CNATFWUNSAFRealmAttribute* self = |
|
45 new (ELeave) CNATFWUNSAFRealmAttribute(); |
|
46 CleanupStack::PushL(self); |
|
47 //Validate realm-value |
|
48 TPtrC8 checkedRealm = NATFWUNSAFUtils::RealmValueFromQuotedStringL(aRealm); |
|
49 self->ConstructL(checkedRealm); |
|
50 return self; |
|
51 } |
|
52 |
|
53 // ----------------------------------------------------------------------------- |
|
54 // CNATFWUNSAFRealmAttribute::DecodeAttributeL |
|
55 // ----------------------------------------------------------------------------- |
|
56 // |
|
57 CNATFWUNSAFAttribute* |
|
58 CNATFWUNSAFRealmAttribute::DecodeAttributeL(const TDesC8& aByteStream) |
|
59 { |
|
60 TUint16 valueLength = ParseLengthL(aByteStream); |
|
61 |
|
62 //Stream has to have enough data for the whole value element |
|
63 __ASSERT_ALWAYS(aByteStream.Length() >= EValueOffset + valueLength, |
|
64 User::Leave(KErrArgument)); |
|
65 return NewL(aByteStream.Mid(EValueOffset, valueLength)); |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CNATFWUNSAFRealmAttribute::CNATFWUNSAFRealmAttribute |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CNATFWUNSAFRealmAttribute::CNATFWUNSAFRealmAttribute() : |
|
73 CNATFWUNSAFAttribute() |
|
74 { |
|
75 } |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CNATFWUNSAFRealmAttribute::ConstructL |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CNATFWUNSAFRealmAttribute::ConstructL(const TDesC8& aRealm) |
|
82 { |
|
83 iRealm = aRealm.AllocL(); |
|
84 } |
|
85 |
|
86 // ----------------------------------------------------------------------------- |
|
87 // CNATFWUNSAFRealmAttribute::~CNATFWUNSAFRealmAttribute |
|
88 // ----------------------------------------------------------------------------- |
|
89 // |
|
90 CNATFWUNSAFRealmAttribute::~CNATFWUNSAFRealmAttribute() |
|
91 { |
|
92 delete iRealm; |
|
93 } |
|
94 |
|
95 // ----------------------------------------------------------------------------- |
|
96 // CNATFWUNSAFRealmAttribute::Type |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 CNATFWUNSAFAttribute::TType CNATFWUNSAFRealmAttribute::Type() const |
|
100 { |
|
101 return ERealm; |
|
102 } |
|
103 |
|
104 // ----------------------------------------------------------------------------- |
|
105 // CNATFWUNSAFRealmAttribute::EncodeValueL |
|
106 // ----------------------------------------------------------------------------- |
|
107 // |
|
108 HBufC8* CNATFWUNSAFRealmAttribute::EncodeValueL() const |
|
109 { |
|
110 return iRealm->AllocL(); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CNATFWUNSAFRealmAttribute::Value |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C const TDesC8& CNATFWUNSAFRealmAttribute::Value() const |
|
118 { |
|
119 return *iRealm; |
|
120 } |
|
121 |