35
|
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: IETF SIMPLE Protocol implementation for XIMP Framework
|
|
15 |
*
|
|
16 |
*/
|
|
17 |
|
|
18 |
|
|
19 |
#ifndef C_CPRESENCEPLUGINCONTACTS_H
|
|
20 |
#define C_CPRESENCEPLUGINCONTACTS_H
|
|
21 |
|
|
22 |
|
|
23 |
#include <e32base.h>
|
|
24 |
#include <MVPbkContactFindObserver.h>
|
|
25 |
#include <MVPbkSingleContactOperationObserver.h>
|
|
26 |
#include <MVPbkContactStoreListObserver.h>
|
|
27 |
#include "presencecontactscontextbase.h"
|
|
28 |
#include "presencelogger.h"
|
|
29 |
|
|
30 |
class CVPbkContactManager;
|
|
31 |
class MVPbkContactOperationBase;
|
|
32 |
class MVPbkContactLinkArray;
|
|
33 |
class MVPbkStoreContact;
|
|
34 |
class CVPbkFieldTypeRefsList;
|
|
35 |
class CPresencePluginContactStateHandler;
|
|
36 |
class MPresencePluginContactsObs;
|
|
37 |
|
|
38 |
|
|
39 |
/**
|
|
40 |
* CPrecensePluginContacts Operation states
|
|
41 |
*/
|
|
42 |
enum TPresenceContactsOperation
|
|
43 |
{
|
|
44 |
EOperationIsPresenceStoredToContacts
|
|
45 |
};
|
|
46 |
|
|
47 |
|
|
48 |
/**
|
|
49 |
* Access to virtual phonebook contacts database
|
|
50 |
*
|
|
51 |
* @lib presenceplugin.dll
|
|
52 |
* @since S60 v5.0
|
|
53 |
*/
|
|
54 |
NONSHARABLE_CLASS( CPresencePluginContacts ) :
|
|
55 |
public CActive,
|
|
56 |
public MVPbkContactStoreListObserver,
|
|
57 |
public MVPbkContactFindObserver,
|
|
58 |
public MVPbkSingleContactOperationObserver,
|
|
59 |
public MPresenceContactsContextBase
|
|
60 |
{
|
|
61 |
|
|
62 |
public:
|
|
63 |
|
|
64 |
/**
|
|
65 |
* Two-phased constructor.
|
|
66 |
* @param aServiceId Service ID.
|
|
67 |
* @param aServiceName Service name
|
|
68 |
* @param aObserver Callback results
|
|
69 |
*/
|
|
70 |
static CPresencePluginContacts* NewL(
|
|
71 |
TInt aServiceId,
|
|
72 |
const TDesC& aServiceName,
|
|
73 |
MPresencePluginContactsObs& aObserver );
|
|
74 |
|
|
75 |
/**
|
|
76 |
* Two-phased constructor.
|
|
77 |
* @param aServiceId Service ID.
|
|
78 |
* @param aServiceName Service name
|
|
79 |
* @param aObserver Callback results
|
|
80 |
*/
|
|
81 |
static CPresencePluginContacts* NewLC(
|
|
82 |
TInt aServiceId,
|
|
83 |
const TDesC& aServiceName,
|
|
84 |
MPresencePluginContactsObs& aObserver );
|
|
85 |
|
|
86 |
/**
|
|
87 |
* Destructor.
|
|
88 |
*/
|
|
89 |
virtual ~CPresencePluginContacts();
|
|
90 |
|
|
91 |
/**
|
|
92 |
* Query to virtual bhonebook contacts database
|
|
93 |
* to ensure is the presence service stored to database
|
|
94 |
*
|
|
95 |
* Calls MPresencePluginContactsObs::RequestComplete() when comlete
|
|
96 |
*
|
|
97 |
* @since S60 v5.0
|
|
98 |
* @param aPresenceId Presence ID.
|
|
99 |
* @param aStatus Client status
|
|
100 |
*/
|
|
101 |
void IsPresenceIdStoredL( const TDesC16& aPresenceId,
|
|
102 |
TRequestStatus& aStatus );
|
|
103 |
|
|
104 |
protected:
|
|
105 |
|
|
106 |
// from base class CActive
|
|
107 |
|
|
108 |
void RunL();
|
|
109 |
|
|
110 |
void DoCancel();
|
|
111 |
|
|
112 |
TInt RunError( TInt aError );
|
|
113 |
|
|
114 |
// from base class MVPbkContactStoreListObserver
|
|
115 |
|
|
116 |
/**
|
|
117 |
* Called when the opening process is complete.
|
|
118 |
*
|
|
119 |
* Before this all stores have sent StoreReady or StoreUnavailable
|
|
120 |
* event. The client can not trust that all stores are available
|
|
121 |
* for use when this is called.
|
|
122 |
*/
|
|
123 |
void OpenComplete();
|
|
124 |
|
|
125 |
// from base class MVPbkContactStoreObserver ( from MVPbkContactStoreListObserver )
|
|
126 |
|
|
127 |
/**
|
|
128 |
* Called when a contact store is ready to use.
|
|
129 |
*
|
|
130 |
* @param aContactStore The store that is ready.
|
|
131 |
*/
|
|
132 |
void StoreReady( MVPbkContactStore& aContactStore );
|
|
133 |
|
|
134 |
/**
|
|
135 |
* Called when a contact store becomes unavailable.
|
|
136 |
*
|
|
137 |
* Client may inspect the reason of the unavailability and decide
|
|
138 |
* whether or not it will keep the store opened (ie. listen to
|
|
139 |
* the store events).
|
|
140 |
*
|
|
141 |
* @param aContactStore The store that became unavailable.
|
|
142 |
* @param aReason The reason why the store is unavailable.
|
|
143 |
* This is one of the system wide error codes.
|
|
144 |
*/
|
|
145 |
void StoreUnavailable( MVPbkContactStore& aContactStore,
|
|
146 |
TInt aReason );
|
|
147 |
|
|
148 |
/**
|
|
149 |
* Called when changes occur in the contact store.
|
|
150 |
*
|
|
151 |
* @see TVPbkContactStoreEvent
|
|
152 |
* @param aContactStore A store whose event it is.
|
|
153 |
* @param aStoreEvent The event that has occurred.
|
|
154 |
*/
|
|
155 |
void HandleStoreEventL(
|
|
156 |
MVPbkContactStore& aContactStore,
|
|
157 |
TVPbkContactStoreEvent aStoreEvent );
|
|
158 |
|
|
159 |
// from base class MVPbkContactFindObserver
|
|
160 |
|
|
161 |
/**
|
|
162 |
* Called when find is complete. Caller takes ownership of the results
|
|
163 |
* In case of an error during find, the aResults may contain only
|
|
164 |
* partial results of the find
|
|
165 |
*
|
|
166 |
* @param aResults Array of contact links that matched the find
|
|
167 |
* Callee must take ownership of this object in
|
|
168 |
* the start of the function, ie. in case the
|
|
169 |
* function leaves the results must be destroyed.
|
|
170 |
* The find operation can be destroyed at the end
|
|
171 |
* of this callback.
|
|
172 |
*/
|
|
173 |
void FindCompleteL( MVPbkContactLinkArray* aResults );
|
|
174 |
|
|
175 |
/**
|
|
176 |
* Called in case the find fails for some reason. The find operation
|
|
177 |
* can be destroyed at the end of this callback.
|
|
178 |
*
|
|
179 |
* @param aError One of the system wide error codes.
|
|
180 |
* KErrNotReady if store is not ready (not open or unavailable)
|
|
181 |
*/
|
|
182 |
void FindFailed( TInt aError );
|
|
183 |
|
|
184 |
// from base class MVPbkSingleContactOperationObserver
|
|
185 |
|
|
186 |
/**
|
|
187 |
* Called when the operation is completed.
|
|
188 |
*
|
|
189 |
* A client has the operation as a member and it can delete the operation
|
|
190 |
* instance in this function call. If the implementation of the store
|
|
191 |
* calls the function from the operation instance it must not handle
|
|
192 |
* any member data after calling it.
|
|
193 |
*
|
|
194 |
* @param aOperation The completed operation.
|
|
195 |
* @param aContact The contact returned by the operation.
|
|
196 |
* A client must take the ownership immediately.
|
|
197 |
*
|
|
198 |
* NOTE:
|
|
199 |
* If you use CleanupStack for MVPbkStoreContact
|
|
200 |
* Use MVPbkStoreContact::PushL or
|
|
201 |
* CleanupDeletePushL from e32base.h.
|
|
202 |
* (Do Not Use CleanupStack::PushL(TAny*) because
|
|
203 |
* then the virtual destructor of the M-class
|
|
204 |
* won't be called when the object is deleted).
|
|
205 |
*/
|
|
206 |
void VPbkSingleContactOperationComplete(
|
|
207 |
MVPbkContactOperationBase& aOperation,
|
|
208 |
MVPbkStoreContact* aContact );
|
|
209 |
|
|
210 |
/**
|
|
211 |
* Called if the operation fails.
|
|
212 |
*
|
|
213 |
* A client has the operation as a member and it can delete the operation
|
|
214 |
* instance in this function call. If the implementation of the store
|
|
215 |
* calls the function from the operation instance it must not handle
|
|
216 |
* any member data after calling it.
|
|
217 |
*
|
|
218 |
* @param aOperation The failed operation.
|
|
219 |
* @param aError An error code of the failure.
|
|
220 |
*/
|
|
221 |
void VPbkSingleContactOperationFailed(
|
|
222 |
MVPbkContactOperationBase& aOperation,
|
|
223 |
TInt aError );
|
|
224 |
|
|
225 |
// from base class MPresenceContactsContextBase
|
|
226 |
|
|
227 |
/**
|
|
228 |
* Open virtual phonebook contact stores
|
|
229 |
*
|
|
230 |
* @since S60 v5.0
|
|
231 |
*/
|
|
232 |
void OpenL();
|
|
233 |
|
|
234 |
/**
|
|
235 |
* Start virtual phonebook contacts search
|
|
236 |
*
|
|
237 |
* @since S60 v5.0
|
|
238 |
*/
|
|
239 |
void SearchL();
|
|
240 |
|
|
241 |
/**
|
|
242 |
* Return virtual phonebook contact links
|
|
243 |
*
|
|
244 |
* @since S60 v5.0
|
|
245 |
* @return virtual phonebook contact links
|
|
246 |
*/
|
|
247 |
const MVPbkContactLinkArray& ContactLinkArrayL();
|
|
248 |
|
|
249 |
/**
|
|
250 |
* Resolve virtual phonebook contact from contact link
|
|
251 |
*
|
|
252 |
* @since S60 v5.0
|
|
253 |
* @param aContactLink contact link to resolve
|
|
254 |
*/
|
|
255 |
void RetrieveContactL(
|
|
256 |
const MVPbkContactLink& aContactLink );
|
|
257 |
|
|
258 |
private:
|
|
259 |
|
|
260 |
CPresencePluginContacts( TInt aServiceId, MPresencePluginContactsObs& aObserver );
|
|
261 |
|
|
262 |
void ConstructL( const TDesC& aServiceName );
|
|
263 |
|
|
264 |
HBufC* ContactStoreNameL();
|
|
265 |
|
|
266 |
private: //data
|
|
267 |
|
|
268 |
/**
|
|
269 |
* Service id.
|
|
270 |
*/
|
|
271 |
TInt iServiceId;
|
|
272 |
|
|
273 |
/**
|
|
274 |
* Service name.
|
|
275 |
* Own.
|
|
276 |
*/
|
|
277 |
HBufC* iServiceName;
|
|
278 |
|
|
279 |
/**
|
|
280 |
* Text used in search
|
|
281 |
* Own.
|
|
282 |
*/
|
|
283 |
HBufC* iSearchText;
|
|
284 |
|
|
285 |
/**
|
|
286 |
* Observer.
|
|
287 |
* Not own.
|
|
288 |
*/
|
|
289 |
MPresencePluginContactsObs* iObserver;
|
|
290 |
|
|
291 |
/**
|
|
292 |
* Presence Plugin Contacts Operation
|
|
293 |
*/
|
|
294 |
TPresenceContactsOperation iOperation;
|
|
295 |
|
|
296 |
/**
|
|
297 |
* Virtual Phonebook field types
|
|
298 |
* Own.
|
|
299 |
*/
|
|
300 |
CVPbkFieldTypeRefsList* iFieldTypeRefList;
|
|
301 |
|
|
302 |
/**
|
|
303 |
* Virtual Phonebook contact manager
|
|
304 |
* Own.
|
|
305 |
*/
|
|
306 |
CVPbkContactManager* iContactManager;
|
|
307 |
|
|
308 |
/**
|
|
309 |
* VPbk operation
|
|
310 |
* Own.
|
|
311 |
*/
|
|
312 |
MVPbkContactOperationBase* iContactOperation;
|
|
313 |
|
|
314 |
/**
|
|
315 |
* VPbk contact links
|
|
316 |
* Own.
|
|
317 |
*/
|
|
318 |
MVPbkContactLinkArray* iContactLinkArray;
|
|
319 |
|
|
320 |
/**
|
|
321 |
* VPbk Store contact array
|
|
322 |
* Own.
|
|
323 |
*/
|
|
324 |
RPointerArray<MVPbkStoreContact> iStoreContactArray;
|
|
325 |
|
|
326 |
/**
|
|
327 |
* state handler
|
|
328 |
* Own.
|
|
329 |
*/
|
|
330 |
CPresencePluginContactStateHandler* iStateHandler;
|
|
331 |
|
|
332 |
/**
|
|
333 |
* Client status
|
|
334 |
* Not own.
|
|
335 |
*/
|
|
336 |
TRequestStatus* iClientStatus;
|
|
337 |
|
|
338 |
|
|
339 |
SIMPLE_UNIT_TEST( UT_CPresencePluginContacts )
|
|
340 |
|
|
341 |
};
|
|
342 |
|
|
343 |
|
|
344 |
#endif // C_CPRESENCEPLUGINCONTACTS_H
|