20
|
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::DenyDelayed
|
|
184 |
// --------------------------------------------------------------------------
|
|
185 |
//
|
|
186 |
void CPbk2SelectMultiplePropertyPhase::DenyDelayedL
|
|
187 |
( const TDesC8& /*aContactLinkBuffer*/ )
|
|
188 |
{
|
|
189 |
// Nothing to do
|
|
190 |
}
|
|
191 |
|
|
192 |
// --------------------------------------------------------------------------
|
|
193 |
// CPbk2SelectMultiplePropertyPhase::Results
|
|
194 |
// --------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
MVPbkContactLinkArray* CPbk2SelectMultiplePropertyPhase::Results() const
|
|
197 |
{
|
|
198 |
return iContactLinks;
|
|
199 |
}
|
|
200 |
|
|
201 |
// --------------------------------------------------------------------------
|
|
202 |
// CPbk2SelectMultiplePropertyPhase::ExtraResultData
|
|
203 |
// --------------------------------------------------------------------------
|
|
204 |
//
|
|
205 |
TInt CPbk2SelectMultiplePropertyPhase::ExtraResultData() const
|
|
206 |
{
|
|
207 |
return KErrNotSupported;
|
|
208 |
}
|
|
209 |
|
|
210 |
// --------------------------------------------------------------------------
|
|
211 |
// CPbk2SelectMultiplePropertyPhase::TakeStoreContact
|
|
212 |
// --------------------------------------------------------------------------
|
|
213 |
//
|
|
214 |
MVPbkStoreContact* CPbk2SelectMultiplePropertyPhase::TakeStoreContact()
|
|
215 |
{
|
|
216 |
// Not supported
|
|
217 |
return NULL;
|
|
218 |
}
|
|
219 |
|
|
220 |
// --------------------------------------------------------------------------
|
|
221 |
// CPbk2SelectMultiplePropertyPhase::FieldContent
|
|
222 |
// --------------------------------------------------------------------------
|
|
223 |
//
|
|
224 |
HBufC* CPbk2SelectMultiplePropertyPhase::FieldContent() const
|
|
225 |
{
|
|
226 |
return NULL;
|
|
227 |
}
|
|
228 |
|
|
229 |
// --------------------------------------------------------------------------
|
|
230 |
// CPbk2SelectMultiplePropertyPhase::RunL
|
|
231 |
// --------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
void CPbk2SelectMultiplePropertyPhase::RunL()
|
|
234 |
{
|
|
235 |
SelectFieldL();
|
|
236 |
}
|
|
237 |
|
|
238 |
// --------------------------------------------------------------------------
|
|
239 |
// CPbk2SelectMultiplePropertyPhase::RunError
|
|
240 |
// --------------------------------------------------------------------------
|
|
241 |
//
|
|
242 |
TInt CPbk2SelectMultiplePropertyPhase::RunError( TInt aError )
|
|
243 |
{
|
|
244 |
if ( aError != KErrDied )
|
|
245 |
{
|
|
246 |
// If this is destroyed it is not safe to use iObserver anymore
|
|
247 |
iObserver.PhaseError( *this, aError );
|
|
248 |
}
|
|
249 |
return KErrNone;
|
|
250 |
}
|
|
251 |
|
|
252 |
// --------------------------------------------------------------------------
|
|
253 |
// CPbk2SelectMultiplePropertyPhase::DoCancel
|
|
254 |
// --------------------------------------------------------------------------
|
|
255 |
//
|
|
256 |
void CPbk2SelectMultiplePropertyPhase::DoCancel()
|
|
257 |
{
|
|
258 |
// Nothing to do
|
|
259 |
}
|
|
260 |
|
|
261 |
// --------------------------------------------------------------------------
|
|
262 |
// CPbk2SelectMultiplePropertyPhase::OkToExitL
|
|
263 |
// --------------------------------------------------------------------------
|
|
264 |
//
|
|
265 |
TBool CPbk2SelectMultiplePropertyPhase::OkToExitL( TInt aCommandId )
|
|
266 |
{
|
|
267 |
return iObserver.PhaseOkToExit( *this, aCommandId );
|
|
268 |
}
|
|
269 |
|
|
270 |
// --------------------------------------------------------------------------
|
|
271 |
// CPbk2SelectMultiplePropertyPhase::SelectFieldL
|
|
272 |
// --------------------------------------------------------------------------
|
|
273 |
//
|
|
274 |
void CPbk2SelectMultiplePropertyPhase::SelectFieldL()
|
|
275 |
{
|
|
276 |
CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&>
|
|
277 |
( *CEikonEnv::Static()->EikAppUi() );
|
|
278 |
|
|
279 |
CPbk2AssignMultiProperty* multiProperty = CPbk2AssignMultiProperty::NewL
|
|
280 |
( iFilterBuffer, *iContactLinks );
|
|
281 |
iSelectFieldProperty = multiProperty;
|
|
282 |
|
|
283 |
TBool thisDestroyed = EFalse;
|
|
284 |
iDestroyedPtr = &thisDestroyed;
|
|
285 |
TPbk2DestructionIndicator indicator( &thisDestroyed, iDestroyedPtr );
|
|
286 |
|
|
287 |
// Select field query
|
|
288 |
CPbk2AssignSelectFieldDlg* dlg =
|
|
289 |
CPbk2AssignSelectFieldDlg::NewL( *this );
|
|
290 |
iSelectFieldDialogEliminator = dlg;
|
|
291 |
iSelectFieldDialogEliminator->ResetWhenDestroyed
|
|
292 |
( &iSelectFieldDialogEliminator );
|
|
293 |
TInt result = dlg->ExecuteLD( *iSelectFieldProperty );
|
|
294 |
|
|
295 |
if ( !thisDestroyed )
|
|
296 |
{
|
|
297 |
if ( result >= KErrNone )
|
|
298 |
{
|
|
299 |
iObserver.NextPhase( *this );
|
|
300 |
}
|
|
301 |
else if ( result == KErrAbort )
|
|
302 |
{
|
|
303 |
iObserver.PhaseAborted( *this );
|
|
304 |
}
|
|
305 |
else
|
|
306 |
{
|
|
307 |
iObserver.PhaseCanceled( *this );
|
|
308 |
}
|
|
309 |
}
|
|
310 |
}
|
|
311 |
|
|
312 |
// --------------------------------------------------------------------------
|
|
313 |
// CPbk2SelectMultiplePropertyPhase::IssueRequest
|
|
314 |
// --------------------------------------------------------------------------
|
|
315 |
//
|
|
316 |
void CPbk2SelectMultiplePropertyPhase::IssueRequest()
|
|
317 |
{
|
|
318 |
TRequestStatus* status = &iStatus;
|
|
319 |
User::RequestComplete( status, KErrNone );
|
|
320 |
SetActive();
|
|
321 |
}
|
|
322 |
|
|
323 |
// End of File
|