author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:31:22 +0300 | |
branch | RCL_3 |
changeset 81 | c26cc2a7c548 |
parent 62 | 5266b1f337bd |
permissions | -rw-r--r-- |
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 |
#include <e32std.h> |
|
19 |
#include <fbs.h> |
|
20 |
#include <CPbk2ImageManager.h> |
|
21 |
#include <CVPbkContactManager.h> |
|
22 |
#include <MVPbkContactStoreList.h> |
|
23 |
#include <MVPbkContactLink.h> |
|
24 |
#include <VPbkContactStoreUris.h> |
|
25 |
#include <TVPbkContactStoreUriPtr.h> |
|
26 |
#include <CVPbkTopContactManager.h> |
|
27 |
#include <MVPbkContactOperationBase.h> |
|
28 |
#include <TVPbkStoreContactAnalyzer.h> |
|
29 |
#include <MVPbkFieldType.h> |
|
30 |
#include <VPbkEng.rsg> |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
31 |
|
62 | 32 |
#include <MVPbkContactViewBase.h> |
33 |
#include <MVPbkBaseContactFieldCollection.h> |
|
34 |
#include <MVPbkContactFieldTextData.h> |
|
35 |
#include <MVPbkContactFieldData.h> |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
36 |
|
62 | 37 |
#include <CVPbkContactLinkArray.h> |
38 |
#include <MVPbkContactLink.h> |
|
39 |
#include <MVPbkContactOperationBase.h> |
|
40 |
#include <MVPbkOperationObserver.h> |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
41 |
#include <MVPbkContactStore.h> // MVPbkContactStore |
62 | 42 |
#include <MVPbkStoreContact.h> |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
43 |
#include <centralrepository.h> |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
44 |
|
62 | 45 |
#include <PbkGlobalSettingFactory.h> |
46 |
||
47 |
#include "easydialingcontactdata.h" |
|
48 |
#include "easydialingcontactdatamanager.h" |
|
49 |
#include "easydialingutils.h" |
|
50 |
#include "mcontactdatamanagerobserver.h" |
|
51 |
#include "easydialingcrkeys.h" |
|
52 |
#include "easydialinglogger.h" |
|
53 |
||
54 |
// --------------------------------------------------------------------------- |
|
55 |
// CEasyDialingContactDataManager::CEasyDialingContactDataManager |
|
56 |
// --------------------------------------------------------------------------- |
|
57 |
// |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
58 |
CEasyDialingContactDataManager::CEasyDialingContactDataManager(CVPbkContactManager* aContactManager) |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
59 |
: iImageOperation(NULL), iContactManager(aContactManager), iContactOperation(NULL), |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
60 |
iContactThumbnailSetting(ETrue), iStoreReady(EFalse) |
62 | 61 |
{ |
62 |
} |
|
63 |
||
64 |
||
65 |
// --------------------------------------------------------------------------- |
|
66 |
// CEasyDialingContactDataManager::~CEasyDialingContactDataManager |
|
67 |
// --------------------------------------------------------------------------- |
|
68 |
// |
|
69 |
CEasyDialingContactDataManager::~CEasyDialingContactDataManager() |
|
70 |
{ |
|
71 |
Reset(); |
|
72 |
iWaitingContacts.Close(); |
|
73 |
iContactDataArray.Close(); |
|
74 |
delete iImageManager; |
|
75 |
delete iVPbkTopContactManager; |
|
76 |
delete iImageOperation; |
|
77 |
delete iContactOperation; |
|
78 |
delete iFavsView; |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
79 |
if (iContactStore) |
62 | 80 |
{ |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
81 |
iContactStore->Close( *this); |
62 | 82 |
} |
83 |
||
84 |
if ( iPbkSettings ) |
|
85 |
{ |
|
86 |
iPbkSettings->Close(); |
|
87 |
} |
|
88 |
delete iPbkSettings; |
|
89 |
} |
|
90 |
||
91 |
// --------------------------------------------------------------------------- |
|
92 |
// CEasyDialingContactDataManager::ConstructL |
|
93 |
// --------------------------------------------------------------------------- |
|
94 |
// |
|
95 |
void CEasyDialingContactDataManager::ConstructL() |
|
96 |
{ |
|
97 |
iImageManager = CPbk2ImageManager::NewL(*iContactManager); |
|
98 |
||
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
99 |
TVPbkContactStoreUriPtr uri( VPbkContactStoreUris::DefaultCntDbUri() ); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
100 |
iContactStore = iContactManager->ContactStoresL().Find( uri ); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
101 |
|
62 | 102 |
iVPbkTopContactManager = CVPbkTopContactManager::NewL( *iContactManager ); |
103 |
||
104 |
iImageManagerParams.iFlags = TPbk2ImageManagerParams::EScaleImage | TPbk2ImageManagerParams::EKeepAspectRatio; |
|
105 |
iThumbnailFieldType = iContactManager->FieldTypes().Find( R_VPBK_FIELD_TYPE_THUMBNAILPIC ); |
|
106 |
||
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
107 |
// Open the store |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
108 |
iContactStore->OpenL( *this ); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
109 |
|
62 | 110 |
// Read easydialing setting from cenrep. |
111 |
CRepository* cenrep = CRepository::NewL( KCRUidEasyDialSettings ); |
|
112 |
CleanupStack::PushL( cenrep ); |
|
113 |
User::LeaveIfError( cenrep->Get( KEasyDialingContactThumbnails, iContactThumbnailSetting ) ); |
|
114 |
CleanupStack::PopAndDestroy( cenrep ); |
|
115 |
||
116 |
iPbkSettings = PbkGlobalSettingFactory::CreatePersistentSettingL(); |
|
117 |
iPbkSettings->ConnectL( MPbkGlobalSetting::EGeneralSettingCategory ); |
|
118 |
iPbkSettings->RegisterObserverL( this ); |
|
119 |
||
120 |
// Get name order from Phonebook settings |
|
121 |
UpdateNameOrderL(); |
|
122 |
} |
|
123 |
||
124 |
// --------------------------------------------------------------------------- |
|
125 |
// CEasyDialingContactDataManager::SetObserver |
|
126 |
// --------------------------------------------------------------------------- |
|
127 |
// |
|
128 |
void CEasyDialingContactDataManager::SetObserver(MContactDataManagerObserver* aObserver) |
|
129 |
{ |
|
130 |
iObserver = aObserver; |
|
131 |
} |
|
132 |
||
133 |
// --------------------------------------------------------------------------- |
|
134 |
// CEasyDialingContactDataManager::SetThumbnailSize |
|
135 |
// --------------------------------------------------------------------------- |
|
136 |
// |
|
137 |
void CEasyDialingContactDataManager::SetThumbnailSize(const TSize& aSize) |
|
138 |
{ |
|
139 |
if (iImageManagerParams.iSize != aSize) |
|
140 |
{ |
|
141 |
iImageManagerParams.iSize = aSize; |
|
142 |
Reload(); |
|
143 |
} |
|
144 |
} |
|
145 |
||
146 |
// --------------------------------------------------------------------------- |
|
147 |
// CEasyDialingContactDataManager::GetThumbnailIdL |
|
148 |
// --------------------------------------------------------------------------- |
|
149 |
// |
|
150 |
HBufC* CEasyDialingContactDataManager::GetThumbnailIdL( |
|
151 |
MVPbkContactLink* aContact, TBool aMatchThumbnails, TBool aFav ) |
|
152 |
{ |
|
153 |
LOGSTRING("CEasyDialingContactDataManager: GetThumbnailIdL"); |
|
154 |
TInt newIndex(KErrNotFound); |
|
155 |
if (aMatchThumbnails) |
|
156 |
{ |
|
157 |
newIndex = FindContactIndex( aContact ); |
|
158 |
} |
|
159 |
||
160 |
LOGSTRING1("newIndex = %d", newIndex); |
|
161 |
if (newIndex == KErrNotFound) |
|
162 |
{ |
|
163 |
MVPbkContactLink* newLink = aContact->CloneLC(); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
164 |
CEasyDialingContactData *newThumbnail = new (ELeave) CEasyDialingContactData(newLink); |
62 | 165 |
CleanupStack::Pop(); // newLink |
166 |
newIndex = iContactDataArray.Count(); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
167 |
CleanupStack::PushL(newThumbnail); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
168 |
iContactDataArray.AppendL(newThumbnail); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
169 |
CleanupStack::Pop(newThumbnail); |
62 | 170 |
} |
171 |
||
172 |
iContactDataArray[ newIndex ]->SetFav( aFav ); |
|
173 |
||
174 |
HBufC* id = HBufC::NewL( sizeof(TInt) * 2 ); // space for hex representation of TInt |
|
175 |
TPtr ptr = id->Des(); |
|
176 |
ptr.Num(newIndex, EHex); |
|
177 |
LOGSTRING1("CEasyDialingContactDataManager: GetThumbnailIdL returns %S", id); |
|
178 |
return id; |
|
179 |
} |
|
180 |
||
181 |
// --------------------------------------------------------------------------- |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
182 |
// CEasyDialingContactDataManager::GetThumbnailAndFav |
62 | 183 |
// --------------------------------------------------------------------------- |
184 |
// |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
185 |
TBool CEasyDialingContactDataManager::GetThumbnailAndFav(const TDesC& aId, CFbsBitmap*& aThumbnail, TBool& aFav) |
62 | 186 |
{ |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
187 |
LOGSTRING("CEasyDialingContactDataManager: GetThumbnailAndFav"); |
62 | 188 |
TUint idVal(0); |
189 |
TLex lex(aId); |
|
190 |
lex.Val(idVal, EHex); |
|
191 |
||
192 |
TBool retVal; |
|
193 |
||
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
194 |
CEasyDialingContactData* thumbnail = iContactDataArray[idVal]; |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
195 |
aFav = thumbnail->Fav(); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
196 |
if (thumbnail->IsLoaded()) |
62 | 197 |
{ |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
198 |
aThumbnail = thumbnail->Thumbnail(); |
62 | 199 |
retVal = ETrue; |
200 |
} |
|
201 |
else |
|
202 |
{ |
|
203 |
aThumbnail = NULL; |
|
204 |
retVal = EFalse; |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
205 |
if (iWaitingContacts.Find(idVal) == KErrNotFound) |
62 | 206 |
{ |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
207 |
LOGSTRING1("iWaitingContacts.Append %d", idVal); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
208 |
iWaitingContacts.Append(idVal); |
62 | 209 |
TRAPD(err, LoadNextContactDataL()); |
210 |
if (err) |
|
211 |
{ |
|
212 |
HandleError(err); |
|
213 |
} |
|
214 |
} |
|
215 |
} |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
216 |
LOGSTRING("CEasyDialingContactDataManager: GetThumbnailAndFav Exit"); |
62 | 217 |
return retVal; |
218 |
} |
|
219 |
||
220 |
// --------------------------------------------------------------------------- |
|
221 |
// CEasyDialingContactDataManager::IsFavL |
|
222 |
// --------------------------------------------------------------------------- |
|
223 |
// |
|
224 |
TBool CEasyDialingContactDataManager::IsFavL( MVPbkContactLink* aLink ) |
|
225 |
{ |
|
226 |
if ( iFavsView && iFavsViewReady && iFavsView->IndexOfLinkL( *aLink ) > KErrNotFound ) |
|
227 |
{ |
|
228 |
return ETrue; |
|
229 |
} |
|
230 |
else |
|
231 |
{ |
|
232 |
return EFalse; |
|
233 |
} |
|
234 |
} |
|
235 |
||
236 |
// --------------------------------------------------------------------------- |
|
237 |
// CEasyDialingContactDataManager::NumberOfFavsL |
|
238 |
// --------------------------------------------------------------------------- |
|
239 |
// |
|
240 |
TInt CEasyDialingContactDataManager::NumberOfFavsL() |
|
241 |
{ |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
242 |
if ( iFavsView && iFavsViewReady ) |
62 | 243 |
{ |
244 |
return iFavsView->ContactCountL(); |
|
245 |
} |
|
246 |
else |
|
247 |
{ |
|
248 |
return 0; |
|
249 |
} |
|
250 |
} |
|
251 |
||
252 |
// --------------------------------------------------------------------------- |
|
253 |
// CEasyDialingContactDataManager::FavLinkLC |
|
254 |
// --------------------------------------------------------------------------- |
|
255 |
// |
|
256 |
MVPbkContactLink* CEasyDialingContactDataManager::FavLinkLC( TInt aIndex ) |
|
257 |
{ |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
258 |
if ( !iFavsView || !iFavsViewReady ) |
62 | 259 |
{ |
260 |
// LC function should not return normally unless it has actually |
|
261 |
// put something to cleanup stack |
|
262 |
User::Leave( KErrNotFound ); |
|
263 |
} |
|
264 |
return iFavsView->ContactAtL( aIndex ).CreateLinkLC(); |
|
265 |
} |
|
266 |
||
267 |
// --------------------------------------------------------------------------- |
|
268 |
// CEasyDialingContactDataManager::FavContactStringLC |
|
269 |
// --------------------------------------------------------------------------- |
|
270 |
// |
|
271 |
HBufC* CEasyDialingContactDataManager::FavContactStringLC( TInt aIndex, TNameOrder aNameOrder ) |
|
272 |
{ |
|
273 |
const MVPbkBaseContactFieldCollection& fields = iFavsView->ContactAtL( aIndex ).Fields(); |
|
274 |
TPtrC firstName; |
|
275 |
TPtrC lastName; |
|
276 |
TPtrC companyName; |
|
277 |
for ( TInt i = 0; i < fields.FieldCount(); i++ ) |
|
278 |
{ |
|
279 |
const MVPbkFieldType* fieldType = fields.FieldAt( i ).MatchFieldType( 0 ); |
|
280 |
switch ( fieldType->FieldTypeResId() ) |
|
281 |
{ |
|
282 |
case R_VPBK_FIELD_TYPE_LASTNAME: |
|
283 |
{ |
|
284 |
const MVPbkContactFieldTextData& data = |
|
285 |
MVPbkContactFieldTextData::Cast( fields.FieldAt( i ).FieldData() ); |
|
286 |
lastName.Set( data.Text() ); |
|
287 |
} |
|
288 |
break; |
|
289 |
case R_VPBK_FIELD_TYPE_FIRSTNAME: |
|
290 |
{ |
|
291 |
const MVPbkContactFieldTextData& data = |
|
292 |
MVPbkContactFieldTextData::Cast( fields.FieldAt( i ).FieldData() ); |
|
293 |
firstName.Set( data.Text() ); |
|
294 |
} |
|
295 |
break; |
|
296 |
case R_VPBK_FIELD_TYPE_COMPANYNAME: |
|
297 |
{ |
|
298 |
const MVPbkContactFieldTextData& data = |
|
299 |
MVPbkContactFieldTextData::Cast( fields.FieldAt( i ).FieldData() ); |
|
300 |
companyName.Set( data.Text() ); |
|
301 |
} |
|
302 |
break; |
|
303 |
default: |
|
304 |
break; |
|
305 |
} |
|
306 |
} |
|
307 |
||
308 |
return EasyDialingUtils::CreateContactStringLC( firstName, lastName, companyName, aNameOrder ); |
|
309 |
} |
|
310 |
||
311 |
// --------------------------------------------------------------------------- |
|
312 |
// CEasyDialingContactDataManager::NameOrder |
|
313 |
// --------------------------------------------------------------------------- |
|
314 |
// |
|
315 |
CEasyDialingContactDataManager::TNameOrder CEasyDialingContactDataManager::NameOrder() |
|
316 |
{ |
|
317 |
return iNameOrder; |
|
318 |
} |
|
319 |
||
320 |
// --------------------------------------------------------------------------- |
|
321 |
// CEasyDialingContactDataManager::Pause |
|
322 |
// --------------------------------------------------------------------------- |
|
323 |
// |
|
324 |
void CEasyDialingContactDataManager::Pause( TBool aPause ) |
|
325 |
{ |
|
326 |
if ( iPause != aPause ) |
|
327 |
{ |
|
328 |
iPause = aPause; |
|
329 |
||
330 |
if ( !iPause && iWaitingContacts.Count() ) |
|
331 |
{ |
|
332 |
TRAPD( err, LoadNextContactDataL()); |
|
333 |
if ( err ) |
|
334 |
{ |
|
335 |
HandleError(err); |
|
336 |
} |
|
337 |
} |
|
338 |
} |
|
339 |
} |
|
340 |
||
341 |
// --------------------------------------------------------------------------- |
|
342 |
// CEasyDialingContactDataManager::InitReady |
|
343 |
// --------------------------------------------------------------------------- |
|
344 |
// |
|
345 |
void CEasyDialingContactDataManager::InitReady() |
|
346 |
{ |
|
347 |
// Initialization is ready. we can start loading contact data, if needed. |
|
348 |
// (It is unlikely that there is any data to load at this point) |
|
349 |
iStoreReady = ETrue; |
|
350 |
if ( iWaitingContacts.Count() ) |
|
351 |
{ |
|
352 |
TRAPD( err, LoadNextContactDataL() ) |
|
353 |
if ( err ) |
|
354 |
{ |
|
355 |
HandleError( err ); |
|
356 |
} |
|
357 |
} |
|
358 |
} |
|
359 |
||
360 |
// --------------------------------------------------------------------------- |
|
361 |
// CEasyDialingContactDataManager::FindContactIndex |
|
362 |
// --------------------------------------------------------------------------- |
|
363 |
// |
|
364 |
TInt CEasyDialingContactDataManager::FindContactIndex( MVPbkContactLink* aContact ) |
|
365 |
{ |
|
366 |
TInt index( KErrNotFound ); |
|
367 |
||
368 |
for ( TInt i = 0; i < iContactDataArray.Count(); i++ ) |
|
369 |
{ |
|
370 |
if ( iContactDataArray[i]->ContactLink()->IsSame( *aContact ) ) |
|
371 |
{ |
|
372 |
index = i; |
|
373 |
break; |
|
374 |
} |
|
375 |
} |
|
376 |
||
377 |
return index; |
|
378 |
} |
|
379 |
||
380 |
||
381 |
// --------------------------------------------------------------------------- |
|
382 |
// CEasyDialingContactDataManager::LoadNextContactDataL |
|
383 |
// --------------------------------------------------------------------------- |
|
384 |
// |
|
385 |
void CEasyDialingContactDataManager::LoadNextContactDataL() |
|
386 |
{ |
|
387 |
LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL"); |
|
388 |
if ( !iImageOperation && !iContactOperation && iWaitingContacts.Count() && iStoreReady && !iPause ) |
|
389 |
{ |
|
390 |
// first we need to load the contact item |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
391 |
CEasyDialingContactData* tn = iContactDataArray[iWaitingContacts[0]]; |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
392 |
iContactOperation = iContactManager->RetrieveContactL( *(tn->ContactLink()), *this); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
393 |
|
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
394 |
if (!iContactOperation) |
62 | 395 |
{ |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
396 |
tn->LoadingComplete(); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
397 |
RDebug::Print(_L("iWaitingContacts.Remove %d"), iWaitingContacts[0]); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
398 |
iWaitingContacts.Remove(0); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
399 |
LoadNextContactDataL(); |
62 | 400 |
} |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
401 |
} |
62 | 402 |
LOGSTRING("CEasyDialingContactDataManager: LoadNextContactDataL Exit"); |
403 |
} |
|
404 |
||
405 |
// --------------------------------------------------------------------------- |
|
406 |
// CEasyDialingContactDataManager::PbkImageGetComplete |
|
407 |
// From MPbkImageGetObserver |
|
408 |
// --------------------------------------------------------------------------- |
|
409 |
// |
|
410 |
void CEasyDialingContactDataManager::Pbk2ImageGetComplete(MPbk2ImageOperation& aOperation, CFbsBitmap* aBitmap) |
|
411 |
{ |
|
412 |
LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetComplete"); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
413 |
TInt index = iWaitingContacts[0]; |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
414 |
LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
415 |
iWaitingContacts.Remove(0); |
62 | 416 |
delete &aOperation; |
417 |
iImageOperation = NULL; |
|
418 |
delete iStoreContact; |
|
419 |
iStoreContact = NULL; |
|
420 |
||
421 |
TRAPD(err, DoHandleImageGetCompleteL(aBitmap, index)); |
|
422 |
if (err) |
|
423 |
{ |
|
424 |
HandleError(err); |
|
425 |
} |
|
426 |
LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetComplete Exit"); |
|
427 |
} |
|
428 |
||
429 |
// --------------------------------------------------------------------------- |
|
430 |
// CEasyDialingContactDataManager::PbkImageGetFailed |
|
431 |
// From MPbkImageGetObserver |
|
432 |
// --------------------------------------------------------------------------- |
|
433 |
// |
|
434 |
void CEasyDialingContactDataManager::Pbk2ImageGetFailed(MPbk2ImageOperation& aOperation, TInt /*aError*/) |
|
435 |
{ |
|
436 |
LOGSTRING("CEasyDialingContactDataManager: Pbk2ImageGetFailed"); |
|
437 |
Pbk2ImageGetComplete(aOperation, NULL); |
|
438 |
} |
|
439 |
||
440 |
// --------------------------------------------------------------------------- |
|
441 |
// CEasyDialingContactDataManager::SettingChangedL |
|
442 |
// From MPbkGlobalSettingObserver |
|
443 |
// --------------------------------------------------------------------------- |
|
444 |
// |
|
445 |
void CEasyDialingContactDataManager::SettingChangedL( MPbkGlobalSetting::TPbkGlobalSetting aKey ) |
|
446 |
{ |
|
447 |
if ( aKey == MPbkGlobalSetting::ENameOrdering ) |
|
448 |
{ |
|
449 |
UpdateNameOrderL(); |
|
450 |
if ( iObserver ) |
|
451 |
{ |
|
452 |
iObserver->NameOrderChanged(); |
|
453 |
} |
|
454 |
} |
|
455 |
} |
|
456 |
||
457 |
// --------------------------------------------------------------------------- |
|
458 |
// CEasyDialingContactDataManager::UpdateNameOrderL |
|
459 |
// Update name order according to Phonebook setting |
|
460 |
// --------------------------------------------------------------------------- |
|
461 |
// |
|
462 |
void CEasyDialingContactDataManager::UpdateNameOrderL() |
|
463 |
{ |
|
464 |
/* |
|
465 |
* Phonebook name ordering flag, integer value, possible values: |
|
466 |
* 0: name order Lastname Firstname |
|
467 |
* 1: name order Firstname Lastname |
|
468 |
* 2: name order undefined |
|
469 |
*/ |
|
470 |
TInt nameOrderSetting; |
|
471 |
iPbkSettings->Get( MPbkGlobalSetting::ENameOrdering, nameOrderSetting ); |
|
472 |
||
473 |
switch ( nameOrderSetting ) |
|
474 |
{ |
|
475 |
case 0: |
|
476 |
{ |
|
477 |
iNameOrder = ELastnameFirstname; |
|
478 |
break; |
|
479 |
} |
|
480 |
case 1: |
|
481 |
{ |
|
482 |
iNameOrder = EFirstnameLastname; |
|
483 |
break; |
|
484 |
} |
|
485 |
case 2: |
|
486 |
default: |
|
487 |
{ |
|
488 |
// Decide name order based on UI language: lastname-firstname |
|
489 |
// for Chinese, firstname-lastname for the rest of languages. |
|
490 |
TLanguage uiLang = User::Language(); |
|
491 |
if ( uiLang == ELangPrcChinese || |
|
492 |
uiLang == ELangHongKongChinese || |
|
493 |
uiLang == ELangTaiwanChinese ) |
|
494 |
{ |
|
495 |
iNameOrder = ELastnameFirstname; |
|
496 |
} |
|
497 |
else |
|
498 |
{ |
|
499 |
iNameOrder = EFirstnameLastname; |
|
500 |
} |
|
501 |
} |
|
502 |
} |
|
503 |
} |
|
504 |
||
505 |
// --------------------------------------------------------------------------- |
|
506 |
// CEasyDialingContactDataManager::DoHandleImageGetCompleteL |
|
507 |
// --------------------------------------------------------------------------- |
|
508 |
// |
|
509 |
void CEasyDialingContactDataManager::DoHandleImageGetCompleteL(CFbsBitmap* aBitmap, TInt aIndex) |
|
510 |
{ |
|
511 |
LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL"); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
512 |
CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
513 |
tn->LoadingComplete(); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
514 |
if (aBitmap) |
62 | 515 |
{ |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
516 |
tn->SetThumbnail(aBitmap); |
62 | 517 |
} |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
518 |
|
62 | 519 |
LoadNextContactDataL(); |
520 |
InformObserver(); |
|
521 |
LOGSTRING("CEasyDialingContactDataManager: DoHandleImageGetCompleteL Exit"); |
|
522 |
} |
|
523 |
||
524 |
// --------------------------------------------------------------------------- |
|
525 |
// CEasyDialingContactDataManager::Reset |
|
526 |
// --------------------------------------------------------------------------- |
|
527 |
// |
|
528 |
void CEasyDialingContactDataManager::Reset() |
|
529 |
{ |
|
530 |
LOGSTRING("CEasyDialingContactDataManager: Reset"); |
|
531 |
delete iImageOperation; |
|
532 |
iImageOperation = NULL; |
|
533 |
delete iContactOperation; |
|
534 |
iContactOperation = NULL; |
|
535 |
delete iStoreContact; |
|
536 |
iStoreContact = NULL; |
|
537 |
iWaitingContacts.Reset(); |
|
538 |
iContactDataArray.ResetAndDestroy(); |
|
539 |
iPause = EFalse; |
|
540 |
} |
|
541 |
||
542 |
// --------------------------------------------------------------------------- |
|
543 |
// CEasyDialingContactDataManager::VoiceCallAvailable |
|
544 |
// --------------------------------------------------------------------------- |
|
545 |
// |
|
546 |
TBool CEasyDialingContactDataManager::VoiceCallAvailable( TInt aIndex ) |
|
547 |
{ |
|
548 |
LOGSTRING("CEasyDialingContactDataManager: VoiceCallAvailable"); |
|
549 |
||
550 |
TBool ret( EFalse ); |
|
551 |
||
552 |
if( aIndex >= 0 ) |
|
553 |
{ |
|
554 |
// If the parsed index is valid, return the availability. |
|
555 |
ret = iContactDataArray[ aIndex ]->VoiceCallAvailable(); |
|
556 |
} |
|
557 |
||
558 |
LOGSTRING1("CEasyDialingContactDataManager: VoiceCallAvailable returns %d", ret); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
559 |
return ret; |
62 | 560 |
} |
561 |
||
562 |
||
563 |
// --------------------------------------------------------------------------- |
|
564 |
// CEasyDialingContactDataManager::VideoCallAvailable |
|
565 |
// --------------------------------------------------------------------------- |
|
566 |
// |
|
567 |
TBool CEasyDialingContactDataManager::VideoCallAvailable( TInt aIndex ) |
|
568 |
{ |
|
569 |
LOGSTRING("CEasyDialingContactDataManager: VideoCallAvailable"); |
|
570 |
||
571 |
TBool ret( EFalse ); |
|
572 |
||
573 |
if( aIndex >= 0 ) |
|
574 |
{ |
|
575 |
// If the parsed index is valid, return the availability. |
|
576 |
ret = iContactDataArray[ aIndex ]->VideoCallAvailable(); |
|
577 |
} |
|
578 |
||
579 |
LOGSTRING1("CEasyDialingContactDataManager: VideoCallAvailable returns %d", ret); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
580 |
return ret; |
62 | 581 |
} |
582 |
||
583 |
||
584 |
// --------------------------------------------------------------------------- |
|
585 |
// CEasyDialingContactDataManager::UniEditorAvailable |
|
586 |
// --------------------------------------------------------------------------- |
|
587 |
// |
|
588 |
TBool CEasyDialingContactDataManager::UniEditorAvailable( TInt aIndex ) |
|
589 |
{ |
|
590 |
LOGSTRING("CEasyDialingContactDataManager: UniEditorAvailable"); |
|
591 |
||
592 |
TBool ret( EFalse ); |
|
593 |
||
594 |
if( aIndex >= 0 ) |
|
595 |
{ |
|
596 |
// If the parsed index is valid, return the availability. |
|
597 |
ret = iContactDataArray[ aIndex ]->UniEditorAvailable(); |
|
598 |
} |
|
599 |
||
600 |
LOGSTRING1("CEasyDialingContactDataManager: UniEditorAvailable returns %d", ret); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
601 |
return ret; |
62 | 602 |
} |
603 |
||
604 |
||
605 |
// --------------------------------------------------------------------------- |
|
606 |
// CEasyDialingContactDataManager::ContactLinkLC |
|
607 |
// --------------------------------------------------------------------------- |
|
608 |
// |
|
609 |
HBufC8* CEasyDialingContactDataManager::ContactLinkLC( TInt aIndex ) |
|
610 |
{ |
|
611 |
LOGSTRING( "CEasyDialingContactDataManager: ContactLinkLC" ); |
|
612 |
||
613 |
if ( aIndex < 0 || aIndex >= iContactDataArray.Count() ) |
|
614 |
{ |
|
615 |
User::Leave( KErrArgument ); |
|
616 |
} |
|
617 |
||
618 |
return iContactDataArray[ aIndex ]->ContactLink()->PackLC(); |
|
619 |
} |
|
620 |
||
621 |
||
622 |
// --------------------------------------------------------------------------- |
|
623 |
// CEasyDialingContactDataManager::HandleError |
|
624 |
// --------------------------------------------------------------------------- |
|
625 |
// |
|
626 |
void CEasyDialingContactDataManager::HandleError(TInt /*aError*/) |
|
627 |
{ |
|
628 |
LOGSTRING("CEasyDialingContactDataManager: HandleError"); |
|
629 |
// Something went wrong, but there is no need to panic. |
|
630 |
// Cancel async operations and notify observer that we are done. |
|
631 |
iWaitingContacts.Reset(); |
|
632 |
delete iImageOperation; |
|
633 |
iImageOperation = NULL; |
|
634 |
delete iContactOperation; |
|
635 |
iContactOperation = NULL; |
|
636 |
||
637 |
// Also mark all contact data as loaded. Otherwise it would just be |
|
638 |
// loaded again, which would cause infinite loop if there is a permanent |
|
639 |
// problem. |
|
640 |
for ( TInt i = 0; i < iContactDataArray.Count(); i++ ) |
|
641 |
{ |
|
642 |
iContactDataArray[i]->LoadingComplete(); |
|
643 |
} |
|
644 |
||
645 |
if ( iObserver ) |
|
646 |
{ |
|
647 |
iObserver->AllContactDataLoaded(); |
|
648 |
} |
|
649 |
} |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
650 |
|
62 | 651 |
// --------------------------------------------------------------------------- |
652 |
// CEasyDialingContactDataManager::StoreReady |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
653 |
// from MVPbkContactStoreObserver |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
654 |
// Called when the contact store is ready to be used, signals |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
655 |
// the next engine state. |
62 | 656 |
// @param aContactStore The store that is ready. |
657 |
// --------------------------------------------------------------------------- |
|
658 |
// |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
659 |
|
62 | 660 |
void CEasyDialingContactDataManager::StoreReady( MVPbkContactStore& /*aContactStore*/ ) |
661 |
{ |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
662 |
// next open the favourites view |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
663 |
TRAPD( err, iVPbkTopContactManager->GetTopContactsViewL( *this, *this ) ); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
664 |
if ( err ) |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
665 |
{ |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
666 |
HandleError( err ); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
667 |
} |
62 | 668 |
} |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
669 |
|
62 | 670 |
// --------------------------------------------------------------------------- |
671 |
// CEasyDialingContactDataManager::StoreUnavailable |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
672 |
// from MVPbkContactStoreObserver |
62 | 673 |
// Called when a contact store becomes unavailable. |
674 |
// @param aContactStore The store that became unavailable. |
|
675 |
// @param aReason The reason why the store is unavailable. |
|
676 |
// This is one of the system wide error codes. |
|
677 |
// --------------------------------------------------------------------------- |
|
678 |
// |
|
679 |
void CEasyDialingContactDataManager::StoreUnavailable( MVPbkContactStore& /*aContactStore*/, |
|
680 |
TInt /*aReason*/ ) |
|
681 |
{ |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
682 |
// Opening main contact database failed. Easydialing can operate without |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
683 |
// it, but thumbnails and favourite stars can't be shown, and availability |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
684 |
// of action menu items can't be checked. |
62 | 685 |
// Of course, if easydialing can't open the database, probably PCSServer |
686 |
// can't open it either... |
|
687 |
} |
|
688 |
||
689 |
// --------------------------------------------------------------------------- |
|
690 |
// CEasyDialingContactDataManager::HandleStoreEventL |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
691 |
// from MVPbkContactStoreObserver |
62 | 692 |
// Called when changes occur in the contact store. |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
693 |
// IGNORED. |
62 | 694 |
// @param aContactStore A store whose event it is. |
695 |
// @param aStoreEvent The event that has occurred. |
|
696 |
// --------------------------------------------------------------------------- |
|
697 |
// |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
698 |
void CEasyDialingContactDataManager::HandleStoreEventL(MVPbkContactStore& /*aContactStore*/, |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
699 |
TVPbkContactStoreEvent /*aStoreEvent*/) |
62 | 700 |
{ |
701 |
} |
|
702 |
||
703 |
// --------------------------------------------------------------------------- |
|
704 |
// CEasyDialingContactDataManager::VPbkOperationFailed |
|
705 |
// --------------------------------------------------------------------------- |
|
706 |
// |
|
707 |
void CEasyDialingContactDataManager::VPbkOperationFailed( |
|
708 |
MVPbkContactOperationBase* /*aOperation*/, |
|
709 |
TInt /*aError*/ ) |
|
710 |
{ |
|
711 |
// Loading list of favourite contacts failed. |
|
712 |
// Continue as if none of the contacts are favourited. |
|
713 |
delete iFavsOperation; |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
714 |
iFavsOperation = NULL; |
62 | 715 |
delete iFavsView; |
716 |
iFavsView = NULL; |
|
717 |
iFavsViewReady = EFalse; |
|
718 |
||
719 |
InitReady(); |
|
720 |
} |
|
721 |
||
722 |
// --------------------------------------------------------------------------- |
|
723 |
// CEasyDialingContactDataManager::VPbkOperationResultCompleted |
|
724 |
// --------------------------------------------------------------------------- |
|
725 |
// |
|
726 |
void CEasyDialingContactDataManager::VPbkOperationResultCompleted( |
|
727 |
MVPbkContactOperationBase* /*aOperation*/, |
|
728 |
MVPbkContactViewBase* aOperationResult ) |
|
729 |
{ |
|
730 |
delete iFavsOperation; |
|
731 |
iFavsOperation = NULL; |
|
732 |
delete iFavsView; |
|
733 |
iFavsView = aOperationResult; |
|
734 |
iFavsViewReady = ETrue; |
|
735 |
||
736 |
// Leave can be safely ignored. Notifications of favourites view changes |
|
737 |
// will not work, but otherwise Easydialing will work correctly. |
|
738 |
TRAP_IGNORE( iFavsView->AddObserverL( *this ) ); |
|
739 |
||
740 |
InitReady(); |
|
741 |
} |
|
742 |
||
743 |
// --------------------------------------------------------------------------- |
|
744 |
// CEasyDialingContactDataManager::ContactViewReady |
|
745 |
// From MVPbkContactViewObserver. |
|
746 |
// --------------------------------------------------------------------------- |
|
747 |
// |
|
748 |
void CEasyDialingContactDataManager::ContactViewReady( |
|
749 |
MVPbkContactViewBase& aView ) |
|
750 |
{ |
|
751 |
LOGSTRING("CEasyDialingContactDataManager: ContactViewReady"); |
|
752 |
||
753 |
if ( iFavsView == &aView ) |
|
754 |
{ |
|
755 |
iFavsViewReady = ETrue; |
|
756 |
} |
|
757 |
} |
|
758 |
||
759 |
// --------------------------------------------------------------------------- |
|
760 |
// CEasyDialingContactDataManager::ContactViewUnavailable |
|
761 |
// From MVPbkContactViewObserver. |
|
762 |
// --------------------------------------------------------------------------- |
|
763 |
// |
|
764 |
void CEasyDialingContactDataManager::ContactViewUnavailable( |
|
765 |
MVPbkContactViewBase& aView ) |
|
766 |
{ |
|
767 |
LOGSTRING("CEasyDialingContactDataManager: ContactViewUnavailable"); |
|
768 |
||
769 |
if ( iFavsView == &aView ) |
|
770 |
{ |
|
771 |
iFavsViewReady = EFalse; |
|
772 |
} |
|
773 |
} |
|
774 |
||
775 |
// --------------------------------------------------------------------------- |
|
776 |
// CEasyDialingContactDataManager::ContactAddedToView |
|
777 |
// From MVPbkContactViewObserver. |
|
778 |
// --------------------------------------------------------------------------- |
|
779 |
// |
|
780 |
void CEasyDialingContactDataManager::ContactAddedToView( |
|
781 |
MVPbkContactViewBase& aView, |
|
782 |
TInt /*aIndex*/, |
|
783 |
const MVPbkContactLink& /*aContactLink*/ ) |
|
784 |
{ |
|
785 |
LOGSTRING("CEasyDialingContactDataManager: ContactAddedToView"); |
|
786 |
||
787 |
if ( iFavsView == &aView ) |
|
788 |
{ |
|
789 |
iObserver->FavouritesChanged(); |
|
790 |
} |
|
791 |
} |
|
792 |
||
793 |
// --------------------------------------------------------------------------- |
|
794 |
// CEasyDialingContactDataManager::ContactRemovedFromView |
|
795 |
// From MVPbkContactViewObserver. |
|
796 |
// --------------------------------------------------------------------------- |
|
797 |
// |
|
798 |
void CEasyDialingContactDataManager::ContactRemovedFromView( |
|
799 |
MVPbkContactViewBase& aView, |
|
800 |
TInt /*aIndex*/, |
|
801 |
const MVPbkContactLink& /*aContactLink*/ ) |
|
802 |
{ |
|
803 |
LOGSTRING("CEasyDialingContactDataManager: ContactRemovedFromView"); |
|
804 |
||
805 |
if ( iFavsView == &aView ) |
|
806 |
{ |
|
807 |
iObserver->FavouritesChanged(); |
|
808 |
} |
|
809 |
} |
|
810 |
||
811 |
// --------------------------------------------------------------------------- |
|
812 |
// CEasyDialingContactDataManager::ContactViewError |
|
813 |
// From MVPbkContactViewObserver. |
|
814 |
// --------------------------------------------------------------------------- |
|
815 |
// |
|
816 |
void CEasyDialingContactDataManager::ContactViewError( |
|
817 |
MVPbkContactViewBase& aView, |
|
818 |
TInt /*aError*/, |
|
819 |
TBool /*aErrorNotified*/ ) |
|
820 |
{ |
|
821 |
LOGSTRING("CEasyDialingContactDataManager: ContactViewError"); |
|
822 |
||
823 |
if ( iFavsView == &aView ) |
|
824 |
{ |
|
825 |
iFavsViewReady = EFalse; |
|
826 |
} |
|
827 |
} |
|
828 |
||
829 |
// --------------------------------------------------------------------------- |
|
830 |
// CEasyDialingContactDataManager::DoHandleContactOperationCompleteL |
|
831 |
// --------------------------------------------------------------------------- |
|
832 |
// |
|
833 |
void CEasyDialingContactDataManager::DoHandleContactOperationCompleteL( |
|
834 |
MVPbkStoreContact* aContact, TInt aIndex) |
|
835 |
{ |
|
836 |
LOGSTRING("CEasyDialingContactDataManager: DoHandleContactOperationCompleteL"); |
|
837 |
if (aContact) |
|
838 |
{ |
|
839 |
||
840 |
__ASSERT_DEBUG((!iStoreContact && !iImageOperation), User::Panic(_L("CEasyDialingContactDataManager"), 1)); |
|
841 |
iStoreContact = aContact; |
|
842 |
||
843 |
// Find out the available communication methods for the contact. |
|
844 |
GetAvailableServicesL( aContact, aIndex ); |
|
845 |
||
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
846 |
|
62 | 847 |
// Next initiate async thumbnail get operation. |
848 |
||
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
849 |
if(GetContactThumbnailSetting()) // reads the iContactThumbnailSetting value if it is false we dont fetch images |
62 | 850 |
{ |
851 |
if (iImageManager->HasImage(*iStoreContact, *iThumbnailFieldType)) |
|
852 |
{ |
|
853 |
iImageOperation = iImageManager->GetImageAsyncL( |
|
854 |
&iImageManagerParams, |
|
855 |
*iStoreContact, |
|
856 |
*iThumbnailFieldType, |
|
857 |
*this); |
|
858 |
} |
|
859 |
} |
|
860 |
if (!iImageOperation) |
|
861 |
{ |
|
862 |
CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
|
863 |
tn->LoadingComplete(); |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
864 |
LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
62 | 865 |
iWaitingContacts.Remove(0); |
866 |
delete iStoreContact; |
|
867 |
iStoreContact = NULL; |
|
868 |
LoadNextContactDataL(); |
|
869 |
InformObserver(); |
|
870 |
} |
|
871 |
} |
|
872 |
else |
|
873 |
{ |
|
874 |
// Opening contact failed. Mark contact data loaded, so it's not opened again. |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
875 |
CEasyDialingContactData *tn = iContactDataArray[aIndex]; |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
876 |
tn->LoadingComplete(); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
877 |
LOGSTRING1("iWaitingContacts.Remove %d", iWaitingContacts[0]); |
62 | 878 |
iWaitingContacts.Remove(0); |
879 |
LoadNextContactDataL(); |
|
880 |
InformObserver(); |
|
881 |
} |
|
882 |
LOGSTRING("CEasyDialingContactDataManager: DoHandleContactOperationCompleteL Exit"); |
|
883 |
} |
|
884 |
||
885 |
||
886 |
// --------------------------------------------------------------------------- |
|
887 |
// CEasyDialingContactDataManager::GetAvailableServicesL |
|
888 |
// |
|
889 |
// Reads from parameter contact which services, i.e. communication methods, |
|
890 |
// can be used with this contact. |
|
891 |
// --------------------------------------------------------------------------- |
|
892 |
// |
|
893 |
void CEasyDialingContactDataManager::GetAvailableServicesL( MVPbkStoreContact* aContact, TInt aIndex ) |
|
894 |
{ |
|
895 |
LOGSTRING1("CEasyDialingContactDataManager: GetAvailableServicesL index = %d", aIndex); |
|
896 |
TVPbkStoreContactAnalyzer analyzer( *iContactManager, aContact ); |
|
897 |
||
898 |
CEasyDialingContactData* contactData = iContactDataArray[aIndex]; |
|
899 |
||
900 |
// Voice call is available if either circuit-switched call or voip call is available. |
|
901 |
TBool csdCall = (analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EVoiceCallSelector ) != KErrNotFound); |
|
902 |
TBool voipCall = (analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EVOIPCallSelector ) != KErrNotFound); |
|
903 |
||
904 |
contactData->SetVoiceCallAvailable( csdCall || voipCall ); |
|
905 |
||
906 |
contactData->SetVideoCallAvailable( |
|
907 |
analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EVideoCallSelector ) != KErrNotFound ); |
|
908 |
||
909 |
contactData->SetUniEditorAvailable( |
|
910 |
analyzer.HasFieldL( VPbkFieldTypeSelectorFactory::EUniEditorSelector ) != KErrNotFound ); |
|
911 |
||
912 |
LOGSTRING("CEasyDialingContactDataManager: GetAvailableServicesL Exit"); |
|
913 |
} |
|
914 |
||
915 |
||
916 |
// --------------------------------------------------------------------------- |
|
917 |
// CEasyDialingContactDataManager::VPbkSingleContactOperationComplete |
|
918 |
// --------------------------------------------------------------------------- |
|
919 |
// |
|
920 |
void CEasyDialingContactDataManager::VPbkSingleContactOperationComplete( |
|
921 |
MVPbkContactOperationBase& aOperation, |
|
922 |
MVPbkStoreContact* aContact ) |
|
923 |
{ |
|
924 |
LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete"); |
|
925 |
delete &aOperation; |
|
926 |
iContactOperation = NULL; |
|
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
927 |
TInt index = iWaitingContacts[0]; |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
928 |
LOGSTRING1("VPbkSingleContactOperationComplete, Index=%d", index); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
929 |
TRAPD(err, DoHandleContactOperationCompleteL(aContact, index)); |
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
930 |
if (err) |
62 | 931 |
{ |
81
c26cc2a7c548
Revision: 201039
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
62
diff
changeset
|
932 |
HandleError(err); |
62 | 933 |
} |
934 |
LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationComplete Exit"); |
|
935 |
} |
|
936 |
||
937 |
// --------------------------------------------------------------------------- |
|
938 |
// CEasyDialingContactDataManager::VPbkSingleContactOperationFailed |
|
939 |
// --------------------------------------------------------------------------- |
|
940 |
// |
|
941 |
void CEasyDialingContactDataManager::VPbkSingleContactOperationFailed( |
|
942 |
MVPbkContactOperationBase& /*aOperation*/, |
|
943 |
TInt /*aError*/ ) |
|
944 |
{ |
|
945 |
LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed"); |
|
946 |
delete iContactOperation; |
|
947 |
iContactOperation = NULL; |
|
948 |
TInt index = iWaitingContacts[0]; |
|
949 |
LOGSTRING1("VPbkSingleContactOperationFailed, Index=%d", index); |
|
950 |
TRAPD(err, DoHandleContactOperationCompleteL(NULL, index)); |
|
951 |
if (err) |
|
952 |
{ |
|
953 |
HandleError(err); |
|
954 |
} |
|
955 |
LOGSTRING("CEasyDialingContactDataManager: VPbkSingleContactOperationFailed Exit"); |
|
956 |
} |
|
957 |
||
958 |
// --------------------------------------------------------------------------- |
|
959 |
// CEasyDialingContactDataManager::InformObserver |
|
960 |
// --------------------------------------------------------------------------- |
|
961 |
// |
|
962 |
void CEasyDialingContactDataManager::InformObserver() |
|
963 |
{ |
|
964 |
if (iObserver && !iWaitingContacts.Count()) |
|
965 |
{ |
|
966 |
iObserver->AllContactDataLoaded(); |
|
967 |
} |
|
968 |
} |
|
969 |
||
970 |
// --------------------------------------------------------------------------- |
|
971 |
// CEasyDialingContactDataManager::SetContactThumbnailSetting |
|
972 |
// --------------------------------------------------------------------------- |
|
973 |
// |
|
974 |
void CEasyDialingContactDataManager::SetContactThumbnailSetting( TInt aContactThumbnailSetting ) |
|
975 |
{ |
|
976 |
iContactThumbnailSetting = aContactThumbnailSetting; |
|
977 |
} |
|
978 |
||
979 |
// --------------------------------------------------------------------------- |
|
980 |
// CEasyDialingContactDataManager::GetContactThumbnailSetting |
|
981 |
// --------------------------------------------------------------------------- |
|
982 |
// |
|
983 |
TBool CEasyDialingContactDataManager::GetContactThumbnailSetting( ) |
|
984 |
{ |
|
985 |
return iContactThumbnailSetting; |
|
986 |
} |
|
987 |
||
988 |
// --------------------------------------------------------------------------- |
|
989 |
// CEasyDialingContactDataManager::Reload |
|
990 |
// --------------------------------------------------------------------------- |
|
991 |
// |
|
992 |
void CEasyDialingContactDataManager::Reload( ) |
|
993 |
{ |
|
994 |
LOGSTRING("CEasyDialingContactDataManager: Reload"); |
|
995 |
||
996 |
for ( TInt i = 0 ; i < iContactDataArray.Count() ; i++ ) |
|
997 |
{ |
|
998 |
iContactDataArray[ i ]->DeleteThumbnail(); |
|
999 |
} |
|
1000 |
} |
|
1001 |
||
1002 |
||
1003 |
// End of File |
|
1004 |