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"
|
|
24 |
|
|
25 |
|
|
26 |
//---------------------------------------------------------------------------
|
|
27 |
// Method that gets the links from the view and passes the link array to the
|
|
28 |
// iterator.
|
|
29 |
//---------------------------------------------------------------------------
|
|
30 |
void CContactViewObserver::SetupContactLinkArrayL(MVPbkContactViewBase& aView )
|
|
31 |
{
|
|
32 |
if((iFlag == EContactFilteredView) || ((iFlag == EContactDefaultView) && (iDefaultView)))
|
|
33 |
{
|
|
34 |
CVPbkContactLinkArray* linkArray = CVPbkContactLinkArray::NewL();
|
|
35 |
CleanupStack::PushL(linkArray);
|
|
36 |
TInt viewCount = aView.ContactCountL();
|
|
37 |
if(viewCount)
|
|
38 |
{
|
|
39 |
for(TInt i=0; i < viewCount; i++)
|
|
40 |
{
|
|
41 |
linkArray->AppendL(aView.CreateLinkLC(i));
|
|
42 |
}
|
|
43 |
|
|
44 |
//Set the params for iterator
|
|
45 |
iIter->SetParams(linkArray, *iStoreUri, iSortOrder, iTransId, EContacts, iContactService);
|
|
46 |
|
|
47 |
//Notify the user
|
|
48 |
iCallback->HandleReturnIter(KErrNone, iIter, iTransId);
|
|
49 |
|
|
50 |
CleanupStack::Pop(viewCount);
|
|
51 |
}
|
|
52 |
else
|
|
53 |
{
|
|
54 |
//Notify User
|
|
55 |
iCallback->HandleReturnValue(EOpComplete, KErrNotFound, iTransId);
|
|
56 |
delete iIter;
|
|
57 |
iIter = NULL;
|
|
58 |
}
|
|
59 |
CleanupStack::Pop(linkArray);
|
|
60 |
}
|
|
61 |
}
|
|
62 |
|
|
63 |
|
|
64 |
//---------------------------------------------------------------------------
|
|
65 |
// This method is called by the ContactViewObserver when the view is ready
|
|
66 |
//---------------------------------------------------------------------------
|
|
67 |
void CContactViewObserver::ContactViewReady(MVPbkContactViewBase& aView )
|
|
68 |
{
|
|
69 |
iSchedulerWait->AsyncStop();
|
|
70 |
iContactService->RequestComplete(iTransId);
|
|
71 |
|
|
72 |
TRAPD(error,SetupContactLinkArrayL(aView));
|
|
73 |
if(error !=KErrNone)
|
|
74 |
{
|
|
75 |
//Notify User
|
|
76 |
iCallback->HandleReturnValue(EOpComplete, error, iTransId);
|
|
77 |
delete iIter;
|
|
78 |
iIter = NULL;
|
|
79 |
}
|
|
80 |
}
|
|
81 |
|
|
82 |
|
|
83 |
//---------------------------------------------------------------------------
|
|
84 |
// NewL()
|
|
85 |
//---------------------------------------------------------------------------
|
|
86 |
|
|
87 |
CContactViewObserver* CContactViewObserver::NewL( MContactCallback* aCallback, enum TViewFlag aFlag, CContactIter* iIter,CContactService* aContactService,const TDesC& aStoreUri, TOrder aSortOrder, TInt aTransId, CActiveSchedulerWait* aSchedulerWait)
|
|
88 |
{
|
|
89 |
CContactViewObserver* self = new( ELeave ) CContactViewObserver( aStoreUri, aFlag, iIter, aContactService, aCallback, aSortOrder, aTransId, aSchedulerWait);
|
|
90 |
return self;
|
|
91 |
}
|
|
92 |
|
|
93 |
|
|
94 |
//---------------------------------------------------------------------------
|
|
95 |
// ConstructL()
|
|
96 |
//---------------------------------------------------------------------------
|
|
97 |
|
|
98 |
|
|
99 |
CContactViewObserver::CContactViewObserver(const TDesC& aStoreUri, enum TViewFlag aFlag, CContactIter* aIter, CContactService* aContactService, MContactCallback* aCallback, TOrder aSortOrder, TInt aTransId, CActiveSchedulerWait* aSchedulerWait )
|
|
100 |
: iStoreUri (&aStoreUri),
|
|
101 |
iFlag (aFlag),
|
|
102 |
iIter (aIter),
|
|
103 |
iCallback (aCallback),
|
|
104 |
iSortOrder (aSortOrder),
|
|
105 |
iTransId (aTransId),
|
|
106 |
iDefaultView (EFalse),
|
|
107 |
iSchedulerWait(aSchedulerWait),
|
|
108 |
iContactService(aContactService)
|
|
109 |
{
|
|
110 |
}
|
|
111 |
|
|
112 |
/*
|
|
113 |
-------------------------------------------------------------------------------------
|
|
114 |
CContactViewObserver::Cancel()
|
|
115 |
Description : Cancel implementation relevant to ViewObserver
|
|
116 |
Return values : KErrorNone on Success and KErrGeneral on Failure
|
|
117 |
-------------------------------------------------------------------------------------
|
|
118 |
*/
|
|
119 |
|
|
120 |
void CContactViewObserver::Cancel()
|
|
121 |
{
|
|
122 |
iCallback->HandleReturnValue(EOpCancel, KErrNone, iTransId);
|
|
123 |
iView->RemoveObserver(*this);
|
|
124 |
delete this;
|
|
125 |
}
|
|
126 |
|
|
127 |
void CContactViewObserver::ReturnDefaultView()
|
|
128 |
{
|
|
129 |
iDefaultView = ETrue;
|
|
130 |
}
|
|
131 |
|
|
132 |
void CContactViewObserver::ContactAddedToView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink */)
|
|
133 |
{
|
|
134 |
}
|
|
135 |
void CContactViewObserver::ContactRemovedFromView( MVPbkContactViewBase& /*aView*/, TInt /*aIndex*/, const MVPbkContactLink& /*aContactLink */)
|
|
136 |
{
|
|
137 |
}
|
|
138 |
|
|
139 |
void CContactViewObserver::ContactViewUnavailable(MVPbkContactViewBase& /*aView*/ )
|
|
140 |
{
|
|
141 |
iSchedulerWait->AsyncStop();
|
|
142 |
iContactService->RequestComplete(iTransId);
|
|
143 |
//Notify User
|
|
144 |
iCallback->HandleReturnValue(EOpError, KErrAbort, iTransId);
|
|
145 |
delete iIter;
|
|
146 |
iIter = NULL;
|
|
147 |
}
|
|
148 |
|
|
149 |
|
|
150 |
void CContactViewObserver::ContactViewError( MVPbkContactViewBase& /*aView*/, TInt aError, TBool /*aErrorNotified*/ )
|
|
151 |
{
|
|
152 |
iSchedulerWait->AsyncStop();
|
|
153 |
iContactService->RequestComplete(iTransId);
|
|
154 |
//Notify User
|
|
155 |
iCallback->HandleReturnValue(EOpError, aError, iTransId);
|
|
156 |
delete iIter;
|
|
157 |
iIter = NULL;
|
|
158 |
}
|