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 application server entry fetcher.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "CPbk2EntryFetcher.h"
|
|
20 |
|
|
21 |
// Phonebook 2
|
|
22 |
#include "MPbk2UiServiceObserver.h"
|
|
23 |
#include "TPbk2ServerMessageDataRetriever.h"
|
|
24 |
#include "CPbk2ServerAppAppUi.h"
|
|
25 |
#include "TPbk2TitlePaneOperator.h"
|
|
26 |
#include "CPbk2ServerAppStoreManager.h"
|
|
27 |
#include "MPbk2ServicePhase.h"
|
|
28 |
#include "CPbk2ContactFetchPhase.h"
|
|
29 |
#include <CPbk2StoreManager.h>
|
|
30 |
#include <Pbk2IPCPackage.h>
|
|
31 |
#include <MPbk2ApplicationServices.h>
|
|
32 |
|
|
33 |
// Virtual Phonebook
|
|
34 |
#include <CVPbkContactStoreUriArray.h>
|
|
35 |
#include <MVPbkContactLink.h>
|
|
36 |
#include <CVPbkFieldTypeSelector.h>
|
|
37 |
#include <CVPbkContactManager.h>
|
|
38 |
|
|
39 |
// System includes
|
|
40 |
#include <AiwContactSelectionDataTypes.h>
|
|
41 |
|
|
42 |
// Debug
|
|
43 |
#include <Pbk2Debug.h>
|
|
44 |
|
|
45 |
|
|
46 |
/// Unnamed namespace for local definitions
|
|
47 |
namespace {
|
|
48 |
|
|
49 |
/**
|
|
50 |
* Sets title pane.
|
|
51 |
*
|
|
52 |
* @param aDataRetriever Server message data retriever.
|
|
53 |
* @param aFlags Fetch flags.
|
|
54 |
* @param aMessage Server message.
|
|
55 |
*/
|
|
56 |
void SetTitlePaneL
|
|
57 |
( TPbk2ServerMessageDataRetriever& aDataRetriever, TUint aFlags,
|
|
58 |
const RMessage2& aMessage )
|
|
59 |
{
|
|
60 |
HBufC* titlePaneText = NULL;
|
|
61 |
if ( !( aFlags & ::EUseProviderTitle ) )
|
|
62 |
{
|
|
63 |
titlePaneText = aDataRetriever.GetTitlePaneTextL( aMessage );
|
|
64 |
}
|
|
65 |
TPbk2TitlePaneOperator titlePaneOperator;
|
|
66 |
titlePaneOperator.SetTitlePaneL( titlePaneText ); // takes ownership
|
|
67 |
}
|
|
68 |
|
|
69 |
} /// namespace
|
|
70 |
|
|
71 |
// --------------------------------------------------------------------------
|
|
72 |
// CPbk2EntryFetcher::CPbk2EntryFetcher
|
|
73 |
// --------------------------------------------------------------------------
|
|
74 |
//
|
|
75 |
CPbk2EntryFetcher::CPbk2EntryFetcher
|
|
76 |
( MPbk2UiServiceObserver& aObserver,
|
|
77 |
TPbk2FetchType aFetchType ) :
|
|
78 |
iObserver( aObserver ),
|
|
79 |
iFetchType( aFetchType )
|
|
80 |
{
|
|
81 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
82 |
("CPbk2EntryFetcher::CPbk2EntryFetcher()") );
|
|
83 |
}
|
|
84 |
|
|
85 |
// --------------------------------------------------------------------------
|
|
86 |
// CPbk2EntryFetcher::~CPbk2EntryFetcher
|
|
87 |
// --------------------------------------------------------------------------
|
|
88 |
//
|
|
89 |
CPbk2EntryFetcher::~CPbk2EntryFetcher()
|
|
90 |
{
|
|
91 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
92 |
("CPbk2EntryFetcher::~CPbk2EntryFetcher()") );
|
|
93 |
|
|
94 |
delete iStoreUris;
|
|
95 |
delete iPreselectedContacts;
|
|
96 |
delete iContactViewFilter;
|
|
97 |
delete iStoreManager;
|
|
98 |
delete iFetchPhase;
|
|
99 |
}
|
|
100 |
|
|
101 |
// --------------------------------------------------------------------------
|
|
102 |
// CPbk2EntryFetcher::ConstructL
|
|
103 |
// --------------------------------------------------------------------------
|
|
104 |
//
|
|
105 |
inline void CPbk2EntryFetcher::ConstructL( const RMessage2& aMessage )
|
|
106 |
{
|
|
107 |
// Retrieve data from the client-server message
|
|
108 |
CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&>
|
|
109 |
( *CEikonEnv::Static()->EikAppUi() );
|
|
110 |
|
|
111 |
TPbk2ServerMessageDataRetriever dataRetriever;
|
|
112 |
TUint flags = dataRetriever.FetchFlagsL( aMessage );
|
|
113 |
|
|
114 |
// Set title pane
|
|
115 |
SetTitlePaneL( dataRetriever, flags, aMessage );
|
|
116 |
|
|
117 |
iPreselectedContacts = dataRetriever.GetPreselectedContactLinksL
|
|
118 |
( aMessage, appUi.ApplicationServices().ContactManager() );
|
|
119 |
iStoreUris = dataRetriever.GetContactStoreUriArrayL
|
|
120 |
( aMessage, appUi.ApplicationServices().StoreConfiguration(),
|
|
121 |
iPreselectedContacts, iUseDeviceConfig );
|
|
122 |
iContactViewFilter = dataRetriever.GetContactViewFilterL
|
|
123 |
( aMessage, appUi.ApplicationServices().ContactManager().
|
|
124 |
FieldTypes() );
|
|
125 |
iFetchResId = dataRetriever.GetFetchDialogResourceL( aMessage );
|
|
126 |
|
|
127 |
iStoreManager = CPbk2ServerAppStoreManager::NewL
|
|
128 |
( appUi.StoreManager(),
|
|
129 |
appUi.ApplicationServices().ContactManager() );
|
|
130 |
}
|
|
131 |
|
|
132 |
// --------------------------------------------------------------------------
|
|
133 |
// CPbk2EntryFetcher::NewL
|
|
134 |
// --------------------------------------------------------------------------
|
|
135 |
//
|
|
136 |
CPbk2EntryFetcher* CPbk2EntryFetcher::NewL(
|
|
137 |
const RMessage2& aFetchCompleteMessage,
|
|
138 |
MPbk2UiServiceObserver& aObserver,
|
|
139 |
TPbk2FetchType aFetchType )
|
|
140 |
{
|
|
141 |
CPbk2EntryFetcher* self =
|
|
142 |
new ( ELeave ) CPbk2EntryFetcher( aObserver, aFetchType );
|
|
143 |
CleanupStack::PushL( self );
|
|
144 |
self->ConstructL( aFetchCompleteMessage );
|
|
145 |
CleanupStack::Pop( self );
|
|
146 |
return self;
|
|
147 |
}
|
|
148 |
|
|
149 |
// --------------------------------------------------------------------------
|
|
150 |
// CPbk2EntryFetcher::LaunchServiceL
|
|
151 |
// --------------------------------------------------------------------------
|
|
152 |
//
|
|
153 |
void CPbk2EntryFetcher::LaunchServiceL()
|
|
154 |
{
|
|
155 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
156 |
("CPbk2EntryFetcher::LaunchServiceL()") );
|
|
157 |
|
|
158 |
iStoreManager->LoadAndOpenContactStoresL( *iStoreUris, *this, EFalse );
|
|
159 |
}
|
|
160 |
|
|
161 |
// --------------------------------------------------------------------------
|
|
162 |
// CPbk2EntryFetcher::CancelService
|
|
163 |
// --------------------------------------------------------------------------
|
|
164 |
//
|
|
165 |
void CPbk2EntryFetcher::CancelService()
|
|
166 |
{
|
|
167 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
168 |
("CPbk2EntryFetcher::CancelService()") );
|
|
169 |
|
|
170 |
if ( iFetchPhase )
|
|
171 |
{
|
|
172 |
iFetchPhase->CancelServicePhase();
|
|
173 |
}
|
|
174 |
}
|
|
175 |
|
|
176 |
// --------------------------------------------------------------------------
|
|
177 |
// CPbk2EntryFetcher::AcceptDelayedContactsL
|
|
178 |
// --------------------------------------------------------------------------
|
|
179 |
//
|
|
180 |
void CPbk2EntryFetcher::AcceptDelayedContactsL
|
|
181 |
( const TDesC8& aContactLinkBuffer )
|
|
182 |
{
|
|
183 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
184 |
("CPbk2EntryFetcher::AcceptDelayedContactsL()") );
|
|
185 |
|
|
186 |
if ( iFetchPhase )
|
|
187 |
{
|
|
188 |
iFetchPhase->AcceptDelayedL( aContactLinkBuffer );
|
|
189 |
}
|
|
190 |
}
|
|
191 |
|
|
192 |
// --------------------------------------------------------------------------
|
|
193 |
// CPbk2EntryFetcher::DenyDelayedContactsL
|
|
194 |
// --------------------------------------------------------------------------
|
|
195 |
//
|
|
196 |
void CPbk2EntryFetcher::DenyDelayedContactsL
|
|
197 |
( const TDesC8& aContactLinkBuffer )
|
|
198 |
{
|
|
199 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
200 |
("CPbk2EntryFetcher::DenyDelayedContactsL()") );
|
|
201 |
|
|
202 |
if ( iFetchPhase )
|
|
203 |
{
|
|
204 |
iFetchPhase->DenyDelayedL( aContactLinkBuffer );
|
|
205 |
}
|
|
206 |
}
|
|
207 |
|
|
208 |
// --------------------------------------------------------------------------
|
|
209 |
// CPbk2EntryFetcher::ExitServiceL
|
|
210 |
// --------------------------------------------------------------------------
|
|
211 |
//
|
|
212 |
void CPbk2EntryFetcher::ExitServiceL( TInt aExitCommandId )
|
|
213 |
{
|
|
214 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
215 |
("CPbk2EntryFetcher::ExitServiceL(%d)"), aExitCommandId );
|
|
216 |
|
|
217 |
if ( iFetchPhase )
|
|
218 |
{
|
|
219 |
iFetchPhase->RequestCancelL( aExitCommandId );
|
|
220 |
}
|
|
221 |
}
|
|
222 |
|
|
223 |
// --------------------------------------------------------------------------
|
|
224 |
// CPbk2EntryFetcher::ServiceResults
|
|
225 |
// --------------------------------------------------------------------------
|
|
226 |
//
|
|
227 |
void CPbk2EntryFetcher::ServiceResults(TServiceResults* aResults) const
|
|
228 |
{
|
|
229 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
230 |
("CPbk2EntryFetcher::ServiceResults()") );
|
|
231 |
|
|
232 |
if ( iFetchPhase )
|
|
233 |
{
|
|
234 |
aResults->iLinkArray = iFetchPhase->Results();
|
|
235 |
aResults->iExtraData = iFetchPhase->ExtraResultData();
|
|
236 |
aResults->iFieldContent = iFetchPhase->FieldContent();
|
|
237 |
}
|
|
238 |
}
|
|
239 |
|
|
240 |
// --------------------------------------------------------------------------
|
|
241 |
// CPbk2EntryFetcher::NextPhase
|
|
242 |
// --------------------------------------------------------------------------
|
|
243 |
//
|
|
244 |
void CPbk2EntryFetcher::NextPhase( MPbk2ServicePhase& /*aPhase*/ )
|
|
245 |
{
|
|
246 |
// There is no other phase than fetch, we are done
|
|
247 |
iObserver.ServiceComplete();
|
|
248 |
}
|
|
249 |
|
|
250 |
// --------------------------------------------------------------------------
|
|
251 |
// CPbk2EntryFetcher::PreviousPhase
|
|
252 |
// --------------------------------------------------------------------------
|
|
253 |
//
|
|
254 |
void CPbk2EntryFetcher::PreviousPhase( MPbk2ServicePhase& /*aPhase*/ )
|
|
255 |
{
|
|
256 |
// Do nothing
|
|
257 |
}
|
|
258 |
|
|
259 |
// --------------------------------------------------------------------------
|
|
260 |
// CPbk2EntryFetcher::PhaseCanceled
|
|
261 |
// --------------------------------------------------------------------------
|
|
262 |
//
|
|
263 |
void CPbk2EntryFetcher::PhaseCanceled( MPbk2ServicePhase& /*aPhase*/ )
|
|
264 |
{
|
|
265 |
iObserver.ServiceCanceled();
|
|
266 |
}
|
|
267 |
|
|
268 |
// --------------------------------------------------------------------------
|
|
269 |
// CPbk2EntryFetcher::PhaseAborted
|
|
270 |
// --------------------------------------------------------------------------
|
|
271 |
//
|
|
272 |
void CPbk2EntryFetcher::PhaseAborted( MPbk2ServicePhase& /*aPhase*/ )
|
|
273 |
{
|
|
274 |
iObserver.ServiceAborted();
|
|
275 |
}
|
|
276 |
|
|
277 |
// --------------------------------------------------------------------------
|
|
278 |
// CPbk2EntryFetcher::PhaseError
|
|
279 |
// --------------------------------------------------------------------------
|
|
280 |
//
|
|
281 |
void CPbk2EntryFetcher::PhaseError
|
|
282 |
( MPbk2ServicePhase& /*aPhase*/, TInt aErrorCode )
|
|
283 |
{
|
|
284 |
iObserver.ServiceError( aErrorCode );
|
|
285 |
}
|
|
286 |
|
|
287 |
// --------------------------------------------------------------------------
|
|
288 |
// CPbk2EntryFetcher::PhaseOkToExit
|
|
289 |
// --------------------------------------------------------------------------
|
|
290 |
//
|
|
291 |
TBool CPbk2EntryFetcher::PhaseOkToExit
|
|
292 |
( MPbk2ServicePhase& /*aPhase*/, TInt aCommandId )
|
|
293 |
{
|
|
294 |
// Deny exit and pass an asynchronous query to the consumer,
|
|
295 |
// which may later approve exit
|
|
296 |
iObserver.CompleteExitMessage( aCommandId );
|
|
297 |
return EFalse;
|
|
298 |
}
|
|
299 |
|
|
300 |
// --------------------------------------------------------------------------
|
|
301 |
// CPbk2EntryFetcher::PhaseAccept
|
|
302 |
// --------------------------------------------------------------------------
|
|
303 |
//
|
|
304 |
void CPbk2EntryFetcher::PhaseAccept
|
|
305 |
( MPbk2ServicePhase& /*aPhase*/, const TDesC8& aMarkedEntries,
|
|
306 |
const TDesC8& aLinkData )
|
|
307 |
{
|
|
308 |
iObserver.CompleteAcceptMsg( aMarkedEntries, aLinkData );
|
|
309 |
}
|
|
310 |
|
|
311 |
// --------------------------------------------------------------------------
|
|
312 |
// CPbk2EntryFetcher::ContactUiReadyL
|
|
313 |
// --------------------------------------------------------------------------
|
|
314 |
//
|
|
315 |
void CPbk2EntryFetcher::ContactUiReadyL
|
|
316 |
( MPbk2StartupMonitor& aStartupMonitor )
|
|
317 |
{
|
|
318 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
319 |
("CPbk2EntryFetcher::ContactUiReadyL()") );
|
|
320 |
|
|
321 |
aStartupMonitor.DeregisterEvents( *this );
|
|
322 |
|
|
323 |
LaunchFetchPhaseL();
|
|
324 |
}
|
|
325 |
|
|
326 |
// --------------------------------------------------------------------------
|
|
327 |
// CPbk2EntryFetcher::StartupCanceled
|
|
328 |
// --------------------------------------------------------------------------
|
|
329 |
//
|
|
330 |
void CPbk2EntryFetcher::StartupCanceled( TInt aErrorCode )
|
|
331 |
{
|
|
332 |
PBK2_DEBUG_PRINT( PBK2_DEBUG_STRING
|
|
333 |
("CPbk2EntryFetcher::StartupCanceled(%d)"), aErrorCode );
|
|
334 |
|
|
335 |
if ( aErrorCode == KErrCancel )
|
|
336 |
{
|
|
337 |
iObserver.ServiceCanceled();
|
|
338 |
}
|
|
339 |
else
|
|
340 |
{
|
|
341 |
iObserver.ServiceError( aErrorCode );
|
|
342 |
}
|
|
343 |
}
|
|
344 |
|
|
345 |
// --------------------------------------------------------------------------
|
|
346 |
// CPbk2EntryFetcher::LaunchFetchPhaseL
|
|
347 |
// --------------------------------------------------------------------------
|
|
348 |
//
|
|
349 |
void CPbk2EntryFetcher::LaunchFetchPhaseL()
|
|
350 |
{
|
|
351 |
CPbk2FetchDlg::TParams params;
|
|
352 |
|
|
353 |
params.iResId = iFetchResId;
|
|
354 |
params.iMarkedEntries = iPreselectedContacts;
|
|
355 |
params.iFlags = CPbk2FetchDlg::EFetchSingle;
|
|
356 |
if ( iFetchType == EMultipleEntryFetch )
|
|
357 |
{
|
|
358 |
params.iFlags = CPbk2FetchDlg::EFetchMultiple;
|
|
359 |
}
|
|
360 |
|
|
361 |
delete iFetchPhase;
|
|
362 |
iFetchPhase = NULL;
|
|
363 |
iFetchPhase = CPbk2ContactFetchPhase::NewL
|
|
364 |
( *this, *iStoreManager, params, ETrue,
|
|
365 |
MPbk2FetchDlgObserver::EFetchDelayed, iContactViewFilter,
|
|
366 |
iUseDeviceConfig, iStoreUris );
|
|
367 |
|
|
368 |
CPbk2ServerAppAppUi& appUi = static_cast<CPbk2ServerAppAppUi&>
|
|
369 |
( *CEikonEnv::Static()->EikAppUi() );
|
|
370 |
|
|
371 |
// Change layout to fetch's layout
|
|
372 |
appUi.ChangeStatuspaneLayoutL(
|
|
373 |
CPbk2ServerAppAppUi::EStatusPaneLayoutUsual );
|
|
374 |
|
|
375 |
iFetchPhase->LaunchServicePhaseL();
|
|
376 |
}
|
|
377 |
|
|
378 |
// End of File
|