|
1 /* |
|
2 * Copyright (c) 2005-2007 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: Phonebook 2 server app assign select multiple |
|
15 * : property phase. |
|
16 * |
|
17 */ |
|
18 |
|
19 |
|
20 #include "CPbk2SelectMultiplePropertyPhase.h" |
|
21 |
|
22 // Phonebook 2 |
|
23 #include "MPbk2ServicePhaseObserver.h" |
|
24 #include "CPbk2ServerAppAppUi.h" |
|
25 #include "CPbk2AssignSelectFieldDlg.h" |
|
26 #include "MPbk2SelectFieldProperty.h" |
|
27 #include "CPbk2AssignMultiProperty.h" |
|
28 #include <TPbk2DestructionIndicator.h> |
|
29 |
|
30 // Virtual Phonebook |
|
31 #include <MVPbkContactLink.h> |
|
32 #include <CVPbkContactLinkArray.h> |
|
33 #include <MVPbkContactOperationBase.h> |
|
34 #include <MVPbkStoreContact.h> |
|
35 #include <CVPbkContactManager.h> |
|
36 |
|
37 |
|
38 /// Unnamed namespace for local definitions |
|
39 namespace { |
|
40 /** |
|
41 * Copies a link array to another. |
|
42 * |
|
43 * @param aSourceLinkArray Link array which is copied |
|
44 * @param aTargetLinkArray Links are copied to this |
|
45 */ |
|
46 void CopyContactLinksL( const MVPbkContactLinkArray& aSourceLinkArray, |
|
47 CVPbkContactLinkArray& aTargetLinkArray ) |
|
48 { |
|
49 const TInt count = aSourceLinkArray.Count(); |
|
50 for ( TInt i(0); i < count; ++i ) |
|
51 { |
|
52 const MVPbkContactLink& contactLink = aSourceLinkArray.At(i); |
|
53 aTargetLinkArray.AppendL( contactLink.CloneLC() ); |
|
54 CleanupStack::Pop(); // link |
|
55 } |
|
56 } |
|
57 |
|
58 } /// namespace |
|
59 |
|
60 // -------------------------------------------------------------------------- |
|
61 // CPbk2SelectMultiplePropertyPhase::CPbk2SelectMultiplePropertyPhase |
|
62 // -------------------------------------------------------------------------- |
|
63 // |
|
64 CPbk2SelectMultiplePropertyPhase::CPbk2SelectMultiplePropertyPhase |
|
65 ( MPbk2ServicePhaseObserver& aObserver, |
|
66 HBufC8& aFilterBuffer, |
|
67 MPbk2SelectFieldProperty*& aSelectFieldProperty ) : |
|
68 CActive( EPriorityIdle ), |
|
69 iObserver( aObserver ), |
|
70 iFilterBuffer( aFilterBuffer ), |
|
71 iSelectFieldProperty( aSelectFieldProperty ) |
|
72 { |
|
73 CActiveScheduler::Add( this ); |
|
74 } |
|
75 |
|
76 // -------------------------------------------------------------------------- |
|
77 // CPbk2SelectMultiplePropertyPhase::~CPbk2SelectMultiplePropertyPhase |
|
78 // -------------------------------------------------------------------------- |
|
79 // |
|
80 CPbk2SelectMultiplePropertyPhase::~CPbk2SelectMultiplePropertyPhase() |
|
81 { |
|
82 Cancel(); |
|
83 |
|
84 if ( iSelectFieldDialogEliminator ) |
|
85 { |
|
86 iSelectFieldDialogEliminator->ForceExit(); |
|
87 } |
|
88 |
|
89 delete iContactLinks; |
|
90 |
|
91 if ( iDestroyedPtr ) |
|
92 { |
|
93 *iDestroyedPtr = ETrue; |
|
94 } |
|
95 } |
|
96 |
|
97 // -------------------------------------------------------------------------- |
|
98 // CPbk2SelectMultiplePropertyPhase::ConstructL |
|
99 // -------------------------------------------------------------------------- |
|
100 // |
|
101 inline void CPbk2SelectMultiplePropertyPhase::ConstructL |
|
102 ( MVPbkContactLinkArray* aContactLinks ) |
|
103 { |
|
104 iContactLinks = CVPbkContactLinkArray::NewL(); |
|
105 // Take a own copy of supplied contact links |
|
106 CopyContactLinksL( *aContactLinks, *iContactLinks ); |
|
107 } |
|
108 |
|
109 // -------------------------------------------------------------------------- |
|
110 // CPbk2SelectMultiplePropertyPhase::NewL |
|
111 // -------------------------------------------------------------------------- |
|
112 // |
|
113 CPbk2SelectMultiplePropertyPhase* CPbk2SelectMultiplePropertyPhase::NewL |
|
114 ( MPbk2ServicePhaseObserver& aObserver, |
|
115 MVPbkContactLinkArray* aContactLinks, |
|
116 HBufC8& aFilterBuffer, |
|
117 MPbk2SelectFieldProperty*& aSelectFieldProperty ) |
|
118 { |
|
119 CPbk2SelectMultiplePropertyPhase* self = |
|
120 new ( ELeave ) CPbk2SelectMultiplePropertyPhase |
|
121 ( aObserver, aFilterBuffer, aSelectFieldProperty ); |
|
122 CleanupStack::PushL( self ); |
|
123 self->ConstructL( aContactLinks ); |
|
124 CleanupStack::Pop( self ); |
|
125 return self; |
|
126 } |
|
127 |
|
128 // -------------------------------------------------------------------------- |
|
129 // CPbk2SelectMultiplePropertyPhase::LaunchServicePhaseL |
|
130 // -------------------------------------------------------------------------- |
|
131 // |
|
132 void CPbk2SelectMultiplePropertyPhase::LaunchServicePhaseL() |
|
133 { |
|
134 IssueRequest(); |
|
135 } |
|
136 |
|
137 // -------------------------------------------------------------------------- |
|
138 // CPbk2SelectMultiplePropertyPhase::CancelServicePhase |
|
139 // -------------------------------------------------------------------------- |
|
140 // |
|
141 void CPbk2SelectMultiplePropertyPhase::CancelServicePhase() |
|
142 { |
|
143 if ( iSelectFieldDialogEliminator ) |
|
144 { |
|
145 iSelectFieldDialogEliminator->ForceExit(); |
|
146 } |
|
147 |
|
148 iObserver.PhaseCanceled( *this ); |
|
149 } |
|
150 |
|
151 // -------------------------------------------------------------------------- |
|
152 // CPbk2SelectMultiplePropertyPhase::RequestCancelL |
|
153 // -------------------------------------------------------------------------- |
|
154 // |
|
155 void CPbk2SelectMultiplePropertyPhase::RequestCancelL( TInt aExitCommandId ) |
|
156 { |
|
157 if ( iSelectFieldDialogEliminator ) |
|
158 { |
|
159 iSelectFieldDialogEliminator->RequestExitL( aExitCommandId ); |
|
160 } |
|
161 |
|
162 if ( aExitCommandId == EEikBidCancel ) |
|
163 { |
|
164 iObserver.PhaseAborted( *this ); |
|
165 } |
|
166 else |
|
167 { |
|
168 iObserver.PhaseCanceled( *this ); |
|
169 } |
|
170 } |
|
171 |
|
172 // -------------------------------------------------------------------------- |
|
173 // CPbk2SelectMultiplePropertyPhase::AcceptDelayed |
|
174 // -------------------------------------------------------------------------- |
|
175 // |
|
176 void CPbk2SelectMultiplePropertyPhase::AcceptDelayedL |
|
177 ( const TDesC8& /*aContactLinkBuffer*/ ) |
|
178 { |
|
179 // Nothing to do |
|
180 } |
|
181 |
|
182 // -------------------------------------------------------------------------- |
|
183 // CPbk2SelectMultiplePropertyPhase::Results |
|
184 // -------------------------------------------------------------------------- |
|
185 // |
|
186 MVPbkContactLinkArray* CPbk2SelectMultiplePropertyPhase::Results() const |
|
187 { |
|
188 return iContactLinks; |
|
189 } |
|
190 |
|
191 // -------------------------------------------------------------------------- |
|
192 // CPbk2SelectMultiplePropertyPhase::ExtraResultData |
|
193 // -------------------------------------------------------------------------- |
|
194 // |
|
195 TInt CPbk2SelectMultiplePropertyPhase::ExtraResultData() const |
|
196 { |
|
197 return KErrNotSupported; |
|
198 } |
|
199 |
|
200 // -------------------------------------------------------------------------- |
|
201 // CPbk2SelectMultiplePropertyPhase::TakeStoreContact |
|
202 // -------------------------------------------------------------------------- |
|
203 // |
|
204 MVPbkStoreContact* CPbk2SelectMultiplePropertyPhase::TakeStoreContact() |
|
205 { |
|
206 // Not supported |
|
207 return NULL; |
|
208 } |
|
209 |
|
210 // -------------------------------------------------------------------------- |
|
211 // CPbk2SelectMultiplePropertyPhase::FieldContent |
|
212 // -------------------------------------------------------------------------- |
|
213 // |
|
214 HBufC* CPbk2SelectMultiplePropertyPhase::FieldContent() const |
|
215 { |
|
216 return NULL; |
|
217 } |
|
218 |
|
219 // -------------------------------------------------------------------------- |
|
220 // CPbk2SelectMultiplePropertyPhase::RunL |
|
221 // -------------------------------------------------------------------------- |
|
222 // |
|
223 void CPbk2SelectMultiplePropertyPhase::RunL() |
|
224 { |
|
225 SelectFieldL(); |
|
226 } |
|
227 |
|
228 // -------------------------------------------------------------------------- |
|
229 // CPbk2SelectMultiplePropertyPhase::RunError |
|
230 // -------------------------------------------------------------------------- |
|
231 // |
|
232 TInt CPbk2SelectMultiplePropertyPhase::RunError( TInt aError ) |
|
233 { |
|
234 if ( aError != KErrDied ) |
|
235 { |
|
236 // If this is destroyed it is not safe to use iObserver anymore |
|
237 iObserver.PhaseError( *this, aError ); |
|
238 } |
|
239 return KErrNone; |
|
240 } |
|
241 |
|
242 // -------------------------------------------------------------------------- |
|
243 // CPbk2SelectMultiplePropertyPhase::DoCancel |
|
244 // -------------------------------------------------------------------------- |
|
245 // |
|
246 void CPbk2SelectMultiplePropertyPhase::DoCancel() |
|
247 { |
|
248 // Nothing to do |
|
249 } |
|
250 |
|
251 // -------------------------------------------------------------------------- |
|
252 // CPbk2SelectMultiplePropertyPhase::OkToExitL |
|
253 // -------------------------------------------------------------------------- |
|
254 // |
|
255 TBool CPbk2SelectMultiplePropertyPhase::OkToExitL( TInt aCommandId ) |
|
256 { |
|
257 return iObserver.PhaseOkToExit( *this, aCommandId ); |
|
258 } |
|
259 |
|
260 // -------------------------------------------------------------------------- |
|
261 // CPbk2SelectMultiplePropertyPhase::SelectFieldL |
|
262 // -------------------------------------------------------------------------- |
|
263 // |
|
264 void CPbk2SelectMultiplePropertyPhase::SelectFieldL() |
|
265 { |
|
266 CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&> |
|
267 ( *CEikonEnv::Static()->EikAppUi() ); |
|
268 |
|
269 CPbk2AssignMultiProperty* multiProperty = CPbk2AssignMultiProperty::NewL |
|
270 ( iFilterBuffer, *iContactLinks ); |
|
271 iSelectFieldProperty = multiProperty; |
|
272 |
|
273 TBool thisDestroyed = EFalse; |
|
274 iDestroyedPtr = &thisDestroyed; |
|
275 TPbk2DestructionIndicator indicator( &thisDestroyed, iDestroyedPtr ); |
|
276 |
|
277 // Select field query |
|
278 CPbk2AssignSelectFieldDlg* dlg = |
|
279 CPbk2AssignSelectFieldDlg::NewL( *this ); |
|
280 iSelectFieldDialogEliminator = dlg; |
|
281 iSelectFieldDialogEliminator->ResetWhenDestroyed |
|
282 ( &iSelectFieldDialogEliminator ); |
|
283 TInt result = dlg->ExecuteLD( *iSelectFieldProperty ); |
|
284 |
|
285 if ( !thisDestroyed ) |
|
286 { |
|
287 if ( result >= KErrNone ) |
|
288 { |
|
289 iObserver.NextPhase( *this ); |
|
290 } |
|
291 else if ( result == KErrAbort ) |
|
292 { |
|
293 iObserver.PhaseAborted( *this ); |
|
294 } |
|
295 else |
|
296 { |
|
297 iObserver.PhaseCanceled( *this ); |
|
298 } |
|
299 } |
|
300 } |
|
301 |
|
302 // -------------------------------------------------------------------------- |
|
303 // CPbk2SelectMultiplePropertyPhase::IssueRequest |
|
304 // -------------------------------------------------------------------------- |
|
305 // |
|
306 void CPbk2SelectMultiplePropertyPhase::IssueRequest() |
|
307 { |
|
308 TRequestStatus* status = &iStatus; |
|
309 User::RequestComplete( status, KErrNone ); |
|
310 SetActive(); |
|
311 } |
|
312 |
|
313 // End of File |