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 fetch dialog page.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#include "CPbk2FetchDlgPage.h"
|
|
20 |
|
|
21 |
// Phonebook 2
|
|
22 |
#include <CPbk2NamesListControl.h>
|
|
23 |
#include <MPbk2FetchDlg.h>
|
|
24 |
#include <MPbk2FetchDlgObserver.h>
|
|
25 |
#include <CPbk2StoreConfiguration.h>
|
|
26 |
#include <MPbk2Command.h>
|
|
27 |
#include <Pbk2UIControls.hrh>
|
|
28 |
#include <Pbk2UIControls.rsg>
|
|
29 |
#include <CPbk2ViewState.h>
|
|
30 |
|
|
31 |
// Virtual Phonebook
|
|
32 |
#include <MVPbkContactViewBase.h>
|
|
33 |
#include <CVPbkContactLinkArray.h>
|
|
34 |
#include <MVPbkContactLink.h>
|
|
35 |
#include <MVPbkBaseContact.h>
|
|
36 |
#include <CVPbkContactManager.h>
|
|
37 |
#include <CVPbkContactStoreUriArray.h>
|
|
38 |
#include <MVPbkContactStore.h>
|
|
39 |
#include <MVPbkContactStoreList.h>
|
|
40 |
#include <MVPbkContactStoreProperties.h>
|
|
41 |
#include <TVPbkContactStoreUriPtr.h>
|
|
42 |
|
|
43 |
// System includes
|
|
44 |
#include <calslbs.h>
|
|
45 |
#include <aknlayout.cdl.h>
|
|
46 |
#include <StringLoader.h>
|
|
47 |
|
|
48 |
/// Unnamed namespace for local definitions
|
|
49 |
namespace {
|
|
50 |
|
|
51 |
// LOCAL CONSTANTS AND MACROS
|
|
52 |
#ifdef _DEBUG
|
|
53 |
enum TPanicCode
|
|
54 |
{
|
|
55 |
EPanicPreCond_HandleContactViewListControlEventL = 1
|
|
56 |
};
|
|
57 |
|
|
58 |
void Panic(TPanicCode aReason)
|
|
59 |
{
|
|
60 |
_LIT(KPanicText, "CPbk2FetchDlgPage");
|
|
61 |
User::Panic(KPanicText, aReason);
|
|
62 |
}
|
|
63 |
#endif // _DEBUG
|
|
64 |
|
|
65 |
} /// namespace
|
|
66 |
|
|
67 |
|
|
68 |
// --------------------------------------------------------------------------
|
|
69 |
// CPbk2FetchDlgPage::CPbk2FetchDlgPage
|
|
70 |
// --------------------------------------------------------------------------
|
|
71 |
//
|
|
72 |
CPbk2FetchDlgPage::CPbk2FetchDlgPage
|
|
73 |
( MPbk2FetchDlg& aParentDlg, TInt aControlId ) :
|
|
74 |
iParentDlg( aParentDlg ),
|
|
75 |
iControlId( aControlId ),
|
|
76 |
iIsReady( EFalse )
|
|
77 |
{
|
|
78 |
}
|
|
79 |
|
|
80 |
// --------------------------------------------------------------------------
|
|
81 |
// CPbk2FetchDlgPage::~CPbk2FetchDlgPage
|
|
82 |
// --------------------------------------------------------------------------
|
|
83 |
//
|
|
84 |
CPbk2FetchDlgPage::~CPbk2FetchDlgPage()
|
|
85 |
{
|
|
86 |
if (iContactView)
|
|
87 |
{
|
|
88 |
iContactView->RemoveObserver( *iControl );
|
|
89 |
}
|
|
90 |
}
|
|
91 |
|
|
92 |
// --------------------------------------------------------------------------
|
|
93 |
// CPbk2FetchDlgPage::ConstructL
|
|
94 |
// --------------------------------------------------------------------------
|
|
95 |
//
|
|
96 |
inline void CPbk2FetchDlgPage::ConstructL()
|
|
97 |
{
|
|
98 |
iControl = static_cast<CPbk2NamesListControl*>
|
|
99 |
( iParentDlg.FetchDlgControl( iControlId ) );
|
|
100 |
iContactView = &iParentDlg.FetchDlgViewL( iControlId );
|
|
101 |
|
|
102 |
iControl->AddObserverL( *this );
|
|
103 |
iContactView->AddObserverL( *iControl );
|
|
104 |
|
|
105 |
AknLayoutUtils::LayoutControl
|
|
106 |
( iControl, iParentDlg.FetchDlgClientRect(),
|
|
107 |
AknLayout::list_gen_pane( 0 ) );
|
|
108 |
}
|
|
109 |
|
|
110 |
// --------------------------------------------------------------------------
|
|
111 |
// CPbk2FetchDlgPage::NewL
|
|
112 |
// --------------------------------------------------------------------------
|
|
113 |
//
|
|
114 |
CPbk2FetchDlgPage* CPbk2FetchDlgPage::NewL
|
|
115 |
( MPbk2FetchDlg& aParentDlg, TInt aControlId )
|
|
116 |
{
|
|
117 |
CPbk2FetchDlgPage* self = new ( ELeave ) CPbk2FetchDlgPage
|
|
118 |
( aParentDlg, aControlId );
|
|
119 |
CleanupStack::PushL( self );
|
|
120 |
self->ConstructL();
|
|
121 |
CleanupStack::Pop( self );
|
|
122 |
return self;
|
|
123 |
}
|
|
124 |
|
|
125 |
// --------------------------------------------------------------------------
|
|
126 |
// CPbk2FetchDlgPage::FetchDlgPageId
|
|
127 |
// --------------------------------------------------------------------------
|
|
128 |
//
|
|
129 |
TInt CPbk2FetchDlgPage::FetchDlgPageId() const
|
|
130 |
{
|
|
131 |
return iControlId;
|
|
132 |
}
|
|
133 |
|
|
134 |
// --------------------------------------------------------------------------
|
|
135 |
// CPbk2FetchDlgPage::ActivateFetchDlgPageL
|
|
136 |
// --------------------------------------------------------------------------
|
|
137 |
//
|
|
138 |
void CPbk2FetchDlgPage::ActivateFetchDlgPageL()
|
|
139 |
{
|
|
140 |
}
|
|
141 |
|
|
142 |
// --------------------------------------------------------------------------
|
|
143 |
// CPbk2FetchDlgPage::DeactivateFetchDlgPage
|
|
144 |
// --------------------------------------------------------------------------
|
|
145 |
//
|
|
146 |
void CPbk2FetchDlgPage::DeactivateFetchDlgPage()
|
|
147 |
{
|
|
148 |
}
|
|
149 |
|
|
150 |
// --------------------------------------------------------------------------
|
|
151 |
// CPbk2FetchDlgPage::FocusedContactL
|
|
152 |
// --------------------------------------------------------------------------
|
|
153 |
//
|
|
154 |
const MVPbkBaseContact* CPbk2FetchDlgPage::FocusedContactL() const
|
|
155 |
{
|
|
156 |
return iControl->FocusedContactL();
|
|
157 |
}
|
|
158 |
|
|
159 |
// --------------------------------------------------------------------------
|
|
160 |
// CPbk2FetchDlgPage::Control
|
|
161 |
// --------------------------------------------------------------------------
|
|
162 |
//
|
|
163 |
MPbk2ContactUiControl& CPbk2FetchDlgPage::Control() const
|
|
164 |
{
|
|
165 |
return *iControl;
|
|
166 |
}
|
|
167 |
|
|
168 |
// --------------------------------------------------------------------------
|
|
169 |
// CPbk2FetchDlgPage::View
|
|
170 |
// --------------------------------------------------------------------------
|
|
171 |
//
|
|
172 |
MVPbkContactViewBase& CPbk2FetchDlgPage::View() const
|
|
173 |
{
|
|
174 |
return iControl->View();
|
|
175 |
}
|
|
176 |
|
|
177 |
// --------------------------------------------------------------------------
|
|
178 |
// CPbk2FetchDlgPage::SetViewL
|
|
179 |
// --------------------------------------------------------------------------
|
|
180 |
//
|
|
181 |
void CPbk2FetchDlgPage::SetViewL( MVPbkContactViewBase& aView )
|
|
182 |
{
|
|
183 |
iControl->SetViewL( aView );
|
|
184 |
}
|
|
185 |
|
|
186 |
// --------------------------------------------------------------------------
|
|
187 |
// CPbk2FetchDlgPage::DlgPageReady
|
|
188 |
// --------------------------------------------------------------------------
|
|
189 |
//
|
|
190 |
TBool CPbk2FetchDlgPage::DlgPageReady() const
|
|
191 |
{
|
|
192 |
return iIsReady;
|
|
193 |
}
|
|
194 |
|
|
195 |
// --------------------------------------------------------------------------
|
|
196 |
// CPbk2FetchDlgPage::DlgPageEmpty
|
|
197 |
// --------------------------------------------------------------------------
|
|
198 |
//
|
|
199 |
TBool CPbk2FetchDlgPage::DlgPageEmpty() const
|
|
200 |
{
|
|
201 |
return ( iControl->NumberOfContacts() == 0 );
|
|
202 |
}
|
|
203 |
|
|
204 |
// --------------------------------------------------------------------------
|
|
205 |
// CPbk2FetchDlgPage::SelectContactL
|
|
206 |
// --------------------------------------------------------------------------
|
|
207 |
//
|
|
208 |
void CPbk2FetchDlgPage::SelectContactL
|
|
209 |
( const MVPbkContactLink& aContactLink, TBool aSelect )
|
|
210 |
{
|
|
211 |
MVPbkContactViewBase& view = iControl->View();
|
|
212 |
TInt index = view.IndexOfLinkL( aContactLink );
|
|
213 |
if ( index >= KErrNone )
|
|
214 |
{
|
|
215 |
iControl->SetSelectedContactL( index, aSelect );
|
|
216 |
}
|
|
217 |
}
|
|
218 |
|
|
219 |
// --------------------------------------------------------------------------
|
|
220 |
// CPbk2FetchDlgPage::HandleResourceChange
|
|
221 |
// --------------------------------------------------------------------------
|
|
222 |
//
|
|
223 |
void CPbk2FetchDlgPage::HandleResourceChange( TInt aType )
|
|
224 |
{
|
|
225 |
if ( aType == KEikDynamicLayoutVariantSwitch )
|
|
226 |
{
|
|
227 |
AknLayoutUtils::LayoutControl
|
|
228 |
( iControl, iParentDlg.FetchDlgClientRect(),
|
|
229 |
AKN_LAYOUT_WINDOW_list_gen_pane( 0 ) );
|
|
230 |
}
|
|
231 |
}
|
|
232 |
|
|
233 |
// --------------------------------------------------------------------------
|
|
234 |
// CPbk2FetchDlgPage::HandleControlEventL
|
|
235 |
// --------------------------------------------------------------------------
|
|
236 |
//
|
|
237 |
void CPbk2FetchDlgPage::HandleControlEventL
|
|
238 |
( MPbk2ContactUiControl& aControl, const TPbk2ControlEvent& aEvent )
|
|
239 |
{
|
|
240 |
__ASSERT_DEBUG(&aControl==iControl,
|
|
241 |
Panic(EPanicPreCond_HandleContactViewListControlEventL));
|
|
242 |
|
|
243 |
switch ( aEvent.iEventType )
|
|
244 |
{
|
|
245 |
case TPbk2ControlEvent::EReady:
|
|
246 |
{
|
|
247 |
SetPagesReadyStateL( ETrue );
|
|
248 |
iControl->ShowThumbnail();
|
|
249 |
break;
|
|
250 |
}
|
|
251 |
|
|
252 |
case TPbk2ControlEvent::EUnavailable:
|
|
253 |
{
|
|
254 |
SetPagesReadyStateL( EFalse );
|
|
255 |
break;
|
|
256 |
}
|
|
257 |
|
|
258 |
case TPbk2ControlEvent::EContactSelected:
|
|
259 |
{
|
|
260 |
HandleContactSelectionL
|
|
261 |
( aControl.FocusedContactL(), aEvent.iInt, ETrue );
|
|
262 |
break;
|
|
263 |
}
|
|
264 |
|
|
265 |
case TPbk2ControlEvent::EContactUnselected:
|
|
266 |
{
|
|
267 |
HandleContactSelectionL
|
|
268 |
( aControl.FocusedContactL(), aEvent.iInt, EFalse );
|
|
269 |
break;
|
|
270 |
}
|
|
271 |
|
|
272 |
case TPbk2ControlEvent::EItemAdded:
|
|
273 |
{
|
|
274 |
// Notify parent dialog that this page's contents has changed
|
|
275 |
iParentDlg.FetchDlgPageChangedL( *this );
|
|
276 |
break;
|
|
277 |
}
|
|
278 |
|
|
279 |
case TPbk2ControlEvent::EItemRemoved:
|
|
280 |
{
|
|
281 |
// Notify parent dialog that this page's contents has changed
|
|
282 |
iParentDlg.FetchDlgPageChangedL( *this );
|
|
283 |
break;
|
|
284 |
}
|
|
285 |
|
|
286 |
case TPbk2ControlEvent::EContactSetChanged:
|
|
287 |
{
|
|
288 |
// Notify parent dialog that this page's contents has changed
|
|
289 |
iParentDlg.FetchDlgPageChangedL( *this );
|
|
290 |
break;
|
|
291 |
}
|
|
292 |
|
|
293 |
case TPbk2ControlEvent::EControlStateChanged:
|
|
294 |
{
|
|
295 |
UpdateListEmptyTextL( aEvent.iInt );
|
|
296 |
iControl->DrawDeferred();
|
|
297 |
break;
|
|
298 |
}
|
|
299 |
|
|
300 |
case TPbk2ControlEvent::EContactUnselectedAll: // FALLTHROUGH
|
|
301 |
default:
|
|
302 |
{
|
|
303 |
// Do nothing
|
|
304 |
break;
|
|
305 |
};
|
|
306 |
}
|
|
307 |
|
|
308 |
// Forward event to parent dialog
|
|
309 |
iParentDlg.HandleControlEventL( aControl, aEvent );
|
|
310 |
}
|
|
311 |
|
|
312 |
// --------------------------------------------------------------------------
|
|
313 |
// CPbk2FetchDlgPage::HandleContactSelectionL
|
|
314 |
// --------------------------------------------------------------------------
|
|
315 |
//
|
|
316 |
void CPbk2FetchDlgPage::HandleContactSelectionL
|
|
317 |
( const MVPbkBaseContact* aContact, TInt /*aIndex*/,
|
|
318 |
TBool aSelected )
|
|
319 |
{
|
|
320 |
if ( aContact )
|
|
321 |
{
|
|
322 |
MVPbkContactLink* link = aContact->CreateLinkLC();
|
|
323 |
iParentDlg.SelectContactL( *link, aSelected );
|
|
324 |
CleanupStack::PopAndDestroy();
|
|
325 |
}
|
|
326 |
}
|
|
327 |
|
|
328 |
// --------------------------------------------------------------------------
|
|
329 |
// CPbk2FetchDlgPage::SetPagesReadyStateL
|
|
330 |
// --------------------------------------------------------------------------
|
|
331 |
//
|
|
332 |
void CPbk2FetchDlgPage::SetPagesReadyStateL( TBool aReadyState )
|
|
333 |
{
|
|
334 |
iIsReady = aReadyState;
|
|
335 |
iParentDlg.FetchDlgPageChangedL( *this ); // call this to update CBAs
|
|
336 |
}
|
|
337 |
|
|
338 |
// --------------------------------------------------------------------------
|
|
339 |
// CPbk2FetchDlgPage::UpdateListEmptyTextL
|
|
340 |
// --------------------------------------------------------------------------
|
|
341 |
//
|
|
342 |
void CPbk2FetchDlgPage::UpdateListEmptyTextL( TInt aListState )
|
|
343 |
{
|
|
344 |
HBufC* text = ListEmptyTextLC( aListState );
|
|
345 |
|
|
346 |
if ( text )
|
|
347 |
{
|
|
348 |
iControl->SetTextL( *text );
|
|
349 |
CleanupStack::PopAndDestroy(); // text
|
|
350 |
}
|
|
351 |
}
|
|
352 |
|
|
353 |
// --------------------------------------------------------------------------
|
|
354 |
// CPbk2FetchDlgPage::ListEmptyTextLC
|
|
355 |
// --------------------------------------------------------------------------
|
|
356 |
//
|
|
357 |
HBufC* CPbk2FetchDlgPage::ListEmptyTextLC( TInt aListState )
|
|
358 |
{
|
|
359 |
HBufC* text = NULL;
|
|
360 |
|
|
361 |
switch ( aListState )
|
|
362 |
{
|
|
363 |
case CPbk2NamesListControl::EStateEmpty: // FALLTHROUGH
|
|
364 |
case CPbk2NamesListControl::EStateNotReady:
|
|
365 |
{
|
|
366 |
text = StringLoader::LoadLC( R_QTN_PHOB_NO_ENTRIES_LONG );
|
|
367 |
break;
|
|
368 |
}
|
|
369 |
|
|
370 |
case CPbk2NamesListControl::EStateReady: // FALLTHROUGH
|
|
371 |
case CPbk2NamesListControl::EStateFiltered:
|
|
372 |
{
|
|
373 |
text = StringLoader::LoadLC( R_PBK2_FIND_NO_MATCHES );
|
|
374 |
break;
|
|
375 |
}
|
|
376 |
|
|
377 |
default:
|
|
378 |
{
|
|
379 |
text = KNullDesC().AllocLC();
|
|
380 |
break;
|
|
381 |
}
|
|
382 |
}
|
|
383 |
return text;
|
|
384 |
}
|
|
385 |
// End of File
|