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 |
#include <MVPbkContactOperationBase.h>
|
|
19 |
#include "contactservice.h"
|
|
20 |
#include "contactiter.h"
|
|
21 |
#include "contactretrieveobserver.h"
|
|
22 |
#include "contactcallback.h"
|
|
23 |
//-------------------------------------------
|
|
24 |
// NewL() Method
|
|
25 |
//-------------------------------------------
|
|
26 |
CContactRetrieveObserver* CContactRetrieveObserver::NewL(CContactIter* aIter, MContactCallback* aCallback, CContactService* aContactService, enum Ttype aType, TInt aTransId, CActiveSchedulerWait* aSchedulerWait)
|
|
27 |
{
|
|
28 |
CContactRetrieveObserver* self = new( ELeave ) CContactRetrieveObserver( );
|
|
29 |
CleanupStack::PushL( self );
|
|
30 |
self->ConstructL(aIter, aCallback, aContactService, aType, aTransId, aSchedulerWait);
|
|
31 |
CleanupStack::Pop( self );
|
|
32 |
return self;
|
|
33 |
|
|
34 |
}
|
|
35 |
|
|
36 |
//-------------------------------------------
|
|
37 |
// ConstructL() Method
|
|
38 |
//-------------------------------------------
|
|
39 |
void CContactRetrieveObserver::ConstructL(CContactIter* aIter, MContactCallback* aCallback, CContactService* aContactService, enum Ttype aType, TInt aTransId, CActiveSchedulerWait* aSchedulerWait)
|
|
40 |
{
|
|
41 |
iIter = aIter;
|
|
42 |
iCallback = aCallback;
|
|
43 |
iContactService = aContactService;
|
|
44 |
iType = aType;
|
|
45 |
iTransId = aTransId;
|
|
46 |
iSchedulerWait = aSchedulerWait;
|
|
47 |
}
|
|
48 |
|
|
49 |
//--------------------------------------------------------------------------------------
|
|
50 |
// Retrival of the contact was successful
|
|
51 |
// Results are set in the iterator and RequestComplete is notified.
|
|
52 |
//--------------------------------------------------------------------------------------
|
|
53 |
void CContactRetrieveObserver::VPbkSingleContactOperationComplete(
|
|
54 |
MVPbkContactOperationBase& aOperation,
|
|
55 |
MVPbkStoreContact* aContact )
|
|
56 |
{
|
|
57 |
delete &aOperation;
|
|
58 |
if(iCallback)
|
|
59 |
{
|
|
60 |
if(iContactService)
|
|
61 |
{
|
|
62 |
iContactService->RequestComplete(iTransId);
|
|
63 |
}
|
|
64 |
|
|
65 |
iSchedulerWait->AsyncStop();
|
|
66 |
|
|
67 |
if(((aContact->Group()) && (iType == EGroups)) || (!(aContact->Group()) && (iType == EContacts)))
|
|
68 |
{
|
|
69 |
//Indicate operation complete
|
|
70 |
iCallback->HandleReturnIter(KErrNone, iIter, iTransId);
|
|
71 |
}
|
|
72 |
else
|
|
73 |
{
|
|
74 |
iCallback->HandleReturnValue(EOpComplete, KErrArgument, iTransId);
|
|
75 |
delete iIter;
|
|
76 |
}
|
|
77 |
}
|
|
78 |
else if(!iCallback)
|
|
79 |
{
|
|
80 |
//Set the iterator with the result
|
|
81 |
iIter->SetContactFetchResult(aContact);
|
|
82 |
|
|
83 |
//Set ActiveObject status to RequestComplete
|
|
84 |
TRequestStatus* status = &(iIter->iSyncIter->iStatus);
|
|
85 |
User::RequestComplete(status, KErrNone);
|
|
86 |
}
|
|
87 |
delete this;
|
|
88 |
}
|
|
89 |
|
|
90 |
//-------------------------------------------
|
|
91 |
// In case the retrival was unsuccessful
|
|
92 |
//-------------------------------------------
|
|
93 |
void CContactRetrieveObserver::VPbkSingleContactOperationFailed(
|
|
94 |
MVPbkContactOperationBase& aOperation,
|
|
95 |
TInt aError)
|
|
96 |
{
|
|
97 |
delete &aOperation;
|
|
98 |
if(!iCallback)
|
|
99 |
{
|
|
100 |
//Set the iterator with the result
|
|
101 |
iIter->SetContactFetchResult(NULL);
|
|
102 |
|
|
103 |
//Set ActiveObject status to RequestComplete
|
|
104 |
TRequestStatus* status = &(iIter->iSyncIter->iStatus);
|
|
105 |
User::RequestComplete(status, KErrNone);
|
|
106 |
}
|
|
107 |
else
|
|
108 |
{
|
|
109 |
if(iContactService)
|
|
110 |
{
|
|
111 |
iContactService->RequestComplete(iTransId);
|
|
112 |
}
|
|
113 |
iSchedulerWait->AsyncStop();
|
|
114 |
//Indicate operation failure
|
|
115 |
iCallback->HandleReturnValue(EOpError, aError, iTransId);
|
|
116 |
delete iIter;
|
|
117 |
iIter = NULL;
|
|
118 |
}
|
|
119 |
delete this;
|
|
120 |
}
|
|
121 |
|
|
122 |
|
|
123 |
/*
|
|
124 |
-------------------------------------------------------------------------------------
|
|
125 |
CContactViewObserver::Cancel()
|
|
126 |
Description : Cancel implementation relevant to ViewObserver
|
|
127 |
Return values : KErrorNone on Success and KErrGeneral on Failure
|
|
128 |
-------------------------------------------------------------------------------------
|
|
129 |
*/
|
|
130 |
|
|
131 |
void CContactRetrieveObserver::Cancel()
|
|
132 |
{
|
|
133 |
iCallback->HandleReturnValue(EOpCancel, KErrNone, iTransId);
|
|
134 |
delete this;
|
|
135 |
}
|
|
136 |
|