|
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 CNcdNodeSearch class implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "ncdnodesearchimpl.h" |
|
20 #include "ncdnodeproxy.h" |
|
21 #include "ncdoperationimpl.h" |
|
22 #include "ncdnodeidentifier.h" |
|
23 #include "catalogsinterfaceidentifier.h" |
|
24 #include "catalogsutils.h" |
|
25 #include "catalogsdebug.h" |
|
26 #include "ncdloadnodeoperationproxy.h" |
|
27 #include "ncdoperationmanagerproxy.h" |
|
28 #include "ncdnodemanagerproxy.h" |
|
29 #include "ncdsearchrootnodeproxy.h" |
|
30 |
|
31 |
|
32 CNcdNodeSearch::CNcdNodeSearch( |
|
33 CNcdNodeProxy& aNode, |
|
34 CNcdOperationManagerProxy& aOperationManager ) |
|
35 : CCatalogsInterfaceBase( &aNode ), |
|
36 iNode( aNode ), |
|
37 iOperationManager( aOperationManager ) |
|
38 { |
|
39 } |
|
40 |
|
41 |
|
42 void CNcdNodeSearch::ConstructL() |
|
43 { |
|
44 DLTRACEIN(("")); |
|
45 // Register the interface |
|
46 MNcdNodeSearch* interface( this ); |
|
47 AddInterfaceL( |
|
48 CCatalogsInterfaceIdentifier::NewL( interface, this, MNcdNodeSearch::KInterfaceUid ) ); |
|
49 } |
|
50 |
|
51 |
|
52 CNcdNodeSearch* CNcdNodeSearch::NewL( |
|
53 CNcdNodeProxy& aNode, |
|
54 CNcdOperationManagerProxy& aOperationManager ) |
|
55 { |
|
56 CNcdNodeSearch* self = |
|
57 CNcdNodeSearch::NewLC( aNode, aOperationManager ); |
|
58 CleanupStack::Pop( self ); |
|
59 return self; |
|
60 } |
|
61 |
|
62 CNcdNodeSearch* CNcdNodeSearch::NewLC( |
|
63 CNcdNodeProxy& aNode, |
|
64 CNcdOperationManagerProxy& aOperationManager ) |
|
65 { |
|
66 CNcdNodeSearch* self = |
|
67 new( ELeave ) CNcdNodeSearch( aNode, aOperationManager ); |
|
68 // Using PushL because the object does not have any references yet |
|
69 CleanupStack::PushL( self ); |
|
70 self->ConstructL(); |
|
71 return self; |
|
72 } |
|
73 |
|
74 |
|
75 CNcdNodeSearch::~CNcdNodeSearch() |
|
76 { |
|
77 DLTRACEIN(("")) |
|
78 // Remove interfaces implemented by this class from the interface list. |
|
79 // So, the interface list is up to date when this class object is deleted. |
|
80 RemoveInterface( MNcdNodeSearch::KInterfaceUid ); |
|
81 |
|
82 |
|
83 // Delete member variables here |
|
84 // Do not delete node and operation manager because |
|
85 // this object does not own them. |
|
86 } |
|
87 |
|
88 |
|
89 // MNcdNodeSearch functions |
|
90 |
|
91 MNcdSearchOperation* CNcdNodeSearch::SearchL( MNcdLoadNodeOperationObserver& aObserver, |
|
92 MNcdSearchFilter& aSearchFilter ) |
|
93 { |
|
94 DLTRACEIN(("")); |
|
95 |
|
96 if ( aSearchFilter.Keywords().MdcaCount() < 1 ) |
|
97 { |
|
98 DLERROR(("Error, no keywords in search!")); |
|
99 DASSERT( 0 ); |
|
100 User::Leave( KErrArgument ); |
|
101 } |
|
102 // make sure that search root is created |
|
103 CNcdSearchRootNodeProxy* searchRoot = &iNode.NodeManager().SearchRootNodeL(); |
|
104 CNcdLoadNodeOperationProxy* operation = iOperationManager.CreateLoadNodeOperationL( iNode, |
|
105 EFalse, // don't load children |
|
106 0, // pagesize, meaningless in this case |
|
107 0, // pagestart, meaningless in this case |
|
108 0, // depth, meaningless in this case |
|
109 ELoadStructure, // meaningless in this case |
|
110 &aSearchFilter ); |
|
111 CleanupReleasePushL( *operation ); |
|
112 // Search root is added as an observer here to make it |
|
113 // update once the op is complete. |
|
114 operation->AddObserverL( searchRoot ); |
|
115 operation->AddObserverL( &iNode ); |
|
116 operation->AddObserverL( &aObserver ); |
|
117 CleanupStack::Pop( operation ); |
|
118 return operation; |
|
119 } |
|
120 |
|
121 |
|
122 |
|
123 // Other functions |
|
124 |
|
125 CNcdOperationManagerProxy& CNcdNodeSearch::OperationManager() const |
|
126 { |
|
127 return iOperationManager; |
|
128 } |
|
129 |
|
130 |
|
131 CNcdNodeProxy& CNcdNodeSearch::Node() const |
|
132 { |
|
133 return iNode; |
|
134 } |