62
|
1 |
/*
|
|
2 |
* Copyright (c) 2010 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: Easy dialing contact data manager.
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef __EASYDIALINGCONTACTDATAMANAGER_H__
|
|
20 |
#define __EASYDIALINGCONTACTDATAMANAGER_H__
|
|
21 |
|
|
22 |
#include <MPbk2ImageOperationObservers.h>
|
|
23 |
#include <MPbk2StoreConfigurationObserver.h>
|
|
24 |
#include <MVPbkSingleContactOperationObserver.h>
|
|
25 |
#include <MVPbkContactStoreListObserver.h>
|
|
26 |
#include <MVPbkOperationObserver.h>
|
|
27 |
#include <MVPbkContactViewBase.h>
|
|
28 |
#include <TPbk2ImageManagerParams.h>
|
|
29 |
#include <MPbkGlobalSetting.h> // For name order setting
|
|
30 |
#include <MVPbkContactViewObserver.h>
|
|
31 |
#include "easydialingcontactdata.h"
|
|
32 |
|
|
33 |
// FORWARD DECLARATIONS
|
|
34 |
class CPbk2StoreConfiguration;
|
|
35 |
class CVPbkContactManager;
|
|
36 |
class MContactDataManagerObserver;
|
|
37 |
class MVPbkFieldType;
|
|
38 |
class CPbk2ImageManager;
|
|
39 |
class CVPbkTopContactManager;
|
|
40 |
class CRepository;
|
|
41 |
|
|
42 |
/**
|
|
43 |
* CEasyDialingContactDataManager
|
|
44 |
* Handles the loading and storing of thumbnail bitmaps
|
|
45 |
*/
|
|
46 |
class CEasyDialingContactDataManager :
|
|
47 |
public CBase,
|
|
48 |
public MPbk2ImageGetObserver,
|
|
49 |
public MVPbkSingleContactOperationObserver,
|
|
50 |
public MVPbkContactStoreListObserver,
|
|
51 |
public MVPbkOperationErrorObserver,
|
|
52 |
public MVPbkOperationResultObserver<MVPbkContactViewBase*>,
|
|
53 |
public MPbk2StoreConfigurationObserver,
|
|
54 |
public MPbkGlobalSettingObserver,
|
|
55 |
public MVPbkContactViewObserver
|
|
56 |
|
|
57 |
{
|
|
58 |
public:
|
|
59 |
|
|
60 |
/**
|
|
61 |
* Contact name display order
|
|
62 |
*/
|
|
63 |
enum TNameOrder
|
|
64 |
{
|
|
65 |
EFirstnameLastname,
|
|
66 |
ELastnameFirstname
|
|
67 |
};
|
|
68 |
|
|
69 |
public: // constructor and destructor
|
|
70 |
|
|
71 |
/**
|
|
72 |
* Two-phased constructor
|
|
73 |
*/
|
|
74 |
static CEasyDialingContactDataManager* NewL();
|
|
75 |
|
|
76 |
/**
|
|
77 |
* Destructor.
|
|
78 |
*/
|
|
79 |
~CEasyDialingContactDataManager();
|
|
80 |
|
|
81 |
private: // constructors
|
|
82 |
/**
|
|
83 |
* Constructor.
|
|
84 |
*/
|
|
85 |
CEasyDialingContactDataManager();
|
|
86 |
|
|
87 |
|
|
88 |
/**
|
|
89 |
* Second phase constructor of the class.
|
|
90 |
*/
|
|
91 |
void ConstructL();
|
|
92 |
|
|
93 |
public: // new methods
|
|
94 |
/**
|
|
95 |
* Sets the observer. Observer is notified when thumbnail loading is complete
|
|
96 |
* @param aObserver
|
|
97 |
*/
|
|
98 |
void SetObserver(MContactDataManagerObserver* aObserver);
|
|
99 |
|
|
100 |
/**
|
|
101 |
* Gets a handle to the VPbk contact manager
|
|
102 |
*/
|
|
103 |
CVPbkContactManager& ContactManager();
|
|
104 |
|
|
105 |
/**
|
|
106 |
* Sets the size of the thumbnails. If the loaded thumbnail is larger than
|
|
107 |
* the set size, thumnail is scaled to the size. If the set size is different
|
|
108 |
* from the old one, deletes all loaded thumbnails, which causes them to be
|
|
109 |
* reloaded when they are needed the next time.
|
|
110 |
* @param aSize The size of the thumbnails
|
|
111 |
*/
|
|
112 |
void SetThumbnailSize(const TSize& aSize);
|
|
113 |
|
|
114 |
/**
|
|
115 |
* Gets an id string for the thumbnail, if thumbnail exists for the contact.
|
|
116 |
* Used when the listbox items are created.
|
|
117 |
* @param aContact Contact link
|
|
118 |
* @param aMatchThumbnail If true, tries to match the link to the existing thumbnails
|
|
119 |
* @param aFav Is this contact a favourite
|
|
120 |
* @return id string. caller needs to delete this.
|
|
121 |
*/
|
|
122 |
HBufC* GetThumbnailIdL( MVPbkContactLink* aContact, TBool aMatchThumbnail, TBool aFav );
|
|
123 |
|
|
124 |
/**
|
|
125 |
* Gets internal index for a contact item with the given internal ID.
|
|
126 |
*/
|
|
127 |
TInt IndexForId( const TDesC& aId ) const;
|
|
128 |
|
|
129 |
/**
|
|
130 |
* Gets the thumbnail for a contact item. If thumbnail is not loaded, starts
|
|
131 |
* loading it.
|
|
132 |
* @param aIndex Internal index for the contact, obtained with IndexForId
|
|
133 |
* @param aThumbnail Outparam. Contact thumbnail. NULL if contact doesn't have thumbnail
|
|
134 |
* @return true if contact data has been loaded
|
|
135 |
*/
|
|
136 |
TBool GetThumbnail( TInt aIndex, CFbsBitmap*& aThumbnail );
|
|
137 |
|
|
138 |
/**
|
|
139 |
* Checks if contact is a favorite contact
|
|
140 |
* @param aIndex Internal index fo the contact, obtained with IndexForId
|
|
141 |
* @return ETrue if contact is a favorite contact
|
|
142 |
*/
|
|
143 |
TBool IsFav( TInt aIndex ) const;
|
|
144 |
|
|
145 |
/**
|
|
146 |
* Checks if contact is a SIM contact
|
|
147 |
* @param aIndex Internal index fo the contact, obtained with IndexForId
|
|
148 |
* @return ETrue if contact is a SIM contact
|
|
149 |
*/
|
|
150 |
TBool IsSimContact( TInt aIndex ) const;
|
|
151 |
|
|
152 |
/**
|
|
153 |
* Checks if contact is a service number contact
|
|
154 |
* @param aIndex Internal index fo the contact, obtained with IndexForId
|
|
155 |
* @return ETrue if contact is a service number contact
|
|
156 |
*/
|
|
157 |
TBool IsSdnContact( TInt aIndex ) const;
|
|
158 |
|
|
159 |
/**
|
|
160 |
* Deletes all loaded thumbnails and cancel asynchronous operations.
|
|
161 |
*/
|
|
162 |
void Reset();
|
|
163 |
|
|
164 |
/**
|
|
165 |
* Returs ETrue if voice call is available for current contact.
|
|
166 |
*/
|
|
167 |
TBool VoiceCallAvailable( TInt aIndex );
|
|
168 |
|
|
169 |
|
|
170 |
/**
|
|
171 |
* Returs ETrue if video call is available for current contact.
|
|
172 |
*/
|
|
173 |
TBool VideoCallAvailable( TInt aIndex );
|
|
174 |
|
|
175 |
|
|
176 |
/**
|
|
177 |
* Returs ETrue if uni-editor is available for current contact.
|
|
178 |
*/
|
|
179 |
TBool UniEditorAvailable( TInt aIndex );
|
|
180 |
|
|
181 |
|
|
182 |
/**
|
|
183 |
* Returns HBufC8 descriptor containing MVPbkContactLink
|
|
184 |
* link packaged.
|
|
185 |
*/
|
|
186 |
HBufC8* ContactLinkLC( TInt aIndex );
|
|
187 |
|
|
188 |
|
|
189 |
/**
|
|
190 |
* Sets the iContactThumbnailSetting member variable to either true or false
|
|
191 |
* which is read and if it is false then thumbnails are not shown
|
|
192 |
* @param aContactThumbnailSetting which is cenrep value for ContactThumbnailSetting
|
|
193 |
*/
|
|
194 |
void SetContactThumbnailSetting( TInt aContactThumbnailSetting );
|
|
195 |
|
|
196 |
/**
|
|
197 |
* Gets the iContactThumbnailSetting member variable to either true or false
|
|
198 |
* which is read and if it is false then thumbnails are not shown
|
|
199 |
* returns iContactThumbnailSetting which is cenrep value for ContactThumbnailSetting
|
|
200 |
*/
|
|
201 |
TBool GetContactThumbnailSetting( );
|
|
202 |
|
|
203 |
|
|
204 |
/**
|
|
205 |
* Flushes the asynchronous contact data of all contacts.
|
|
206 |
*/
|
|
207 |
void Reload();
|
|
208 |
|
|
209 |
/**
|
|
210 |
* Checks if contact link is a favourite. This is meant to be used for contacts that
|
|
211 |
* don't yet have contact data item. Since this needs to go through all the favourites,
|
|
212 |
* unnecessary calls should be avoided.
|
|
213 |
*/
|
|
214 |
TBool IsFavL( MVPbkContactLink* aLink );
|
|
215 |
|
|
216 |
/**
|
|
217 |
* @return the number of favourites in contact db
|
|
218 |
*/
|
|
219 |
TInt NumberOfFavsL();
|
|
220 |
|
|
221 |
/**
|
|
222 |
* Creates contact link to a favourite contact.
|
|
223 |
* @param aIndex Index of the favourite in favourites view
|
|
224 |
* @return the newly created link (added to cleanupstack)
|
|
225 |
*/
|
|
226 |
MVPbkContactLink* FavLinkLC( TInt aIndex );
|
|
227 |
|
|
228 |
/**
|
|
229 |
* Creates contact string for favourite contact. This string can be used directly
|
|
230 |
* in the contact listbox. F.ex. "Firstname Surname\tCompanyname".
|
|
231 |
* @param aIndex Index of the favourite in favourites view
|
|
232 |
* @param aNameOrder Name ordering to be used
|
|
233 |
* @return the newly created string (added to cleanupstack)
|
|
234 |
*/
|
|
235 |
HBufC* FavContactStringLC( TInt aIndex, TNameOrder aNameOrder );
|
|
236 |
|
|
237 |
/**
|
|
238 |
* @return Contact name display order
|
|
239 |
*/
|
|
240 |
TNameOrder NameOrder();
|
|
241 |
|
|
242 |
/**
|
|
243 |
* Get URIs of the contact stores which are currently shown in Phonebook.
|
|
244 |
* @param aUris On return, contains heap descriptors identifying the contact
|
|
245 |
* stores which are active. Ownership of the descriptors is given.
|
|
246 |
*/
|
|
247 |
void GetCurrentStoreUrisL( RPointerArray<TDesC>& aUris );
|
|
248 |
|
|
249 |
/**
|
|
250 |
* Pause the loading of contact data. This is used to make sure listbox is responsive
|
|
251 |
* and smooth during panning and flicking.
|
|
252 |
* @param aPause Pause on/off
|
|
253 |
*/
|
|
254 |
void Pause( TBool aPause );
|
|
255 |
|
|
256 |
public:
|
|
257 |
|
|
258 |
/**
|
|
259 |
* From MPbk2ImageGetObserver.
|
|
260 |
*/
|
|
261 |
void Pbk2ImageGetComplete(MPbk2ImageOperation& aOperation, CFbsBitmap* aBitmap);
|
|
262 |
|
|
263 |
|
|
264 |
/**
|
|
265 |
* From MPbk2ImageGetObserver.
|
|
266 |
*/
|
|
267 |
void Pbk2ImageGetFailed(MPbk2ImageOperation& aOperation, TInt aError);
|
|
268 |
|
|
269 |
public:
|
|
270 |
|
|
271 |
/**
|
|
272 |
* From MPbk2StoreConfigurationObserver
|
|
273 |
*/
|
|
274 |
void ConfigurationChanged();
|
|
275 |
|
|
276 |
/**
|
|
277 |
* From MPbk2StoreConfigurationObserver
|
|
278 |
*/
|
|
279 |
void ConfigurationChangedComplete();
|
|
280 |
|
|
281 |
|
|
282 |
public:
|
|
283 |
|
|
284 |
/**
|
|
285 |
* From MPbkGlobalSettingObserver.
|
|
286 |
*/
|
|
287 |
void SettingChangedL( MPbkGlobalSetting::TPbkGlobalSetting aKey );
|
|
288 |
|
|
289 |
private:
|
|
290 |
|
|
291 |
/**
|
|
292 |
* From MVPbkSingleContactOperationObserver.
|
|
293 |
*/
|
|
294 |
void VPbkSingleContactOperationComplete(
|
|
295 |
MVPbkContactOperationBase& aOperation,
|
|
296 |
MVPbkStoreContact* aContact );
|
|
297 |
|
|
298 |
|
|
299 |
/**
|
|
300 |
* From MVPbkSingleContactOperationObserver.
|
|
301 |
*/
|
|
302 |
void VPbkSingleContactOperationFailed(
|
|
303 |
MVPbkContactOperationBase& aOperation,
|
|
304 |
TInt aError );
|
|
305 |
|
|
306 |
private:
|
|
307 |
|
|
308 |
/**
|
|
309 |
* From MVPbkContactStoreListObserver.
|
|
310 |
*/
|
|
311 |
void StoreReady( MVPbkContactStore& aContactStore );
|
|
312 |
|
|
313 |
/**
|
|
314 |
* From MVPbkContactStoreListObserver.
|
|
315 |
*/
|
|
316 |
void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
|
|
317 |
|
|
318 |
/**
|
|
319 |
* From MVPbkContactStoreListObserver.
|
|
320 |
*/
|
|
321 |
void HandleStoreEventL( MVPbkContactStore& aContactStore,
|
|
322 |
TVPbkContactStoreEvent aStoreEvent );
|
|
323 |
|
|
324 |
/**
|
|
325 |
* From MVPbkContactStoreListObserver.
|
|
326 |
*/
|
|
327 |
void OpenComplete();
|
|
328 |
|
|
329 |
private:
|
|
330 |
/**
|
|
331 |
* From MVPbkOperationErrorObserver.
|
|
332 |
*/
|
|
333 |
void VPbkOperationFailed(
|
|
334 |
MVPbkContactOperationBase* aOperation,
|
|
335 |
TInt aError );
|
|
336 |
|
|
337 |
private:
|
|
338 |
/**
|
|
339 |
* From MVPbkOperationResultObserver.
|
|
340 |
*/
|
|
341 |
void VPbkOperationResultCompleted(
|
|
342 |
MVPbkContactOperationBase* aOperation,
|
|
343 |
MVPbkContactViewBase* aOperationResult );
|
|
344 |
|
|
345 |
|
|
346 |
private:
|
|
347 |
/**
|
|
348 |
* From MVPbkContactViewObserver.
|
|
349 |
* For observing changes to favourites view.
|
|
350 |
*/
|
|
351 |
virtual void ContactViewReady(
|
|
352 |
MVPbkContactViewBase& aView );
|
|
353 |
|
|
354 |
virtual void ContactViewUnavailable(
|
|
355 |
MVPbkContactViewBase& aView );
|
|
356 |
|
|
357 |
virtual void ContactAddedToView(
|
|
358 |
MVPbkContactViewBase& aView,
|
|
359 |
TInt aIndex,
|
|
360 |
const MVPbkContactLink& aContactLink );
|
|
361 |
|
|
362 |
virtual void ContactRemovedFromView(
|
|
363 |
MVPbkContactViewBase& aView,
|
|
364 |
TInt aIndex,
|
|
365 |
const MVPbkContactLink& aContactLink );
|
|
366 |
|
|
367 |
virtual void ContactViewError(
|
|
368 |
MVPbkContactViewBase& aView,
|
|
369 |
TInt aError,
|
|
370 |
TBool aErrorNotified );
|
|
371 |
|
|
372 |
private:
|
|
373 |
|
|
374 |
void InitReady();
|
|
375 |
|
|
376 |
TInt FindContactIndex( MVPbkContactLink* aContact );
|
|
377 |
|
|
378 |
void LoadNextContactDataL();
|
|
379 |
|
|
380 |
void DoHandleImageGetCompleteL(CFbsBitmap* aBitmap, TInt aIndex);
|
|
381 |
|
|
382 |
void HandleError(TInt aError);
|
|
383 |
|
|
384 |
void DoHandleContactOperationCompleteL( MVPbkStoreContact* aContact, TInt aIndex);
|
|
385 |
|
|
386 |
void GetAvailableServicesL( MVPbkStoreContact* aContact, TInt aIndex );
|
|
387 |
|
|
388 |
void InformObserver();
|
|
389 |
|
|
390 |
void UpdateNameOrderL();
|
|
391 |
|
|
392 |
void SetupFavStoreSearchedL();
|
|
393 |
|
|
394 |
void SetStoreFlagsForContact( CEasyDialingContactData* aContactData ) const;
|
|
395 |
|
|
396 |
private:
|
|
397 |
/** Phonebook store configuration. Owned. */
|
|
398 |
CPbk2StoreConfiguration* iPbkStoreConfiguration;
|
|
399 |
|
|
400 |
/** Array that contains all loaded contact data. Owned. */
|
|
401 |
RPointerArray<CEasyDialingContactData> iContactDataArray;
|
|
402 |
|
|
403 |
/** Array that contains indexes of thumbnails that are waiting to be loaded. Owned. */
|
|
404 |
RArray<TInt> iWaitingContacts;
|
|
405 |
|
|
406 |
/** Phonebook image manager. Owned. */
|
|
407 |
CPbk2ImageManager* iImageManager;
|
|
408 |
|
|
409 |
/** Parameters for image manager. Contains info about the size of thumbnails. */
|
|
410 |
TPbk2ImageManagerParams iImageManagerParams;
|
|
411 |
|
|
412 |
/** Field type. Not owned. */
|
|
413 |
const MVPbkFieldType* iThumbnailFieldType;
|
|
414 |
|
|
415 |
/** Image loading operation. Owned. */
|
|
416 |
MPbk2ImageOperation* iImageOperation;
|
|
417 |
|
|
418 |
/** Contact item for which a thumbnail is being loaded. Owned. */
|
|
419 |
MVPbkStoreContact* iStoreContact;
|
|
420 |
|
|
421 |
/** Virtual phonebook contact manager. Owned. */
|
|
422 |
CVPbkContactManager* iContactManager;
|
|
423 |
|
|
424 |
/** Contact data manager observer. Not owned. */
|
|
425 |
MContactDataManagerObserver* iObserver;
|
|
426 |
|
|
427 |
/** Top (i.e. favourite) contacts manager. Owned. */
|
|
428 |
CVPbkTopContactManager* iVPbkTopContactManager;
|
|
429 |
|
|
430 |
/** Virtual phonebook operation handle. Owned. */
|
|
431 |
MVPbkContactOperationBase* iContactOperation;
|
|
432 |
|
|
433 |
/** Variable which tells either to show or hide contact thumbnails. */
|
|
434 |
TBool iContactThumbnailSetting;
|
|
435 |
|
|
436 |
/** ETrue if asynchronous opening of the contac store is ready. */
|
|
437 |
TBool iStoreReady;
|
|
438 |
|
|
439 |
/** View to vpbk containing all favourite contacts. Owned. */
|
|
440 |
MVPbkContactViewBase* iFavsView;
|
|
441 |
|
|
442 |
/** Favourites view is ready to be used. */
|
|
443 |
TBool iFavsViewReady;
|
|
444 |
|
|
445 |
/** Contact store containing favourite contacts is configured to be searched. */
|
|
446 |
TBool iFavStoreSearched;
|
|
447 |
|
|
448 |
/** Virtual phonebook operation handle for getting favourites. Owned. */
|
|
449 |
MVPbkContactOperationBase* iFavsOperation;
|
|
450 |
|
|
451 |
/** Phonebook settings interface. */
|
|
452 |
MPbkGlobalSetting* iPbkSettings;
|
|
453 |
|
|
454 |
/** Contact name display order. */
|
|
455 |
TNameOrder iNameOrder;
|
|
456 |
|
|
457 |
/** Contact data manager pause status */
|
|
458 |
TBool iPause;
|
|
459 |
};
|
|
460 |
|
|
461 |
#endif //__EASYDIALINGTHUMBNAILMANAGER_H__
|