20
|
1 |
/*
|
|
2 |
* Copyright (c) 2005-2008 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 update
|
|
15 |
* : empty property phase.
|
|
16 |
*
|
|
17 |
*/
|
|
18 |
|
|
19 |
|
|
20 |
#include "CPbk2SelectUpdateEmptyPropertyPhase.h"
|
|
21 |
|
|
22 |
// Phonebook 2
|
|
23 |
#include "MPbk2ServicePhaseObserver.h"
|
|
24 |
#include <MPbk2ApplicationServices.h>
|
|
25 |
#include "CPbk2ServerAppAppUi.h"
|
|
26 |
|
|
27 |
// Virtual Phonebook
|
|
28 |
#include <MVPbkStoreContact.h>
|
|
29 |
#include <CVPbkContactLinkArray.h>
|
|
30 |
#include <MVPbkContactLink.h>
|
|
31 |
#include <CVPbkContactManager.h>
|
|
32 |
#include <MVPbkContactOperationBase.h>
|
|
33 |
|
|
34 |
// System includes
|
|
35 |
#include <eikon.hrh>
|
|
36 |
|
|
37 |
/// Unnamed namespace for local definitions
|
|
38 |
namespace {
|
|
39 |
|
|
40 |
const TInt KFirstElement = 0;
|
|
41 |
|
|
42 |
/**
|
|
43 |
* Copies a link array to another.
|
|
44 |
*
|
|
45 |
* @param aSourceLinkArray Link array which is copied
|
|
46 |
* @param aTargetLinkArray Links are copied to this
|
|
47 |
*/
|
|
48 |
void CopyContactLinksL( const MVPbkContactLinkArray& aSourceLinkArray,
|
|
49 |
CVPbkContactLinkArray& aTargetLinkArray )
|
|
50 |
{
|
|
51 |
const TInt count = aSourceLinkArray.Count();
|
|
52 |
for ( TInt i(0); i < count; ++i )
|
|
53 |
{
|
|
54 |
const MVPbkContactLink& contactLink = aSourceLinkArray.At(i);
|
|
55 |
aTargetLinkArray.AppendL( contactLink.CloneLC() );
|
|
56 |
CleanupStack::Pop(); // link
|
|
57 |
}
|
|
58 |
}
|
|
59 |
|
|
60 |
} /// namespace
|
|
61 |
|
|
62 |
// --------------------------------------------------------------------------
|
|
63 |
// CPbk2SelectUpdateEmptyPropertyPhase::CPbk2SelectUpdateEmptyPropertyPhase
|
|
64 |
// --------------------------------------------------------------------------
|
|
65 |
//
|
|
66 |
CPbk2SelectUpdateEmptyPropertyPhase::CPbk2SelectUpdateEmptyPropertyPhase(
|
|
67 |
MPbk2ServicePhaseObserver& aObserver,
|
|
68 |
MPbk2SelectFieldProperty*& aSelectFieldProperty, TInt& aResult,
|
|
69 |
TUint& /*aNoteFlags*/ ) :
|
|
70 |
iObserver( aObserver ),
|
|
71 |
iSelectFieldProperty( aSelectFieldProperty ),
|
|
72 |
iResult( aResult )
|
|
73 |
{
|
|
74 |
}
|
|
75 |
|
|
76 |
// --------------------------------------------------------------------------
|
|
77 |
// CPbk2SelectUpdateEmptyPropertyPhase::~CPbk2SelectUpdateEmptyPropertyPhase
|
|
78 |
// --------------------------------------------------------------------------
|
|
79 |
//
|
|
80 |
CPbk2SelectUpdateEmptyPropertyPhase::~CPbk2SelectUpdateEmptyPropertyPhase()
|
|
81 |
{
|
|
82 |
delete iRetrieveOperation;
|
|
83 |
delete iContactLinks;
|
|
84 |
delete iStoreContact;
|
|
85 |
}
|
|
86 |
|
|
87 |
// --------------------------------------------------------------------------
|
|
88 |
// CPbk2SelectUpdateEmptyPropertyPhase::ConstructL
|
|
89 |
// --------------------------------------------------------------------------
|
|
90 |
//
|
|
91 |
inline void CPbk2SelectUpdateEmptyPropertyPhase::ConstructL
|
|
92 |
( MVPbkContactLinkArray& aContactLinks )
|
|
93 |
{
|
|
94 |
iContactLinks = CVPbkContactLinkArray::NewL();
|
|
95 |
// Take a own copy of supplied contact links
|
|
96 |
CopyContactLinksL( aContactLinks, *iContactLinks );
|
|
97 |
}
|
|
98 |
|
|
99 |
// --------------------------------------------------------------------------
|
|
100 |
// CPbk2SelectUpdateEmptyPropertyPhase::NewL
|
|
101 |
// --------------------------------------------------------------------------
|
|
102 |
//
|
|
103 |
CPbk2SelectUpdateEmptyPropertyPhase* CPbk2SelectUpdateEmptyPropertyPhase::NewL
|
|
104 |
( MPbk2ServicePhaseObserver& aObserver,
|
|
105 |
MVPbkContactLinkArray& aContactLinks,
|
|
106 |
MPbk2SelectFieldProperty*& aSelectFieldProperty,
|
|
107 |
TInt& aResult, TUint& aNoteFlags )
|
|
108 |
{
|
|
109 |
CPbk2SelectUpdateEmptyPropertyPhase* self =
|
|
110 |
new ( ELeave ) CPbk2SelectUpdateEmptyPropertyPhase
|
|
111 |
( aObserver, aSelectFieldProperty,
|
|
112 |
aResult, aNoteFlags );
|
|
113 |
CleanupStack::PushL( self );
|
|
114 |
self->ConstructL( aContactLinks );
|
|
115 |
CleanupStack::Pop();
|
|
116 |
return self;
|
|
117 |
}
|
|
118 |
|
|
119 |
// --------------------------------------------------------------------------
|
|
120 |
// CPbk2SelectUpdateEmptyPropertyPhase::LaunchServicePhaseL
|
|
121 |
// --------------------------------------------------------------------------
|
|
122 |
//
|
|
123 |
void CPbk2SelectUpdateEmptyPropertyPhase::LaunchServicePhaseL()
|
|
124 |
{
|
|
125 |
RetrieveContactL();
|
|
126 |
}
|
|
127 |
|
|
128 |
// --------------------------------------------------------------------------
|
|
129 |
// CPbk2SelectUpdateEmptyPropertyPhase::CancelServicePhase
|
|
130 |
// --------------------------------------------------------------------------
|
|
131 |
//
|
|
132 |
void CPbk2SelectUpdateEmptyPropertyPhase::CancelServicePhase()
|
|
133 |
{
|
|
134 |
iObserver.PhaseCanceled( *this );
|
|
135 |
}
|
|
136 |
|
|
137 |
// --------------------------------------------------------------------------
|
|
138 |
// CPbk2SelectUpdateEmptyPropertyPhase::RequestCancelL
|
|
139 |
// --------------------------------------------------------------------------
|
|
140 |
//
|
|
141 |
void CPbk2SelectUpdateEmptyPropertyPhase::RequestCancelL
|
|
142 |
( TInt aExitCommandId )
|
|
143 |
{
|
|
144 |
if ( aExitCommandId == EEikBidCancel )
|
|
145 |
{
|
|
146 |
iObserver.PhaseAborted( *this );
|
|
147 |
}
|
|
148 |
else
|
|
149 |
{
|
|
150 |
iObserver.PhaseCanceled( *this );
|
|
151 |
}
|
|
152 |
}
|
|
153 |
|
|
154 |
// --------------------------------------------------------------------------
|
|
155 |
// CPbk2SelectUpdateEmptyPropertyPhase::AcceptDelayed
|
|
156 |
// --------------------------------------------------------------------------
|
|
157 |
//
|
|
158 |
void CPbk2SelectUpdateEmptyPropertyPhase::AcceptDelayedL
|
|
159 |
( const TDesC8& /*aContactLinkBuffer*/ )
|
|
160 |
{
|
|
161 |
// Nothing to do
|
|
162 |
}
|
|
163 |
|
|
164 |
// --------------------------------------------------------------------------
|
|
165 |
// CPbk2SelectUpdateEmptyPropertyPhase::DenyDelayed
|
|
166 |
// --------------------------------------------------------------------------
|
|
167 |
//
|
|
168 |
void CPbk2SelectUpdateEmptyPropertyPhase::DenyDelayedL
|
|
169 |
( const TDesC8& /*aContactLinkBuffer*/ )
|
|
170 |
{
|
|
171 |
// Nothing to do
|
|
172 |
}
|
|
173 |
|
|
174 |
// --------------------------------------------------------------------------
|
|
175 |
// CPbk2SelectUpdateEmptyPropertyPhase::Results
|
|
176 |
// --------------------------------------------------------------------------
|
|
177 |
//
|
|
178 |
MVPbkContactLinkArray* CPbk2SelectUpdateEmptyPropertyPhase::Results() const
|
|
179 |
{
|
|
180 |
return iContactLinks;
|
|
181 |
}
|
|
182 |
|
|
183 |
// --------------------------------------------------------------------------
|
|
184 |
// CPbk2SelectUpdateEmptyPropertyPhase::ExtraResultData
|
|
185 |
// --------------------------------------------------------------------------
|
|
186 |
//
|
|
187 |
TInt CPbk2SelectUpdateEmptyPropertyPhase::ExtraResultData() const
|
|
188 |
{
|
|
189 |
return KErrNotSupported;
|
|
190 |
}
|
|
191 |
|
|
192 |
// --------------------------------------------------------------------------
|
|
193 |
// CPbk2SelectUpdateEmptyPropertyPhase::TakeStoreContact
|
|
194 |
// --------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
MVPbkStoreContact* CPbk2SelectUpdateEmptyPropertyPhase::TakeStoreContact()
|
|
197 |
{
|
|
198 |
MVPbkStoreContact* contact = iStoreContact;
|
|
199 |
iStoreContact = NULL;
|
|
200 |
return contact;
|
|
201 |
}
|
|
202 |
|
|
203 |
// --------------------------------------------------------------------------
|
|
204 |
// CPbk2SelectUpdateEmptyPropertyPhase::FieldContent
|
|
205 |
// --------------------------------------------------------------------------
|
|
206 |
//
|
|
207 |
HBufC* CPbk2SelectUpdateEmptyPropertyPhase::FieldContent() const
|
|
208 |
{
|
|
209 |
return NULL;
|
|
210 |
}
|
|
211 |
|
|
212 |
// --------------------------------------------------------------------------
|
|
213 |
// CPbk2SelectUpdateEmptyPropertyPhase::VPbkSingleContactOperationComplete
|
|
214 |
// --------------------------------------------------------------------------
|
|
215 |
//
|
|
216 |
void CPbk2SelectUpdateEmptyPropertyPhase::VPbkSingleContactOperationComplete
|
|
217 |
( MVPbkContactOperationBase& /*aOperation*/,
|
|
218 |
MVPbkStoreContact* aContact )
|
|
219 |
{
|
|
220 |
// Contact retrieval complete
|
|
221 |
delete iStoreContact;
|
|
222 |
iStoreContact = aContact;
|
|
223 |
|
|
224 |
iResult = KErrNotFound;
|
|
225 |
iSelectFieldProperty = NULL;
|
|
226 |
iObserver.NextPhase( *this );
|
|
227 |
}
|
|
228 |
|
|
229 |
// --------------------------------------------------------------------------
|
|
230 |
// CPbk2SelectUpdateEmptyPropertyPhase::VPbkSingleContactOperationFailed
|
|
231 |
// --------------------------------------------------------------------------
|
|
232 |
//
|
|
233 |
void CPbk2SelectUpdateEmptyPropertyPhase::VPbkSingleContactOperationFailed
|
|
234 |
( MVPbkContactOperationBase& /*aOperation*/, TInt aError )
|
|
235 |
{
|
|
236 |
iObserver.PhaseError( *this, aError );
|
|
237 |
}
|
|
238 |
|
|
239 |
// --------------------------------------------------------------------------
|
|
240 |
// CPbk2SelectUpdateEmptyPropertyPhase::RetrieveContactL
|
|
241 |
// --------------------------------------------------------------------------
|
|
242 |
//
|
|
243 |
void CPbk2SelectUpdateEmptyPropertyPhase::RetrieveContactL()
|
|
244 |
{
|
|
245 |
CPbk2ServerAppAppUi& appUi =
|
|
246 |
static_cast<CPbk2ServerAppAppUi&>
|
|
247 |
( *CEikonEnv::Static()->EikAppUi() );
|
|
248 |
|
|
249 |
delete iRetrieveOperation;
|
|
250 |
iRetrieveOperation = NULL;
|
|
251 |
iRetrieveOperation = appUi.ApplicationServices().ContactManager().
|
|
252 |
RetrieveContactL( iContactLinks->At( KFirstElement ), *this );
|
|
253 |
// Do not delete anything from iContactLinks since it is not necessary
|
|
254 |
// and would result to errors when client queries results
|
|
255 |
}
|
|
256 |
|
|
257 |
// End of File
|