author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Thu, 27 Aug 2009 07:43:07 +0300 | |
changeset 10 | fc9cf246af83 |
parent 5 | 989d2f495d90 |
permissions | -rw-r--r-- |
5 | 1 |
/* |
2 |
* Copyright (c) 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 the License "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: |
|
15 |
* |
|
16 |
*/ |
|
17 |
||
18 |
||
19 |
#include <CVPbkContactLinkArray.h> |
|
20 |
#include <MVPbkContactViewBase.h> |
|
21 |
||
22 |
#include "contactiter.h" |
|
23 |
#include "contactviewobserver.h" |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
24 |
#include <MVPbkContactLink.h> |
5 | 25 |
|
26 |
||
27 |
//--------------------------------------------------------------------------- |
|
28 |
// Method that gets the links from the view and passes the link array to the |
|
29 |
// iterator. |
|
30 |
//--------------------------------------------------------------------------- |
|
31 |
void CContactViewObserver::SetupContactLinkArrayL(MVPbkContactViewBase& aView ) |
|
32 |
{ |
|
33 |
if((iFlag == EContactFilteredView) || ((iFlag == EContactDefaultView) && (iDefaultView))) |
|
34 |
{ |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
35 |
TInt viewCount = aView.ContactCountL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
36 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
37 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
38 |
if(viewCount) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
39 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
40 |
CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewL(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
41 |
CleanupStack::PushL(linkArray); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
42 |
RPointerArray<HBufC8> idArray(viewCount); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
43 |
if(iVal == EGetList) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
44 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
45 |
MVPbkContactLink* link = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
46 |
for(TInt i=0; i < viewCount; i++) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
47 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
48 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
49 |
link = aView.CreateLinkLC(i); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
50 |
linkArray->AppendL(link); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
51 |
CleanupStack::Pop(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
52 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
53 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
54 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
55 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
56 |
if(iSortOrder == EDesc) |
5 | 57 |
{ |
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
58 |
for(TInt i=(viewCount-1); i >= 0; i--) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
59 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
60 |
MVPbkContactLink* link = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
61 |
link = aView.CreateLinkLC(i); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
62 |
idArray.AppendL( link->PackLC()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
63 |
CleanupStack::Pop(); //PackLC puts every element into cleanup stack |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
64 |
//CleanupStack::PopAndDestroy(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
65 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
66 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
67 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
68 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
69 |
for(TInt j=0; j < viewCount; j++) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
70 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
71 |
MVPbkContactLink* link = NULL; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
72 |
link = aView.CreateLinkLC(j); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
73 |
idArray.AppendL( link->PackLC()); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
74 |
CleanupStack::Pop(); //PackLC puts every element into cleanup stack |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
75 |
//CleanupStack::PopAndDestroy(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
76 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
77 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
78 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
79 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
80 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
81 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
82 |
if(iVal == EGetList) |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
83 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
84 |
//Set the params for iterator |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
85 |
iIter->SetParams(linkArray, *iStoreUri, iSortOrder, iTransId, EContacts, iContactService); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
86 |
//Notify the user |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
87 |
iCallback->HandleReturnIter(KErrNone, iIter, iTransId); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
88 |
// CleanupStack::Pop(viewCount); //All Contacts are put in clean up stack. Pop em |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
89 |
CleanupStack::Pop(linkArray); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
90 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
91 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
92 |
else |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
93 |
{ |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
94 |
//iContactService->RequestComplete(iTransId); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
95 |
//Notify the user |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
96 |
//iCallback->HandleReturnIter(KErrNone, iIter, iTransId); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
97 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
98 |
iCallback->HandleReturnArray(KErrNone, idArray, iTransId); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
99 |
CleanupStack::PopAndDestroy(viewCount); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
100 |
CleanupStack::PopAndDestroy(linkArray); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
101 |
//idArray.Reset(); |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
102 |
delete iIter; |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
103 |
} |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
104 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
105 |
|
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
106 |
} |
5 | 107 |
else |
108 |
{ |
|
109 |
//Notify User |
|
110 |
iCallback->HandleReturnValue(EOpComplete, KErrNotFound, iTransId); |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
111 |
delete iIter; |
5 | 112 |
iIter = NULL; |
113 |
} |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
114 |
|
5 | 115 |
} |
116 |
} |
|
117 |
||
118 |
||
119 |
//--------------------------------------------------------------------------- |
|
120 |
// This method is called by the ContactViewObserver when the view is ready |
|
121 |
//--------------------------------------------------------------------------- |
|
122 |
void CContactViewObserver::ContactViewReady(MVPbkContactViewBase& aView ) |
|
123 |
{ |
|
124 |
iSchedulerWait->AsyncStop(); |
|
125 |
iContactService->RequestComplete(iTransId); |
|
126 |
||
127 |
TRAPD(error,SetupContactLinkArrayL(aView)); |
|
128 |
if(error !=KErrNone) |
|
129 |
{ |
|
130 |
//Notify User |
|
131 |
iCallback->HandleReturnValue(EOpComplete, error, iTransId); |
|
132 |
delete iIter; |
|
133 |
iIter = NULL; |
|
134 |
} |
|
135 |
} |
|
136 |
||
137 |
||
138 |
//--------------------------------------------------------------------------- |
|
139 |
// NewL() |
|
140 |
//--------------------------------------------------------------------------- |
|
141 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
142 |
CContactViewObserver* CContactViewObserver::NewL( MContactCallback* aCallback, enum TViewFlag aFlag, CContactIter* iIter, CContactService* aContactService,const TDesC& aStoreUri, TOrder aSortOrder, TInt aTransId, CActiveSchedulerWait* aSchedulerWait, TCmdType val) |
5 | 143 |
{ |
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
144 |
CContactViewObserver* self = new( ELeave ) CContactViewObserver( aStoreUri, aFlag, iIter,aContactService, aCallback, aSortOrder, aTransId, aSchedulerWait, val); |
5 | 145 |
return self; |
146 |
} |
|
147 |
||
148 |
||
149 |
//--------------------------------------------------------------------------- |
|
150 |
// ConstructL() |
|
151 |
//--------------------------------------------------------------------------- |
|
152 |
||
153 |
||
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
154 |
CContactViewObserver::CContactViewObserver(const TDesC& aStoreUri, enum TViewFlag aFlag, CContactIter* aIter, CContactService* aContactService, MContactCallback* aCallback, TOrder aSortOrder, TInt aTransId, CActiveSchedulerWait* aSchedulerWait, TCmdType val ) |
5 | 155 |
: iStoreUri (&aStoreUri), |
156 |
iFlag (aFlag), |
|
157 |
iIter (aIter), |
|
158 |
iCallback (aCallback), |
|
159 |
iSortOrder (aSortOrder), |
|
160 |
iTransId (aTransId), |
|
161 |
iDefaultView (EFalse), |
|
162 |
iSchedulerWait(aSchedulerWait), |
|
10
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
163 |
iContactService(aContactService), |
fc9cf246af83
Revision: 200931
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
5
diff
changeset
|
164 |
iVal(val) |
5 | 165 |
{ |
166 |
} |
|
167 |
||
168 |
/* |
|
169 |
------------------------------------------------------------------------------------- |
|
170 |
CContactViewObserver::Cancel() |
|
171 |
Description : Cancel implementation relevant to ViewObserver |
|
172 |
Return values : KErrorNone on Success and KErrGeneral on Failure |
|
173 |
------------------------------------------------------------------------------------- |
|
174 |
*/ |
|
175 |
||
176 |
void CContactViewObserver::Cancel() |
|
177 |
{ |
|
178 |
iCallback->HandleReturnValue(EOpCancel, KErrNone, iTransId); |
|
179 |
iView->RemoveObserver(*this); |
|
180 |
delete this; |
|
181 |
} |
|
182 |
||
183 |
void CContactViewObserver::ReturnDefaultView() |
|
184 |
{ |
|
185 |
iDefaultView = ETrue; |
|
186 |
} |
|
187 |
||
188 |
void CContactViewObserver::ContactAddedToView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink */) |
|
189 |
{ |
|
190 |
} |
|
191 |
void CContactViewObserver::ContactRemovedFromView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink */) |
|
192 |
{ |
|
193 |
} |
|
194 |
||
195 |
void CContactViewObserver::ContactViewUnavailable(MVPbkContactViewBase& /*aView*/ ) |
|
196 |
{ |
|
197 |
iSchedulerWait->AsyncStop(); |
|
198 |
iContactService->RequestComplete(iTransId); |
|
199 |
//Notify User |
|
200 |
iCallback->HandleReturnValue(EOpError, KErrAbort, iTransId); |
|
201 |
delete iIter; |
|
202 |
iIter = NULL; |
|
203 |
} |
|
204 |
||
205 |
||
206 |
void CContactViewObserver::ContactViewError( MVPbkContactViewBase& /*aView*/, TInt aError, TBool /*aErrorNotified*/ ) |
|
207 |
{ |
|
208 |
iSchedulerWait->AsyncStop(); |
|
209 |
iContactService->RequestComplete(iTransId); |
|
210 |
//Notify User |
|
211 |
iCallback->HandleReturnValue(EOpError, aError, iTransId); |
|
212 |
delete iIter; |
|
213 |
iIter = NULL; |
|
214 |
} |