|
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 : extensiondescrarrayparam.cpp |
|
15 // Part of : SIP Profile |
|
16 // implementation |
|
17 // Version : 1.0 |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 // INCLUDE FILES |
|
23 #include "extensiondescrarrayparam.h" |
|
24 #include "sipconcreteprofile.h" |
|
25 |
|
26 // ============================ MEMBER FUNCTIONS =============================== |
|
27 |
|
28 // ----------------------------------------------------------------------------- |
|
29 // CExtensionDescrArrayParam::NewLC |
|
30 // ----------------------------------------------------------------------------- |
|
31 // |
|
32 CExtensionDescrArrayParam* |
|
33 CExtensionDescrArrayParam::NewLC(TUint32 aID, const MDesC8Array& aValue) |
|
34 { |
|
35 CExtensionDescrArrayParam* self = |
|
36 new (ELeave) CExtensionDescrArrayParam(aID); |
|
37 CleanupStack::PushL(self); |
|
38 self->ConstructL(aValue); |
|
39 return self; |
|
40 } |
|
41 |
|
42 // ----------------------------------------------------------------------------- |
|
43 // CExtensionDescrArrayParam::CExtensionDescrArrayParam |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 CExtensionDescrArrayParam::CExtensionDescrArrayParam(TUint32 aID) : |
|
47 iID(aID), |
|
48 iValue(NULL) |
|
49 { |
|
50 } |
|
51 |
|
52 // ----------------------------------------------------------------------------- |
|
53 // CExtensionDescrArrayParam::ConstructL |
|
54 // ----------------------------------------------------------------------------- |
|
55 // |
|
56 void CExtensionDescrArrayParam::ConstructL(const MDesC8Array& aValue) |
|
57 { |
|
58 iValue = CSIPConcreteProfile::CopyDesArrayL(aValue); |
|
59 } |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CExtensionDescrArrayParam::~CExtensionDescrArrayParam |
|
63 // ----------------------------------------------------------------------------- |
|
64 // |
|
65 CExtensionDescrArrayParam::~CExtensionDescrArrayParam() |
|
66 { |
|
67 if (iValue) |
|
68 { |
|
69 iValue->Reset(); |
|
70 } |
|
71 delete iValue; |
|
72 } |
|
73 |
|
74 // ----------------------------------------------------------------------------- |
|
75 // CExtensionDescrArrayParam::InternalizeL |
|
76 // ----------------------------------------------------------------------------- |
|
77 // |
|
78 CExtensionDescrArrayParam* |
|
79 CExtensionDescrArrayParam::InternalizeL(RReadStream& aReadStream) |
|
80 { |
|
81 TUint32 id = aReadStream.ReadUint32L(); |
|
82 CExtensionDescrArrayParam* self = |
|
83 new (ELeave) CExtensionDescrArrayParam(id); |
|
84 CleanupStack::PushL(self); |
|
85 self->iValue = CSIPConcreteProfile::InternalizeDesArrayL(aReadStream); |
|
86 CleanupStack::Pop(self); |
|
87 return self; |
|
88 } |
|
89 |
|
90 // ----------------------------------------------------------------------------- |
|
91 // CExtensionDescrArrayParam::ExternalizeL |
|
92 // ----------------------------------------------------------------------------- |
|
93 // |
|
94 void CExtensionDescrArrayParam::ExternalizeL(RWriteStream& aWriteStream) const |
|
95 { |
|
96 aWriteStream.WriteUint32L(iID); |
|
97 CSIPConcreteProfile::ExternalizeDesArrayL(*iValue, aWriteStream); |
|
98 } |
|
99 |
|
100 // ----------------------------------------------------------------------------- |
|
101 // CExtensionDescrArrayParam::ExternalizedSizeL |
|
102 // CSIPConcreteProfile::ExternalizeDesArrayL writes the amount of elements in |
|
103 // the array as UInt32 and every descriptor's length as TInt32. |
|
104 // ----------------------------------------------------------------------------- |
|
105 // |
|
106 TUint CExtensionDescrArrayParam::ExternalizedSizeL() const |
|
107 { |
|
108 const TInt KElementCountSize = sizeof(TUint32); |
|
109 const TInt KLengthFieldSize = sizeof(TInt32); |
|
110 |
|
111 TUint size = sizeof(iID) + KElementCountSize; |
|
112 |
|
113 for (TInt i = 0; i < iValue->Count(); ++i) |
|
114 { |
|
115 const TPtrC8& value = (*iValue)[i]; |
|
116 size = size + KLengthFieldSize + value.Length(); |
|
117 } |
|
118 |
|
119 return size; |
|
120 } |
|
121 |
|
122 // ----------------------------------------------------------------------------- |
|
123 // CExtensionDescrArrayParam::operator== |
|
124 // Check that every descriptor element in aParam, is also present in this |
|
125 // object. The elements don't need to be in the same order in the array. |
|
126 // ----------------------------------------------------------------------------- |
|
127 // |
|
128 TBool CExtensionDescrArrayParam::operator==( |
|
129 const CExtensionDescrArrayParam& aParam) const |
|
130 { |
|
131 if ( !(ID() == aParam.ID() && |
|
132 Value().MdcaCount() == aParam.Value().MdcaCount() ) ) |
|
133 { |
|
134 return EFalse; |
|
135 } |
|
136 |
|
137 for (TInt i = 0; i < aParam.Value().MdcaCount(); ++i) |
|
138 { |
|
139 TInt pos(0); |
|
140 |
|
141 if (iValue->Find(aParam.Value().MdcaPoint(i), pos) != 0) |
|
142 { |
|
143 //Element present only in the other object |
|
144 return EFalse; |
|
145 } |
|
146 } |
|
147 |
|
148 return ETrue; |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CExtensionDescrArrayParam::ID |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 TUint32 CExtensionDescrArrayParam::ID() const |
|
156 { |
|
157 return iID; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CExtensionDescrArrayParam::Value |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 const MDesC8Array& CExtensionDescrArrayParam::Value() const |
|
165 { |
|
166 return *iValue; |
|
167 } |