19
|
1 |
/*
|
|
2 |
* Copyright (c) 2006 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: Observer to Add a contact to the contact store
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_ADDCONTACTOBSERVER_H
|
|
20 |
#define C_ADDCONTACTOBSERVER_H
|
|
21 |
|
|
22 |
|
|
23 |
#include <s32file.h>
|
|
24 |
#include <mvpbkcontactstoreobserver.h>
|
|
25 |
#include <mvpbkcontactobserver.h>
|
|
26 |
#include <MVPbkSingleContactOperationObserver.h>
|
|
27 |
#include <MVPbkStoreContact.h>
|
|
28 |
|
|
29 |
#include "singlecontact.h"
|
|
30 |
#include "cancelasyncrquest.h"
|
|
31 |
|
|
32 |
class CVPbkContactManager;
|
|
33 |
class MVPbkStoreContact;
|
|
34 |
class MVPbkContactLink;
|
|
35 |
class MContactCallback;
|
|
36 |
class MCancelAsync;
|
|
37 |
|
|
38 |
|
|
39 |
class CAddContactObserver : public CBase,
|
|
40 |
public MVPbkContactStoreObserver,
|
|
41 |
public MVPbkSingleContactOperationObserver,
|
|
42 |
public MVPbkContactObserver,
|
|
43 |
public MCancelAsync
|
|
44 |
{
|
|
45 |
public:
|
|
46 |
/*
|
|
47 |
* called for creating an instace of add contact observer
|
|
48 |
*/
|
|
49 |
static CAddContactObserver* NewL(CContactService* aContactService,
|
|
50 |
MVPbkContactStore* aContactStore,
|
|
51 |
CSingleContact* aStoreContact,
|
|
52 |
const TDesC8& aGroupId,
|
|
53 |
const TDesC& aGroupLabel,
|
|
54 |
TInt aTransId,
|
|
55 |
MContactCallback* aCallback);
|
|
56 |
/*
|
|
57 |
* Destructor
|
|
58 |
*/
|
|
59 |
~CAddContactObserver();
|
|
60 |
|
|
61 |
/*
|
|
62 |
* Implementation of Cancel of MCancelAsync
|
|
63 |
*/
|
|
64 |
void Cancel();
|
|
65 |
private:
|
|
66 |
/*
|
|
67 |
* Constructor */
|
|
68 |
CAddContactObserver(CContactService* aContactService,
|
|
69 |
MVPbkContactStore* aContactStore,
|
|
70 |
CSingleContact* aStoreContact,
|
|
71 |
TInt aTransId,
|
|
72 |
MContactCallback* aCallback);
|
|
73 |
|
|
74 |
/*
|
|
75 |
* Symbian second-phase construction
|
|
76 |
*/
|
|
77 |
void ConstructL(const TDesC8& aGroupId,
|
|
78 |
const TDesC& aGroupLabel);
|
|
79 |
|
|
80 |
/*
|
|
81 |
* Called for adding a contact into the contacts database.
|
|
82 |
*/
|
|
83 |
void DoAddL();
|
|
84 |
|
|
85 |
/*
|
|
86 |
* Called for committing a contact into the contacts database.
|
|
87 |
*/
|
|
88 |
TInt DoCommitL(TContactOpResult aResult);
|
|
89 |
|
|
90 |
void DoEditContactOrGroupL(MVPbkStoreContact* aContact);
|
|
91 |
|
|
92 |
private: // from MVPbkContactObserver
|
|
93 |
|
|
94 |
/**
|
|
95 |
* An indication that a contact operation has been completed.
|
|
96 |
*
|
|
97 |
* @param aResult The result of the operation.
|
|
98 |
* @return None.
|
|
99 |
*/
|
|
100 |
void ContactOperationCompleted( TContactOpResult aResult );
|
|
101 |
|
|
102 |
/**
|
|
103 |
* An indication that a contact operation has failed.
|
|
104 |
*
|
|
105 |
* @param aOpCode The operation identifier.
|
|
106 |
* @param aErrorCode The error code.
|
|
107 |
* @param aErrorNotified A flag indicating whether the user has been
|
|
108 |
* notified about the error.
|
|
109 |
* @return None.
|
|
110 |
*/
|
|
111 |
void ContactOperationFailed( TContactOp aOpCode, TInt aErrorCode,
|
|
112 |
TBool aErrorNotified );
|
|
113 |
|
|
114 |
|
|
115 |
private: //MVPbkContactStoreObserver
|
|
116 |
/**
|
|
117 |
* Called when a contact store is ready to use.
|
|
118 |
*/
|
|
119 |
void StoreReady( MVPbkContactStore& aContactStore );
|
|
120 |
|
|
121 |
/**
|
|
122 |
* Called when a contact store becomes unavailable.
|
|
123 |
* Client may inspect the reason of the unavailability and decide whether or not
|
|
124 |
* it will keep the store opened (ie. listen to the store events).
|
|
125 |
* @param aContactStore The store that became unavailable.
|
|
126 |
* @param aReason The reason why the store is unavailable.
|
|
127 |
* This is one of the system wide error codes.
|
|
128 |
*/
|
|
129 |
void StoreUnavailable( MVPbkContactStore& aContactStore, TInt aReason );
|
|
130 |
|
|
131 |
/**
|
|
132 |
* Called when changes occur in the contact store.
|
|
133 |
* @see TVPbkContactStoreEvent
|
|
134 |
* @param aContactStore The store the event occurred in.
|
|
135 |
* @param aStoreEvent Event that has occured.
|
|
136 |
*/
|
|
137 |
virtual void HandleStoreEventL( MVPbkContactStore& aContactStore,
|
|
138 |
TVPbkContactStoreEvent aStoreEvent );
|
|
139 |
|
|
140 |
private: // from MVPbkSingleContactOperationObserver
|
|
141 |
/**
|
|
142 |
* Called when operation is completed.
|
|
143 |
*
|
|
144 |
* @param aOperation the completed operation.
|
|
145 |
* @param aContact the contact returned by the operation.
|
|
146 |
* Client must take the ownership immediately.
|
|
147 |
*
|
|
148 |
* !!! NOTICE !!!
|
|
149 |
* If you use Cleanupstack for MVPbkStoreContact
|
|
150 |
* Use MVPbkStoreContact::PushL or
|
|
151 |
* CleanupDeletePushL from e32base.h.
|
|
152 |
* (Do Not Use CleanupStack::PushL(TAny*) because
|
|
153 |
* then the virtual destructor of the M-class
|
|
154 |
* won't be called when the object is deleted).
|
|
155 |
*/
|
|
156 |
virtual void VPbkSingleContactOperationComplete(
|
|
157 |
MVPbkContactOperationBase& aOperation,
|
|
158 |
MVPbkStoreContact* aContact);
|
|
159 |
/**
|
|
160 |
* Called if the operation fails.
|
|
161 |
*
|
|
162 |
* @param aOperation the failed operation.
|
|
163 |
* @param aError error code of the failure.
|
|
164 |
*/
|
|
165 |
virtual void VPbkSingleContactOperationFailed(
|
|
166 |
MVPbkContactOperationBase& aOperation,
|
|
167 |
TInt aError);
|
|
168 |
|
|
169 |
private:
|
|
170 |
|
|
171 |
void CreateAndAddFieldToContactL();
|
|
172 |
|
|
173 |
public:
|
|
174 |
/*
|
|
175 |
* Pointer to a contact manager
|
|
176 |
*/
|
|
177 |
CContactService* iContactService;
|
|
178 |
/*
|
|
179 |
* Pointer to a contact store
|
|
180 |
*/
|
|
181 |
MVPbkContactStore* iContactStore;
|
|
182 |
/*
|
|
183 |
* Pointer to a store contact
|
|
184 |
*/
|
|
185 |
CSingleContact* iStoreContact;
|
|
186 |
/*
|
|
187 |
* Pointer to a callback
|
|
188 |
*/
|
|
189 |
MContactCallback* iCallback;
|
|
190 |
/*
|
|
191 |
* Pointer to group id.
|
|
192 |
*/
|
|
193 |
HBufC8* iGroupId;
|
|
194 |
/*
|
|
195 |
* Pointer to group label
|
|
196 |
*/
|
|
197 |
HBufC* iGroupLabel;
|
|
198 |
/*
|
|
199 |
* Flag to indicate whether contact is locked or not
|
|
200 |
*/
|
|
201 |
TBool iLockFlag;
|
|
202 |
|
|
203 |
/*
|
|
204 |
* Transaction Id.
|
|
205 |
*/
|
|
206 |
TInt iTransId;
|
|
207 |
|
|
208 |
TInt iErrorID;
|
|
209 |
//TPtrC iErrKey;
|
|
210 |
|
|
211 |
MVPbkStoreContact* iContact;
|
|
212 |
MVPbkContactGroup* iGroup;
|
|
213 |
|
|
214 |
|
|
215 |
//OperationBase pointer to be used to cancel async request
|
|
216 |
MVPbkContactOperationBase* iOp;
|
|
217 |
};
|
|
218 |
|
|
219 |
#endif //C_ADDCONTACTOBSERVER_H |