|
1 // Copyright (c) 2006-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 : extensiondescrparam.cpp |
|
15 // Part of : SIP Profile |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // INCLUDE FILES |
|
19 // |
|
20 |
|
21 |
|
22 |
|
23 #include "extensiondescrparam.h" |
|
24 |
|
25 // ============================ MEMBER FUNCTIONS =============================== |
|
26 |
|
27 // ----------------------------------------------------------------------------- |
|
28 // CExtensionDescrParam::NewLC |
|
29 // ----------------------------------------------------------------------------- |
|
30 // |
|
31 CExtensionDescrParam* |
|
32 CExtensionDescrParam::NewLC(TUint32 aID, const TDesC8& aValue) |
|
33 { |
|
34 CExtensionDescrParam* self = new (ELeave) CExtensionDescrParam(aID); |
|
35 CleanupStack::PushL(self); |
|
36 self->ConstructL(aValue); |
|
37 return self; |
|
38 } |
|
39 |
|
40 // ----------------------------------------------------------------------------- |
|
41 // CExtensionDescrParam::CExtensionDescrParam |
|
42 // ----------------------------------------------------------------------------- |
|
43 // |
|
44 CExtensionDescrParam::CExtensionDescrParam(TUint32 aID) : |
|
45 iID(aID), |
|
46 iValue(NULL) |
|
47 { |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CExtensionDescrParam::ConstructL |
|
52 // ----------------------------------------------------------------------------- |
|
53 // |
|
54 void CExtensionDescrParam::ConstructL(const TDesC8& aValue) |
|
55 { |
|
56 iValue = aValue.AllocL(); |
|
57 } |
|
58 |
|
59 // ----------------------------------------------------------------------------- |
|
60 // CExtensionDescrParam::~CExtensionDescrParam |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CExtensionDescrParam::~CExtensionDescrParam() |
|
64 { |
|
65 delete iValue; |
|
66 } |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // CExtensionDescrParam::InternalizeL |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 CExtensionDescrParam* |
|
73 CExtensionDescrParam::InternalizeL(RReadStream& aReadStream) |
|
74 { |
|
75 TUint32 id = aReadStream.ReadUint32L(); |
|
76 CExtensionDescrParam* self = new (ELeave) CExtensionDescrParam(id); |
|
77 CleanupStack::PushL(self); |
|
78 |
|
79 TUint32 valueLength = aReadStream.ReadInt32L(); |
|
80 self->iValue = HBufC8::NewL(valueLength); |
|
81 TPtr8 valuePtr(self->iValue->Des()); |
|
82 aReadStream.ReadL(valuePtr, valueLength); |
|
83 CleanupStack::Pop(self); |
|
84 return self; |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CExtensionDescrParam::ExternalizeL |
|
89 // ----------------------------------------------------------------------------- |
|
90 // |
|
91 void CExtensionDescrParam::ExternalizeL(RWriteStream& aWriteStream) const |
|
92 { |
|
93 __ASSERT_ALWAYS(iValue != NULL, User::Leave(KErrNotFound)); |
|
94 |
|
95 aWriteStream.WriteUint32L(iID); |
|
96 aWriteStream.WriteInt32L(iValue->Length()); |
|
97 aWriteStream.WriteL(*iValue); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CExtensionDescrParam::ExternalizedSizeL |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 TUint CExtensionDescrParam::ExternalizedSizeL() const |
|
105 { |
|
106 __ASSERT_ALWAYS(iValue != NULL, User::Leave(KErrNotFound)); |
|
107 |
|
108 //CExtensionDescrParam::ExternalizeL writes descriptor's length as TInt32 |
|
109 const TInt KLengthFieldSize = sizeof(TInt32); |
|
110 return sizeof(iID) + KLengthFieldSize + iValue->Length(); |
|
111 } |
|
112 |
|
113 // ----------------------------------------------------------------------------- |
|
114 // CExtensionDescrParam::operator== |
|
115 // ----------------------------------------------------------------------------- |
|
116 // |
|
117 TBool CExtensionDescrParam::operator==(const CExtensionDescrParam& aParam) const |
|
118 { |
|
119 return (ID() == aParam.ID()) && (Value().Compare(aParam.Value()) == 0); |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CExtensionDescrParam::ID |
|
124 // ----------------------------------------------------------------------------- |
|
125 // |
|
126 TUint32 CExtensionDescrParam::ID() const |
|
127 { |
|
128 return iID; |
|
129 } |
|
130 |
|
131 // ----------------------------------------------------------------------------- |
|
132 // CExtensionDescrParam::Value |
|
133 // ----------------------------------------------------------------------------- |
|
134 // |
|
135 const TDesC8& CExtensionDescrParam::Value() const |
|
136 { |
|
137 if (iValue) |
|
138 { |
|
139 return *iValue; |
|
140 } |
|
141 return KNullDesC8; |
|
142 } |