|
1 /* |
|
2 * Copyright (c) 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: Presence search transactions. |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include "CPEngSearchTransaction2Imp.h" |
|
20 #include "CPEngAsyncOperation.h" |
|
21 #include "CPEngNWSessionSlotStorageProxy.h" |
|
22 #include "CPEngSearchControl.h" |
|
23 |
|
24 #include <CPEngNWSessionSlotID2.h> |
|
25 #include <CPEngSearchCriteria2.h> |
|
26 |
|
27 |
|
28 |
|
29 // ============================ MEMBER FUNCTIONS =============================== |
|
30 |
|
31 // ----------------------------------------------------------------------------- |
|
32 // CPEngSearchTransaction2Imp::NewL() |
|
33 // Two-phased constructor. |
|
34 // ----------------------------------------------------------------------------- |
|
35 // |
|
36 CPEngSearchTransaction2Imp* CPEngSearchTransaction2Imp::NewL( |
|
37 CPEngSearchTransaction2& aInterface, |
|
38 TInt aPriority, |
|
39 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
40 { |
|
41 CPEngSearchTransaction2Imp* self = new ( ELeave ) |
|
42 CPEngSearchTransaction2Imp( aInterface, aPriority ); |
|
43 CleanupStack::PushL( self ); |
|
44 self->ConstructL( aNWSessionSlotID ); |
|
45 CleanupStack::Pop( self ); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 |
|
51 // Destructor |
|
52 CPEngSearchTransaction2Imp::~CPEngSearchTransaction2Imp() |
|
53 { |
|
54 delete iSearchCntrl; //Deleting search control cancels also it |
|
55 delete iUsedSlot; |
|
56 delete iUsedSlotId; |
|
57 } |
|
58 |
|
59 |
|
60 |
|
61 // ----------------------------------------------------------------------------- |
|
62 // CPEngSearchTransaction2Imp::CPEngSearchTransaction2Imp |
|
63 // C++ default constructor can NOT contain any code, that |
|
64 // might leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CPEngSearchTransaction2Imp::CPEngSearchTransaction2Imp( |
|
68 CPEngSearchTransaction2& aInterface, |
|
69 TInt aPriority ) |
|
70 : iInterface( aInterface ), |
|
71 iCActivePriority( aPriority ) |
|
72 { |
|
73 } |
|
74 |
|
75 |
|
76 |
|
77 // ----------------------------------------------------------------------------- |
|
78 // CPEngSearchTransaction2Imp::ConstructL() |
|
79 // ----------------------------------------------------------------------------- |
|
80 // |
|
81 void CPEngSearchTransaction2Imp::ConstructL( |
|
82 const CPEngNWSessionSlotID2& aNWSessionSlotID ) |
|
83 { |
|
84 iUsedSlot = CPEngNWSessionSlotStorageProxy::NewL( aNWSessionSlotID ); |
|
85 iUsedSlotId = aNWSessionSlotID.CloneL(); |
|
86 } |
|
87 |
|
88 |
|
89 // ----------------------------------------------------------------------------- |
|
90 // CPEngSearchTransaction2Imp::IsSearchFromNetworkActive() |
|
91 // ----------------------------------------------------------------------------- |
|
92 // |
|
93 TBool CPEngSearchTransaction2Imp::IsSearchFromNetworkActive() const |
|
94 { |
|
95 return ( iSearchCntrl != NULL ); // CSI: 64 # |
|
96 } |
|
97 |
|
98 |
|
99 // ----------------------------------------------------------------------------- |
|
100 // CPEngSearchTransaction2Imp::SearchFromNetwork() |
|
101 // ----------------------------------------------------------------------------- |
|
102 // |
|
103 TInt CPEngSearchTransaction2Imp::SearchFromNetwork( |
|
104 CPEngSearchCriteria2*& aCriteria, |
|
105 TInt aSearchLimit, |
|
106 MPEngSearchTransactionObserver2& aObserver ) |
|
107 { |
|
108 RPointerArray<CPEngSearchCriteria2> adapter; |
|
109 TInt err = adapter.Append( aCriteria ); |
|
110 if ( err == KErrNone ) |
|
111 { |
|
112 err = SearchFromNetwork( adapter, aSearchLimit, aObserver ); |
|
113 } |
|
114 |
|
115 if ( err == KErrNone ) |
|
116 { |
|
117 aCriteria = NULL; |
|
118 } |
|
119 |
|
120 adapter.Close(); |
|
121 return err; |
|
122 } |
|
123 |
|
124 |
|
125 // ----------------------------------------------------------------------------- |
|
126 // CPEngSearchTransaction2Imp::SearchFromNetwork() |
|
127 // ----------------------------------------------------------------------------- |
|
128 // |
|
129 TInt CPEngSearchTransaction2Imp::SearchFromNetwork( |
|
130 RPointerArray< CPEngSearchCriteria2 >& aCriterias, |
|
131 TInt aSearchLimit, |
|
132 MPEngSearchTransactionObserver2& aObserver ) |
|
133 { |
|
134 if ( iSearchCntrl ) |
|
135 { |
|
136 return KErrInUse; |
|
137 } |
|
138 |
|
139 |
|
140 CPEngSearchControl* cntrl = NULL; |
|
141 TRAPD( err, |
|
142 cntrl = CPEngSearchControl::NewL( iCActivePriority, |
|
143 *iUsedSlotId, |
|
144 aCriterias, |
|
145 aSearchLimit, |
|
146 aObserver ); ); |
|
147 |
|
148 if ( err == KErrNone ) |
|
149 { |
|
150 //Success. |
|
151 //Ownership of passed search criterias is taken here |
|
152 iSearchCntrl = cntrl; |
|
153 iSearchCntrl->IssueSearch(); |
|
154 iSearchCntrl->SetOwner( *this ); |
|
155 aCriterias.ResetAndDestroy(); |
|
156 } |
|
157 |
|
158 return err; |
|
159 } |
|
160 |
|
161 |
|
162 // ----------------------------------------------------------------------------- |
|
163 // CPEngSearchTransaction2Imp::ContinueSearchFromNetwork() |
|
164 // ----------------------------------------------------------------------------- |
|
165 // |
|
166 TInt CPEngSearchTransaction2Imp::ContinueSearchFromNetwork( TInt aContinueIndex ) |
|
167 { |
|
168 if ( !iSearchCntrl ) |
|
169 { |
|
170 return KErrNotFound; |
|
171 } |
|
172 |
|
173 return iSearchCntrl->IssueContinueSearchFromNetwork( aContinueIndex ); |
|
174 } |
|
175 |
|
176 |
|
177 // ----------------------------------------------------------------------------- |
|
178 // CPEngSearchTransaction2Imp::StopSearchFromNetwork() |
|
179 // ----------------------------------------------------------------------------- |
|
180 // |
|
181 TInt CPEngSearchTransaction2Imp::StopSearchFromNetwork() |
|
182 { |
|
183 if ( !iSearchCntrl ) |
|
184 { |
|
185 return KErrNotFound; |
|
186 } |
|
187 |
|
188 return iSearchCntrl->IssueStopSearchFromNetwork(); |
|
189 } |
|
190 |
|
191 |
|
192 // ----------------------------------------------------------------------------- |
|
193 // CPEngSearchTransaction2Imp::HandleSearchDestruction() |
|
194 // ----------------------------------------------------------------------------- |
|
195 // |
|
196 void CPEngSearchTransaction2Imp::HandleSearchDestruction( |
|
197 CPEngSearchControl* /*aSearch*/ ) |
|
198 { |
|
199 iSearchCntrl = NULL; |
|
200 } |
|
201 |
|
202 |
|
203 // ----------------------------------------------------------------------------- |
|
204 // CPEngSearchTransaction2Imp::Interface() |
|
205 // ----------------------------------------------------------------------------- |
|
206 // |
|
207 CPEngSearchTransaction2& CPEngSearchTransaction2Imp::Interface() |
|
208 { |
|
209 return iInterface; |
|
210 } |
|
211 |
|
212 // End of File |
|
213 |
|
214 |