|
1 /* |
|
2 * Copyright (c) 2002-2004 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: server common implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 // INCLUDE FILES |
|
21 #include "SearchLeaf.h" |
|
22 #include <e32std.h> |
|
23 #include <e32base.h> |
|
24 #include <f32file.h> |
|
25 |
|
26 // EXTERNAL DATA STRUCTURES |
|
27 |
|
28 |
|
29 // EXTERNAL FUNCTION PROTOTYPES |
|
30 |
|
31 |
|
32 // CONSTANTS |
|
33 |
|
34 |
|
35 // MACROS |
|
36 |
|
37 |
|
38 // LOCAL CONSTANTS AND MACROS |
|
39 |
|
40 |
|
41 // MODULE DATA STRUCTURES |
|
42 |
|
43 |
|
44 // LOCAL FUNCTION PROTOTYPES |
|
45 |
|
46 |
|
47 // FORWARD DECLARATIONS |
|
48 |
|
49 |
|
50 // ============================= LOCAL FUNCTIONS =============================== |
|
51 |
|
52 |
|
53 |
|
54 // ============================ MEMBER FUNCTIONS =============================== |
|
55 |
|
56 |
|
57 // ----------------------------------------------------------------------------- |
|
58 // CSearchLeaf::CSearchLeaf |
|
59 // C++ default constructor can NOT contain any code, that |
|
60 // might leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CSearchLeaf::CSearchLeaf( CSearchLeaf*& aRoot ) : iRoot(aRoot) |
|
64 { |
|
65 } |
|
66 |
|
67 // ----------------------------------------------------------------------------- |
|
68 // CPair::ConstructL |
|
69 // Symbian 2nd phase constructor can leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CSearchLeaf::ConstructL( const TDesC& aFolderName ) |
|
73 { |
|
74 iFolderName = aFolderName.AllocL(); |
|
75 } |
|
76 |
|
77 // Destructor |
|
78 CSearchLeaf::~CSearchLeaf( void ) |
|
79 { |
|
80 delete iFolderName; |
|
81 iFolderName = NULL; |
|
82 iRoot = NULL; |
|
83 iLeafList.ResetAndDestroy(); |
|
84 iLeafList.Close(); |
|
85 } |
|
86 |
|
87 // ----------------------------------------------------------------------------- |
|
88 // CSearchLeaf::NewL |
|
89 // Two-phased constructor. |
|
90 // ----------------------------------------------------------------------------- |
|
91 // |
|
92 CSearchLeaf* CSearchLeaf::NewL( CSearchLeaf*& aRoot , const TDesC& aFolderName ) |
|
93 { |
|
94 CSearchLeaf* self = NewLC( aRoot , aFolderName ); |
|
95 CleanupStack::Pop(self); |
|
96 return self; |
|
97 } |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CSearchLeaf::NewLC |
|
101 // Two-phased constructor. |
|
102 // ----------------------------------------------------------------------------- |
|
103 // |
|
104 CSearchLeaf* CSearchLeaf::NewLC( CSearchLeaf*& aRoot , const TDesC& aFolderName ) |
|
105 { |
|
106 CSearchLeaf* self = new ( ELeave ) CSearchLeaf( aRoot ); |
|
107 CleanupStack::PushL( self ); |
|
108 self->ConstructL( aFolderName ); |
|
109 return self; |
|
110 } |
|
111 |
|
112 // ----------------------------------------------------------------------------- |
|
113 // CSearchLeaf::SetLeafL |
|
114 // ----------------------------------------------------------------------------- |
|
115 // |
|
116 void CSearchLeaf::SetLeafL( CDir*& aLeaf ) |
|
117 { |
|
118 CSearchLeaf* leaf = NULL; |
|
119 CSearchLeaf* root = this; |
|
120 TInt i = 0; |
|
121 for ( ; i < aLeaf->Count() ; i++ ) |
|
122 { |
|
123 leaf = CSearchLeaf::NewL( root , ( *aLeaf )[i].iName ); |
|
124 CleanupStack::PushL( leaf ); |
|
125 User::LeaveIfError( iLeafList.Append( leaf ) ); |
|
126 CleanupStack::Pop(leaf); //leaf |
|
127 } |
|
128 } |
|
129 |
|
130 // ----------------------------------------------------------------------------- |
|
131 // CSearchLeaf::RemoveLeaf |
|
132 // ----------------------------------------------------------------------------- |
|
133 // |
|
134 void CSearchLeaf::RemoveLeaf( CSearchLeaf*& aLeaf ) |
|
135 { |
|
136 TInt index = 0; |
|
137 index = iLeafList.Find( aLeaf ); |
|
138 iLeafList.Remove( index ); |
|
139 iLeafList.Compress(); |
|
140 } |
|
141 |
|
142 // ----------------------------------------------------------------------------- |
|
143 // CSearchLeaf::FolderName |
|
144 // ----------------------------------------------------------------------------- |
|
145 // |
|
146 const TDesC& CSearchLeaf::FolderName() |
|
147 { |
|
148 return (*iFolderName); |
|
149 } |
|
150 |
|
151 // ----------------------------------------------------------------------------- |
|
152 // CSearchLeaf::Root |
|
153 // ----------------------------------------------------------------------------- |
|
154 // |
|
155 CSearchLeaf*& CSearchLeaf::Root() |
|
156 { |
|
157 return iRoot; |
|
158 } |
|
159 |
|
160 // ----------------------------------------------------------------------------- |
|
161 // CSearchLeaf::LeafList |
|
162 // ----------------------------------------------------------------------------- |
|
163 // |
|
164 RPointerArray<CSearchLeaf>& CSearchLeaf::LeafList() |
|
165 { |
|
166 return iLeafList; |
|
167 } |
|
168 |
|
169 |
|
170 // End of File |