85
|
1 |
/*
|
|
2 |
* Copyright (c) 2008 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: Definition of entry attribute
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
// INCLUDE FILES
|
|
19 |
#include <s32mem.h>
|
|
20 |
#include "caarraycleanup.inl"
|
|
21 |
#include "caentryattribute.h"
|
|
22 |
|
|
23 |
// ================= MEMBER FUNCTIONS =======================
|
|
24 |
|
|
25 |
// ---------------------------------------------------------
|
|
26 |
// CCaEntryAttribute::~CMenuItemAttr
|
|
27 |
// ---------------------------------------------------------
|
|
28 |
//
|
|
29 |
CCaEntryAttribute::~CCaEntryAttribute()
|
|
30 |
{
|
|
31 |
iName.Close();
|
|
32 |
iValue.Close();
|
|
33 |
}
|
|
34 |
|
98
|
35 |
#ifdef COVERAGE_MEASUREMENT
|
|
36 |
#pragma CTC SKIP
|
|
37 |
#endif //COVERAGE_MEASUREMENT (only NewLC used in code)
|
85
|
38 |
// ---------------------------------------------------------
|
|
39 |
// CCaEntryAttribute::NewL
|
|
40 |
// ---------------------------------------------------------
|
|
41 |
//
|
|
42 |
EXPORT_C CCaEntryAttribute* CCaEntryAttribute::NewL( const TDesC& aName )
|
|
43 |
{
|
|
44 |
CCaEntryAttribute* attr = NewLC( aName );
|
|
45 |
CleanupStack::Pop( attr );
|
|
46 |
return attr;
|
|
47 |
}
|
98
|
48 |
#ifdef COVERAGE_MEASUREMENT
|
|
49 |
#pragma CTC ENDSKIP
|
|
50 |
#endif //COVERAGE_MEASUREMENT
|
85
|
51 |
|
|
52 |
// ---------------------------------------------------------
|
|
53 |
// CCaEntryAttribute::NewLC
|
|
54 |
// ---------------------------------------------------------
|
|
55 |
//
|
|
56 |
EXPORT_C CCaEntryAttribute* CCaEntryAttribute::NewLC( const TDesC& aName )
|
|
57 |
{
|
|
58 |
CCaEntryAttribute* attr = new ( ELeave ) CCaEntryAttribute();
|
|
59 |
CleanupStack::PushL( attr );
|
|
60 |
attr->ConstructL( aName );
|
|
61 |
return attr;
|
|
62 |
}
|
|
63 |
|
|
64 |
// ---------------------------------------------------------
|
|
65 |
// CCaEntryAttribute::ConstructL
|
|
66 |
// ---------------------------------------------------------
|
|
67 |
//
|
|
68 |
void CCaEntryAttribute::ConstructL( const TDesC& aName )
|
|
69 |
{
|
|
70 |
iName.CreateL( aName );
|
|
71 |
}
|
|
72 |
|
|
73 |
// ---------------------------------------------------------
|
|
74 |
// CCaEntryAttribute::ConstructL
|
|
75 |
// ---------------------------------------------------------
|
|
76 |
//
|
|
77 |
EXPORT_C void CCaEntryAttribute::SetValueL( const TDesC& aName )
|
|
78 |
{
|
|
79 |
if( iValue.Length() > 0 )
|
|
80 |
{
|
|
81 |
iValue.Close();
|
|
82 |
}
|
|
83 |
iValue.CreateL( aName );
|
|
84 |
}
|
|
85 |
|
|
86 |
// ---------------------------------------------------------------------------
|
|
87 |
// CCaEntryAttribute::ExternalizeL
|
|
88 |
// ---------------------------------------------------------------------------
|
|
89 |
//
|
|
90 |
void CCaEntryAttribute::ExternalizeL( RWriteStream& aStream ) const
|
|
91 |
{
|
|
92 |
aStream.WriteUint32L( iName.Length() );
|
|
93 |
aStream.WriteL( iName, iName.Length() );
|
|
94 |
aStream.WriteUint32L( iValue.Length() );
|
|
95 |
aStream.WriteL( iValue, iValue.Length() );
|
|
96 |
aStream.CommitL();
|
|
97 |
}
|
|
98 |
|
|
99 |
// ---------------------------------------------------------------------------
|
|
100 |
// CCaEntryAttribute::InternalizeL
|
|
101 |
// ---------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
void CCaEntryAttribute::InternalizeL( RReadStream& aStream )
|
|
104 |
{
|
|
105 |
TUint length = aStream.ReadUint32L();
|
|
106 |
iName.Close();
|
|
107 |
iName.CreateL( length );
|
|
108 |
aStream.ReadL( iName, length );
|
|
109 |
length = aStream.ReadUint32L();
|
|
110 |
iValue.Close();
|
|
111 |
iValue.CreateL( length );
|
|
112 |
aStream.ReadL( iValue, length );
|
|
113 |
}
|
|
114 |
|
|
115 |
// ---------------------------------------------------------
|
|
116 |
// RMenuSrvAttrArray::Find
|
|
117 |
// ---------------------------------------------------------
|
|
118 |
//
|
107
|
119 |
EXPORT_C TBool RCaEntryAttrArray::Find( const TDesC& aName, TDes& aAttrVal ) const
|
85
|
120 |
{
|
|
121 |
for( TInt i = 0; i < Count(); i++ )
|
|
122 |
{
|
|
123 |
if( aName.Compare( operator[]( i )->Name() ) == KErrNone )
|
|
124 |
{
|
|
125 |
aAttrVal = operator[]( i )->Value();
|
|
126 |
return ETrue;
|
|
127 |
}
|
|
128 |
}
|
|
129 |
return EFalse;
|
|
130 |
}
|
|
131 |
|
|
132 |
// ---------------------------------------------------------
|
92
|
133 |
// RMenuSrvAttrArray::Find
|
|
134 |
// ---------------------------------------------------------
|
|
135 |
//
|
107
|
136 |
EXPORT_C TBool RCaEntryAttrArray::Find( const TDesC& aName, TPtrC& aAttrVal ) const
|
92
|
137 |
{
|
|
138 |
for( TInt i = 0; i < Count(); i++ )
|
|
139 |
{
|
|
140 |
if( aName.Compare( operator[]( i )->Name() ) == KErrNone )
|
|
141 |
{
|
|
142 |
aAttrVal.Set( operator[]( i )->Value() );
|
|
143 |
return ETrue;
|
|
144 |
}
|
|
145 |
}
|
|
146 |
return EFalse;
|
|
147 |
}
|
|
148 |
|
|
149 |
// ---------------------------------------------------------
|
85
|
150 |
// RCaEntryAttrArray::Exist
|
|
151 |
// ---------------------------------------------------------
|
|
152 |
//
|
107
|
153 |
EXPORT_C TBool RCaEntryAttrArray::Exist( const TDesC& aName ) const
|
85
|
154 |
{
|
|
155 |
for( TInt i = 0; i < Count(); i++ )
|
|
156 |
{
|
|
157 |
if( aName.Compare( operator[]( i )->Name() ) == KErrNone )
|
|
158 |
{
|
|
159 |
return ETrue;
|
|
160 |
}
|
|
161 |
}
|
|
162 |
return EFalse;
|
|
163 |
}
|
|
164 |
|
|
165 |
// ---------------------------------------------------------
|
|
166 |
// RCaEntryAttrArray::RemoveAttribute
|
|
167 |
// ---------------------------------------------------------
|
|
168 |
//
|
|
169 |
EXPORT_C void RCaEntryAttrArray::RemoveAttribute( const TDesC& aAttrName )
|
|
170 |
{
|
|
171 |
for( TInt i = 0; i < Count(); i++ )
|
|
172 |
{
|
|
173 |
if( aAttrName == operator[]( i )->Name() )
|
|
174 |
{
|
|
175 |
delete operator[]( i );
|
|
176 |
Remove( i );
|
|
177 |
break;
|
|
178 |
}
|
|
179 |
}
|
|
180 |
}
|
|
181 |
|
|
182 |
// ---------------------------------------------------------------------------
|
|
183 |
// RCaEntryAttrArray::ExternalizeL
|
|
184 |
// ---------------------------------------------------------------------------
|
|
185 |
//
|
|
186 |
void RCaEntryAttrArray::ExternalizeL( RWriteStream& aStream ) const
|
|
187 |
{
|
|
188 |
aStream.WriteUint16L( Count() );
|
|
189 |
for( TInt i = 0; i < Count(); i++ )
|
|
190 |
{
|
|
191 |
operator[]( i )->ExternalizeL( aStream );
|
|
192 |
}
|
|
193 |
}
|
|
194 |
|
|
195 |
// ---------------------------------------------------------------------------
|
|
196 |
// RCaEntryAttrArray::InternalizeL
|
|
197 |
// ---------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
void RCaEntryAttrArray::InternalizeL( RReadStream& aStream )
|
|
200 |
{
|
|
201 |
ResetAndDestroy();
|
|
202 |
TUint count = aStream.ReadUint16L();
|
|
203 |
for( TInt i = 0; i < count; i++ )
|
|
204 |
{
|
|
205 |
CCaEntryAttribute* attr = CCaEntryAttribute::NewLC( KNullDesC );
|
|
206 |
attr->InternalizeL( aStream );
|
|
207 |
AppendL( attr );
|
|
208 |
CleanupStack::Pop( attr );
|
|
209 |
}
|
|
210 |
}
|
|
211 |
|
|
212 |
// End of File
|