|
1 /* |
|
2 * Copyright (c) 2007, 2008 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: Implementation for presence cache reader and writer. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef PRESENCECACHECLIENT_H |
|
19 #define PRESENCECACHECLIENT_H |
|
20 |
|
21 #include <presencecachereader.h> |
|
22 #include <presencecachewriter.h> |
|
23 |
|
24 #include "presencecachedefs.h" |
|
25 #include "presenceapiobjbase.h" |
|
26 |
|
27 |
|
28 class MPresenceInfo; |
|
29 class MPersonPresenceInfo; |
|
30 class MPresenceInfoField; |
|
31 class MPresenceBuddyInfo; |
|
32 class MPresCacheWriteHandler; |
|
33 class MPresCacheReadHandler; |
|
34 class MXIMPIdentity; |
|
35 class MPresenceBuddyInfoList; |
|
36 class MPresenceObjectFactory; |
|
37 class CPresenceObjectFactoryImp; |
|
38 |
|
39 class CPresenceCacheClientNotification; |
|
40 |
|
41 //Include Cache server namespace |
|
42 using namespace NCacheSrv; |
|
43 |
|
44 /** |
|
45 * Implementation for presence cache reader and writer. This object is |
|
46 * instantiated either by MPresenceCacheReader or MPresenceCacheWriter using ecom framework. |
|
47 * Apart from implementing these two objects, this is also a Symbian OS client and |
|
48 * it communicates with presence cache server. Its also an active object. |
|
49 * |
|
50 * @ingroup ximpprescacheapi |
|
51 * @since S60 v3.2 |
|
52 */ |
|
53 class CPresenceCacheClient : public CActive, |
|
54 public MPresenceCacheReader, |
|
55 public MPresenceCacheWriter, |
|
56 public RSessionBase |
|
57 |
|
58 { |
|
59 public: |
|
60 |
|
61 /** The class ID. */ |
|
62 enum { KClassId = PRIMP_CLSID_CPRESENCECACHECLIENT }; |
|
63 |
|
64 |
|
65 public: |
|
66 |
|
67 /** |
|
68 * Factory method to instantiate CPresenceCacheClient through the ECom. |
|
69 * |
|
70 * @return The new CPresenceCacheClient object. Object |
|
71 * ownership is returned to caller. |
|
72 */ |
|
73 IMPORT_C static CPresenceCacheClient* NewL(); |
|
74 |
|
75 /** |
|
76 * Factory method to instantiate CPresenceCacheClient through the ECom. |
|
77 * It's returns MPresenceCacheReader |
|
78 * |
|
79 * @return The new CPresenceCacheClient object. Object |
|
80 * ownership is returned to caller. |
|
81 */ |
|
82 IMPORT_C static MPresenceCacheReader* CreateReaderL(); |
|
83 |
|
84 /** |
|
85 * Factory method to instantiate CPresenceCacheClient through the ECom. |
|
86 * It's returns MPresenceCacheWriter |
|
87 * |
|
88 * @return The new CPresenceCacheClient object. Object |
|
89 * ownership is returned to caller. |
|
90 */ |
|
91 IMPORT_C static MPresenceCacheWriter* CreateWriterL(); |
|
92 |
|
93 /** |
|
94 * Public destructor. |
|
95 * Objects can be deleted through this interface. |
|
96 */ |
|
97 virtual ~CPresenceCacheClient(); |
|
98 |
|
99 /** |
|
100 * Start the server |
|
101 * @return TInt Error code |
|
102 */ |
|
103 TInt StartServer(); |
|
104 |
|
105 /** |
|
106 * Version. |
|
107 * Gets the version number. |
|
108 * @return The version. |
|
109 */ |
|
110 TVersion Version() const; |
|
111 |
|
112 |
|
113 private: |
|
114 |
|
115 /** |
|
116 * C++ constructor |
|
117 */ |
|
118 CPresenceCacheClient(); |
|
119 |
|
120 /** |
|
121 * Symbian second phase constructor |
|
122 */ |
|
123 void ConstructL(); |
|
124 |
|
125 /** |
|
126 * Connect. |
|
127 * Connects to the server and create a session. |
|
128 * @return Error code. |
|
129 */ |
|
130 TInt Connect(); |
|
131 |
|
132 /** |
|
133 * Packs MPresenceBuddyInfo object into a buffer |
|
134 * |
|
135 * @param aBuddyPresInfo, MPresenceBuddyInfo |
|
136 * @return HBufC8* buffer |
|
137 */ |
|
138 HBufC8* PackBuddyPresenceInfoLC(const MPresenceBuddyInfo* aBuddyPresInfo); |
|
139 |
|
140 /** |
|
141 * Packs MPresenceBuddyInfoList object into a buffer |
|
142 * |
|
143 * @param aList, MPresenceBuddyInfoList |
|
144 * @return HBufC8* buffer |
|
145 */ |
|
146 HBufC8* PackPresenceBuddyListLC(const MPresenceBuddyInfoList* aList); |
|
147 |
|
148 /** |
|
149 * Packs MXIMPIdentity object into a buffer |
|
150 * |
|
151 * @param MXIMPIdentity, aIdentity |
|
152 * @return HBufC8* buffer |
|
153 */ |
|
154 HBufC8* PackIdentityLC(const MXIMPIdentity& aIdentity); |
|
155 |
|
156 /** |
|
157 * Handle asynchronous call from server that buddies presence have been prepared. |
|
158 * This function does further processing and calls the client. |
|
159 * |
|
160 * @param aError, Error came from server. |
|
161 */ |
|
162 void HandlePreparedAllBuddiesPresenceL(TInt aError); |
|
163 |
|
164 /** |
|
165 * Return true if given identity is valid xsp identity |
|
166 * |
|
167 * @param ETrue if valid xsp identity |
|
168 */ |
|
169 TBool ValidateXspId(const TDesC& aXspId); |
|
170 |
|
171 |
|
172 /** |
|
173 * Internalize the services packet from given buffer |
|
174 * |
|
175 * @param aServicesBuffer, services buffer recieved from server. |
|
176 */ |
|
177 //CDesCArray* UnPackServicesLC(TDesC8& aServicesBuffer); |
|
178 |
|
179 |
|
180 public: //From MPresenceCacheReader and MPresenceCacheWriter |
|
181 |
|
182 MXIMPIdentity* NewIdentityLC(); |
|
183 |
|
184 public: //From MPresenceCacheReader |
|
185 |
|
186 |
|
187 MPresenceInfo* PresenceInfoLC(const MXIMPIdentity& aIdentity); |
|
188 |
|
189 TInt BuddyCountInAllServices(); |
|
190 |
|
191 TInt BuddyCountInService(const TDesC& aServiceName); |
|
192 |
|
193 TInt ServicesCount(); |
|
194 |
|
195 //CDesCArray* ServicesLC(); |
|
196 |
|
197 TInt CancelRead(); |
|
198 |
|
199 TInt SubscribePresenceBuddyChangeL(const MXIMPIdentity& aIdentity); |
|
200 |
|
201 void UnSubscribePresenceBuddyChangeL(const MXIMPIdentity& aIdentity); |
|
202 |
|
203 |
|
204 public: //From MPresenceCacheReader, Asynchronous methods |
|
205 |
|
206 TInt AllBuddiesPresenceInService(const TDesC& aServiceName, |
|
207 MPresCacheReadHandler* aHandler); |
|
208 |
|
209 TInt SetObserverForSubscribedNotifications( |
|
210 MPresCacheReadHandler* aHandler); |
|
211 |
|
212 public: //From MPresenceCacheWriter |
|
213 |
|
214 TInt WritePresenceL(const MPresenceBuddyInfo* aPresenceBuddyInfo); |
|
215 |
|
216 TInt DeleteService(const TDesC& aServiceName); |
|
217 |
|
218 TInt DeletePresenceL(const MXIMPIdentity& aIdentity); |
|
219 |
|
220 MPresenceObjectFactory& PresenceObjectFactory() const; |
|
221 |
|
222 MPresenceInfo* NewPresenceInfoLC(); |
|
223 |
|
224 MPresenceBuddyInfo* NewBuddyPresenceInfoLC(); |
|
225 |
|
226 MPresenceBuddyInfoList* NewPresenceBuddyInfoListLC(const TDesC& aServiceName); |
|
227 |
|
228 TInt CancelWrite(); |
|
229 |
|
230 |
|
231 public: //From MPresenceCacheWriter, Asynchronous methods |
|
232 |
|
233 TInt WritePresenceL(const MPresenceBuddyInfoList* aPresenceBuddyInfos, |
|
234 MPresCacheWriteHandler* aHandler); |
|
235 |
|
236 public: //Froom CActive |
|
237 |
|
238 void RunL(); |
|
239 |
|
240 void DoCancel(); |
|
241 |
|
242 private: // Data |
|
243 |
|
244 //Not Owned |
|
245 MPresCacheWriteHandler* iWriteHandler; |
|
246 |
|
247 //Not Owned |
|
248 MPresCacheReadHandler* iReadHandler; |
|
249 |
|
250 //To store async request status |
|
251 NRequest::TOpAsyncCodes iAsyncReq; |
|
252 |
|
253 /** |
|
254 * Object factory sub interface. |
|
255 */ |
|
256 CPresenceObjectFactoryImp* iPresObjFactory; |
|
257 |
|
258 /** |
|
259 * Client who subscribed cache notifications |
|
260 * NOT OWN |
|
261 */ |
|
262 MPresCacheReadHandler* iNotifyClient; |
|
263 |
|
264 /** |
|
265 * Handler for subscribed cache notifications |
|
266 * OWN |
|
267 */ |
|
268 CPresenceCacheClientNotification* iNotifyHandler; |
|
269 |
|
270 private: // friend classes |
|
271 |
|
272 friend class CPresenceCacheClientNotification; |
|
273 |
|
274 }; |
|
275 |
|
276 #endif // PRESENCECACHECLIENT_H |
|
277 |
|
278 |
|
279 |