|
1 /* |
|
2 * Copyright (c) 2005 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: "Light weight" SAP list. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <e32std.h> |
|
20 #include "cimpssapsettingslist.h" |
|
21 #include "cimpssapsettingslistitem.h" |
|
22 #include "TIMPSSAPSettingsListItemNameKey.h" |
|
23 |
|
24 // CONSTANTS |
|
25 const TInt KSettingsListGranurality = 5; ///< Granularity of the list. Usually there are just quite few servers. |
|
26 |
|
27 |
|
28 // ================= MEMBER FUNCTIONS ======================= |
|
29 |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CIMPSSAPSettingsList::NewL() |
|
33 // Two-phased constructor. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 EXPORT_C CIMPSSAPSettingsList* CIMPSSAPSettingsList::NewL() |
|
37 { |
|
38 return new ( ELeave ) CIMPSSAPSettingsList(); |
|
39 } |
|
40 |
|
41 // ----------------------------------------------------------------------------- |
|
42 // CIMPSSAPSettingsList::NewLC() |
|
43 // Two-phased constructor. |
|
44 // ----------------------------------------------------------------------------- |
|
45 // |
|
46 EXPORT_C CIMPSSAPSettingsList* CIMPSSAPSettingsList::NewLC() |
|
47 { |
|
48 CIMPSSAPSettingsList* self = new ( ELeave ) CIMPSSAPSettingsList(); |
|
49 CleanupStack::PushL( self ); |
|
50 return self; |
|
51 } |
|
52 |
|
53 |
|
54 // ----------------------------------------------------------------------------- |
|
55 // CIMPSSAPSettingsList::~CIMPSSAPSettingsList() |
|
56 // Destructor |
|
57 // ----------------------------------------------------------------------------- |
|
58 // |
|
59 EXPORT_C CIMPSSAPSettingsList::~CIMPSSAPSettingsList() |
|
60 { |
|
61 ResetAndDestroy(); |
|
62 } |
|
63 |
|
64 |
|
65 // ----------------------------------------------------------------------------- |
|
66 // CIMPSSAPSettingsList::CIMPSSAPSettingsList() |
|
67 // C++ default constructor can NOT contain any code, that |
|
68 // might leave. |
|
69 // ----------------------------------------------------------------------------- |
|
70 // |
|
71 CIMPSSAPSettingsList::CIMPSSAPSettingsList() |
|
72 : CArrayPtrSeg< CIMPSSAPSettingsListItem >( KSettingsListGranurality ) |
|
73 { |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 |
|
79 // ----------------------------------------------------------------------------- |
|
80 // CIMPSSAPSettingsList::IndexForUid() |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 EXPORT_C TInt CIMPSSAPSettingsList::IndexForUid( TUint32 aUid ) const |
|
84 { |
|
85 TInt count( Count() ); |
|
86 TInt index = KErrNotFound; |
|
87 |
|
88 for ( TInt ii( 0 ); ii < count; ii++ ) |
|
89 { |
|
90 if ( UidForIndex( ii ) == aUid ) |
|
91 { |
|
92 index = ii; |
|
93 break; |
|
94 } |
|
95 } |
|
96 |
|
97 return index; |
|
98 } |
|
99 |
|
100 |
|
101 // ----------------------------------------------------------------------------- |
|
102 // CIMPSSAPSettingsList::UidForIndex() |
|
103 // ----------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C TUint32 CIMPSSAPSettingsList::UidForIndex( TInt aIndex ) const |
|
106 { |
|
107 return At( aIndex )->Uid(); |
|
108 } |
|
109 |
|
110 |
|
111 // ----------------------------------------------------------------------------- |
|
112 // CIMPSSAPSettingsList::ListItemForUid() |
|
113 // ----------------------------------------------------------------------------- |
|
114 // |
|
115 EXPORT_C const CIMPSSAPSettingsListItem* CIMPSSAPSettingsList::ListItemForUid( TUint32 aUid ) const |
|
116 { |
|
117 TInt index = IndexForUid( aUid ); |
|
118 CIMPSSAPSettingsListItem* ptr = NULL; |
|
119 |
|
120 if ( index != KErrNotFound ) |
|
121 { |
|
122 ptr = At( index ); |
|
123 } |
|
124 |
|
125 return ptr; |
|
126 } |
|
127 |
|
128 |
|
129 // ----------------------------------------------------------------------------- |
|
130 // CIMPSSAPSettingsList::FindNameL() |
|
131 // ----------------------------------------------------------------------------- |
|
132 // |
|
133 EXPORT_C TInt CIMPSSAPSettingsList::FindNameL( const TDesC& aName, TInt& aIndex ) const |
|
134 { |
|
135 CIMPSSAPSettingsListItem* item = CIMPSSAPSettingsListItem::NewLC( aName, 0, EIMPSIMAccessGroup ); |
|
136 TIMPSSAPSettingsListItemNameKey key; |
|
137 TInt ret( FindIsq( item, key, aIndex ) ); |
|
138 CleanupStack::PopAndDestroy(); //item |
|
139 return ret; |
|
140 } |
|
141 |
|
142 |
|
143 // ----------------------------------------------------------------------------- |
|
144 // CIMPSSAPSettingsList::Delete() |
|
145 // Overides default delete from CArrayPtrSeg. |
|
146 // ----------------------------------------------------------------------------- |
|
147 // |
|
148 EXPORT_C void CIMPSSAPSettingsList::Delete( TInt aIndex ) |
|
149 { |
|
150 delete At( aIndex ); |
|
151 CArrayPtrSeg< CIMPSSAPSettingsListItem >::Delete( aIndex ); |
|
152 } |
|
153 |
|
154 |
|
155 // ----------------------------------------------------------------------------- |
|
156 // CIMPSSAPSettingsList::Delete() |
|
157 // Overides default delete from CArrayPtrSeg. |
|
158 // ----------------------------------------------------------------------------- |
|
159 // |
|
160 EXPORT_C void CIMPSSAPSettingsList::Delete( TInt aIndex, TInt aCount ) |
|
161 { |
|
162 for ( TInt ii( 0 ); ii < aCount; ii++ ) |
|
163 { |
|
164 delete At( aIndex + ii ); |
|
165 CArrayPtrSeg< CIMPSSAPSettingsListItem >::Delete( aIndex + ii ); |
|
166 } |
|
167 } |
|
168 |
|
169 |
|
170 // ----------------------------------------------------------------------------- |
|
171 // CIMPSSAPSettingsList::MdcaCount() |
|
172 // ----------------------------------------------------------------------------- |
|
173 // |
|
174 EXPORT_C TInt CIMPSSAPSettingsList::MdcaCount() const |
|
175 { |
|
176 return Count(); |
|
177 } |
|
178 |
|
179 |
|
180 // ----------------------------------------------------------------------------- |
|
181 // CIMPSSAPSettingsList::MdcaPoint() |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 EXPORT_C TPtrC CIMPSSAPSettingsList::MdcaPoint( TInt aIndex ) const |
|
185 { |
|
186 return TPtrC( At( aIndex )->Name() ); |
|
187 } |
|
188 |
|
189 |
|
190 // End of File |
|
191 |