|
1 /* |
|
2 * Copyright (c) 2006 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: Contains CNcdSearchNodeFolderProxy class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdsearchnodefolderproxy.h" |
|
20 #include "ncdnodemetadataproxy.h" |
|
21 #include "catalogsclientserver.h" |
|
22 #include "ncdnodemanagerproxy.h" |
|
23 #include "ncdoperationmanagerproxy.h" |
|
24 #include "ncdnodeidentifier.h" |
|
25 #include "catalogsdebug.h" |
|
26 #include "ncdnodefunctionids.h" |
|
27 #include "ncdnodeclassids.h" |
|
28 #include "catalogsinterfaceidentifier.h" |
|
29 #include "ncdloadnodeoperationproxy.h" |
|
30 #include "ncdnodeskinproxy.h" |
|
31 #include "ncdnodesearchimpl.h" |
|
32 #include "catalogsutils.h" |
|
33 #include "ncdutils.h" |
|
34 |
|
35 |
|
36 CNcdSearchNodeFolderProxy::CNcdSearchNodeFolderProxy( MCatalogsClientServer& aSession, |
|
37 TInt aHandle, |
|
38 CNcdNodeManagerProxy& aNodeManager, |
|
39 CNcdOperationManagerProxy& aOperationManager, |
|
40 CNcdFavoriteManagerProxy& aFavoriteManager ) |
|
41 : CNcdParentOfTransparentNodeProxy( aSession, aHandle, aNodeManager, aOperationManager, aFavoriteManager ) |
|
42 { |
|
43 } |
|
44 |
|
45 |
|
46 void CNcdSearchNodeFolderProxy::ConstructL() |
|
47 { |
|
48 CNcdParentOfTransparentNodeProxy::ConstructL(); |
|
49 } |
|
50 |
|
51 |
|
52 CNcdSearchNodeFolderProxy* CNcdSearchNodeFolderProxy::NewL( MCatalogsClientServer& aSession, |
|
53 TInt aHandle, |
|
54 CNcdNodeManagerProxy& aNodeManager, |
|
55 CNcdOperationManagerProxy& aOperationManager, |
|
56 CNcdFavoriteManagerProxy& aFavoriteManager ) |
|
57 { |
|
58 CNcdSearchNodeFolderProxy* self = |
|
59 CNcdSearchNodeFolderProxy::NewLC( |
|
60 aSession, aHandle, aNodeManager, aOperationManager, aFavoriteManager ); |
|
61 CleanupStack::Pop( self ); |
|
62 return self; |
|
63 } |
|
64 |
|
65 CNcdSearchNodeFolderProxy* CNcdSearchNodeFolderProxy::NewLC( MCatalogsClientServer& aSession, |
|
66 TInt aHandle, |
|
67 CNcdNodeManagerProxy& aNodeManager, |
|
68 CNcdOperationManagerProxy& aOperationManager, |
|
69 CNcdFavoriteManagerProxy& aFavoriteManager ) |
|
70 { |
|
71 CNcdSearchNodeFolderProxy* self = |
|
72 new( ELeave ) CNcdSearchNodeFolderProxy( |
|
73 aSession, aHandle, aNodeManager, aOperationManager, aFavoriteManager ); |
|
74 // Using PushL because the object does not have any references yet |
|
75 CleanupStack::PushL( self ); |
|
76 self->ConstructL(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 |
|
81 CNcdSearchNodeFolderProxy::~CNcdSearchNodeFolderProxy() |
|
82 { |
|
83 delete iSearchFilter; |
|
84 iSearchFilter = 0; |
|
85 } |
|
86 |
|
87 |
|
88 const CNcdSearchFilter& CNcdSearchNodeFolderProxy::SearchFilterL() const |
|
89 { |
|
90 if ( !iSearchFilter ) |
|
91 { |
|
92 User::Leave( KErrNotFound ); |
|
93 } |
|
94 return *iSearchFilter; |
|
95 } |
|
96 |
|
97 void CNcdSearchNodeFolderProxy::InternalizeNodeDataL( RReadStream& aStream ) |
|
98 { |
|
99 DLTRACEIN(("")); |
|
100 |
|
101 // First internalize parent data |
|
102 CNcdParentOfTransparentNodeProxy::InternalizeNodeDataL( aStream ); |
|
103 |
|
104 DLTRACE(("")); |
|
105 |
|
106 delete iSearchFilter; |
|
107 iSearchFilter = NULL; |
|
108 iSearchFilter = CNcdSearchFilter::NewL( aStream ); |
|
109 |
|
110 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
111 const MDesCArray& keywords = iSearchFilter->Keywords(); |
|
112 DLINFO(("Search filter: ")); |
|
113 for ( TInt i = 0; i < keywords.MdcaCount(); i++ ) |
|
114 { |
|
115 DLINFO((_L("%S"), &keywords.MdcaPoint( i ) )); |
|
116 } |
|
117 #endif |
|
118 |
|
119 DLTRACE(("")); |
|
120 |
|
121 DLTRACEOUT(("")); |
|
122 } |
|
123 |
|
124 |
|
125 MNcdLoadNodeOperation* CNcdSearchNodeFolderProxy::LoadChildrenL( TInt aIndex, |
|
126 TInt aSize, |
|
127 TNcdChildLoadMode aMode, |
|
128 MNcdLoadNodeOperationObserver& aObserver ) |
|
129 { |
|
130 DLTRACEIN((("this: %X"), this)); |
|
131 DASSERT( iSearchFilter ); |
|
132 |
|
133 if( aSize < 1 || aIndex < 0 || ( aMode == ELoadMetadata && aIndex + aSize > ChildCount() )) |
|
134 { |
|
135 // Nothing to be done |
|
136 DLERROR(( "Argument error. ChildCount: %d Given index: %d, size: %d", |
|
137 ChildCount(), aIndex, aSize )); |
|
138 DASSERT( EFalse ); |
|
139 User::Leave( KErrArgument ); |
|
140 } |
|
141 |
|
142 DLTRACE(( _L("Node: %S, %S"), &Namespace(), &Id() )); |
|
143 |
|
144 #ifdef CATALOGS_BUILD_CONFIG_DEBUG |
|
145 const MDesCArray& keywords = iSearchFilter->Keywords(); |
|
146 DLINFO(("Search filter: ")); |
|
147 for ( TInt i = 0; i < keywords.MdcaCount(); i++ ) |
|
148 { |
|
149 DLINFO((_L("%S"), &keywords.MdcaPoint( i ) )); |
|
150 } |
|
151 #endif |
|
152 |
|
153 CNcdLoadNodeOperationProxy* operation = |
|
154 OperationManager().CreateLoadNodeOperationL( *this, |
|
155 ETrue, // load children |
|
156 aSize, |
|
157 aIndex, |
|
158 1, |
|
159 aMode, |
|
160 iSearchFilter ); |
|
161 |
|
162 if( operation == NULL ) |
|
163 { |
|
164 DLTRACEOUT(("NULL")); |
|
165 return NULL; |
|
166 } |
|
167 |
|
168 CleanupReleasePushL( *operation ); |
|
169 operation->AddObserverL( this ); |
|
170 operation->AddObserverL( &aObserver ); |
|
171 CleanupStack::Pop( operation ); |
|
172 |
|
173 DLTRACEOUT(("")); |
|
174 |
|
175 return operation; |
|
176 } |
|
177 |
|
178 MNcdNode::TState CNcdSearchNodeFolderProxy::State() const |
|
179 { |
|
180 DLTRACEIN((_L("Node namespace=%S, id=%S"), &Namespace(), &Id() )); |
|
181 |
|
182 // Check if the link handle has been set, which means that also |
|
183 // link data has been internalized. Also, check if the metadata |
|
184 // exists, which means that metadata has also been internalized. |
|
185 if ( LinkHandleSet() |
|
186 && Metadata() != NULL ) |
|
187 { |
|
188 DLTRACEOUT(("Initialized")); |
|
189 return MNcdNode::EStateInitialized; |
|
190 } |
|
191 else |
|
192 { |
|
193 // Node has not been initialized. |
|
194 DLTRACEOUT(("Not initialized")); |
|
195 return MNcdNode::EStateNotInitialized; |
|
196 } |
|
197 } |
|
198 |
|
199 MNcdLoadNodeOperation* CNcdSearchNodeFolderProxy::LoadL( MNcdLoadNodeOperationObserver& aObserver ) |
|
200 { |
|
201 CNcdLoadNodeOperationProxy* operation = OperationManager().CreateLoadNodeOperationL( *this, |
|
202 EFalse, // don't load children |
|
203 0, // pagesize, meaningless in this case |
|
204 0, // pagestart, meaningless in this case |
|
205 0, // depth, meaningless in this case |
|
206 ELoadStructure, // meaningless in this case |
|
207 iSearchFilter ); |
|
208 CleanupReleasePushL( *operation ); |
|
209 |
|
210 operation->AddObserverL( this ); |
|
211 operation->AddObserverL( &aObserver ); |
|
212 CleanupStack::Pop( operation ); |
|
213 return operation; |
|
214 } |