|
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 "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: Presence Service Connection data cache implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 #ifndef CPRESENCEDATACACHEIMP_H |
|
19 #define CPRESENCEDATACACHEIMP_H |
|
20 |
|
21 #include "ximpapiobjbase.h" |
|
22 #include "presenceapiobjbase.h" |
|
23 #include "ximpitemparent.h" |
|
24 #include "presencetypehelpers.h" |
|
25 #include "ximpoperationdefs.h" |
|
26 #include "ximpapieventbase.h" |
|
27 |
|
28 class MXIMPHost; |
|
29 class COwnPresenceSubscriptionItem; |
|
30 class CPresentityPresenceSubscriptionItem; |
|
31 class CGroupContentSubscriptionItem; |
|
32 class CWatcherListSubscriptionItem; |
|
33 class MPresentityGroupInfo; |
|
34 class CXIMPIdentityImp; |
|
35 class MXIMPPscContext; |
|
36 class CXIMPSubscriptionItemBase; |
|
37 class MPresenceWatcherInfo; |
|
38 class MXIMPStatus; |
|
39 class MPresenceBlockInfo; |
|
40 class CBlockListSubscriptionItem; |
|
41 class MXIMPIdentity; |
|
42 class MPresenceInfo; |
|
43 class MXIMPDataSubscriptionState; |
|
44 class CXIMPDataSubscriptionStateImp; |
|
45 class MPresenceCacheWriter; |
|
46 |
|
47 //class CXIMPApiEventBase; |
|
48 /** |
|
49 * PSC Presence Data Cache implementation. |
|
50 * |
|
51 * @since S60 v3.2 |
|
52 */ |
|
53 class CPresenceDataCache : public CBase, |
|
54 public MXIMPItemParent |
|
55 { |
|
56 public: // Definitions |
|
57 |
|
58 /** The class ID. */ |
|
59 enum { KClassId = PRIMP_CLSID_CPRESENCEDATACACHE }; |
|
60 |
|
61 public: // Construction and destruction |
|
62 |
|
63 /** |
|
64 * Construction |
|
65 */ |
|
66 IMPORT_C static CPresenceDataCache* NewL( MXIMPHost& aHost ); |
|
67 |
|
68 /** |
|
69 * Destruction |
|
70 */ |
|
71 virtual ~CPresenceDataCache(); |
|
72 |
|
73 private: |
|
74 |
|
75 CPresenceDataCache( MXIMPHost& aHost ); |
|
76 void ConstructL(); |
|
77 |
|
78 private: //MXIMPItemParentBase |
|
79 TAny* GetInterface(TInt aInterfaceId) ; |
|
80 // Expiring items |
|
81 void RegisterExpiringItemL( CXIMPSubscriptionItemBase* aExpireItem ); |
|
82 void UnregisterExpiringItem( CXIMPSubscriptionItemBase* aExpireItem ); |
|
83 |
|
84 |
|
85 private: // From MXIMPItemParent |
|
86 |
|
87 /** |
|
88 * @see MXIMPItemParent |
|
89 */ |
|
90 // Subscription items |
|
91 |
|
92 void RemoveMe( COwnPresenceSubscriptionItem* aChild ); |
|
93 void RemoveMe( CGroupListSubscriptionItem* aChild ); |
|
94 void RemoveMe( CGroupContentSubscriptionItem* aChild ); |
|
95 void RemoveMe( CPresentityPresenceSubscriptionItem* aChild ); |
|
96 void RemoveMe( CWatcherListSubscriptionItem* aChild ); |
|
97 void RemoveMe( CPresentityGroupMembersPresenceSubscriptionItem* aChild ); |
|
98 void RemoveMe( CGrantRequestListSubscriptionItem* aChild ); |
|
99 void RemoveMe( CBlockListSubscriptionItem* aChild ); |
|
100 |
|
101 void AddPresentityPresenceSubscriberL( const CXIMPIdentityImp& aIdentity, CXIMPSubscriptionItemBase* aItem, CXIMPIdentityImp* aGroup = NULL ); |
|
102 void RemovePresentityPresenceSubscriber( const CXIMPIdentityImp& aIdentity, CXIMPSubscriptionItemBase* aItem ); |
|
103 void ActivatePresentityPresenceSubscriberL( const CXIMPIdentityImp& aIdentity, CXIMPSubscriptionItemBase* aItem ); |
|
104 void SynthesisePresentityPresenceSubscriptionEventToL( const CXIMPIdentityImp& aIdentity, MXIMPPscContext* aContext, TBool aForceEvent ); |
|
105 |
|
106 // Configuration items |
|
107 void RemoveMe( CPresenceConfigurationItem* aChild ); |
|
108 void RemoveMe( CPresenceToEveryoneConfigurationItem* aChild ); |
|
109 void RemoveMe( CGroupMembersPresenceConfigurationItem* aChild ); |
|
110 |
|
111 void AddPresenceConfiguratorL( const CXIMPIdentityImp& aIdentity, CXIMPConfigurationItemBase* aItem ); |
|
112 void RemovePresenceConfigurator( const CXIMPIdentityImp& aIdentity, CXIMPConfigurationItemBase* aItem ); |
|
113 |
|
114 |
|
115 // Other methods |
|
116 void AddEventL( CXIMPApiEventBase& aEvent, MXIMPPscContext* aContext ); |
|
117 |
|
118 TInt32 ProtocolUID( ); |
|
119 |
|
120 MPresenceCacheWriter* ExternalCache(); |
|
121 |
|
122 public: // New methods |
|
123 |
|
124 /** |
|
125 * - If OwnPresenceSubscriptionItem is not found, data cache |
|
126 * initializes new one and returns ownership to caller |
|
127 * - If OwnPresenceSubscriptionItem is found, data cache increases |
|
128 * refcount by one, and returns the old object |
|
129 */ |
|
130 IMPORT_C COwnPresenceSubscriptionItem& OwnPresenceSubscriptionItemLC(); |
|
131 IMPORT_C CGroupListSubscriptionItem& GroupListSubscriptionItemLC(); |
|
132 IMPORT_C CWatcherListSubscriptionItem& WatcherListSubscriptionItemLC(); |
|
133 IMPORT_C CGrantRequestListSubscriptionItem& GrantRequestListSubscriptionItemLC(); |
|
134 IMPORT_C CBlockListSubscriptionItem& BlockListSubscriptionItemLC(); |
|
135 IMPORT_C CGroupContentSubscriptionItem& GroupContentSubscriptionItemLC( |
|
136 const CXIMPIdentityImp& aGroupId ); |
|
137 IMPORT_C CPresentityPresenceSubscriptionItem& PresentityPresenceSubscriptionItemLC( |
|
138 const CXIMPIdentityImp& aIdentity ); |
|
139 IMPORT_C CPresentityGroupMembersPresenceSubscriptionItem& |
|
140 PresentityGroupMembersPresenceSubscriptionItemLC( const CXIMPIdentityImp& aIdentity ); |
|
141 |
|
142 IMPORT_C CPresenceConfigurationItem& PresenceConfigurationItemLC( const CXIMPIdentityImp& aIdentity ); |
|
143 IMPORT_C CPresenceToEveryoneConfigurationItem& PresenceToEveryoneConfigurationItemLC(); |
|
144 IMPORT_C CGroupMembersPresenceConfigurationItem& GroupMembersPresenceConfigurationItemLC( |
|
145 const CXIMPIdentityImp& aGroupId ); |
|
146 |
|
147 |
|
148 /** |
|
149 * Checks if group content subscription item with given group id is found. |
|
150 */ |
|
151 IMPORT_C TBool GroupContentSubscriptionItemExists( const CXIMPIdentityImp& aGroupId ); |
|
152 |
|
153 /** |
|
154 * Clean resources concerning context. |
|
155 */ |
|
156 IMPORT_C void CleanResources( MXIMPPscContext& aContext ); |
|
157 |
|
158 /** |
|
159 * |
|
160 */ |
|
161 IMPORT_C void CleanExpired(); |
|
162 |
|
163 /** |
|
164 * Helper method to pack group id. |
|
165 * @param aGroupId The group id to be packed. |
|
166 * @return HBufC8 containing the packed group id. |
|
167 */ |
|
168 HBufC8* PackGroupIdLC( const MXIMPIdentity& aGroupId ); |
|
169 |
|
170 IMPORT_C const MXIMPDataSubscriptionState& OwnPresenceDataSubscriptionState() const; |
|
171 IMPORT_C const MXIMPDataSubscriptionState& PresentityGroupListDataSubscriptionState() const; |
|
172 IMPORT_C const MXIMPDataSubscriptionState& PresentityGroupContentDataSubscriptionState( |
|
173 const MXIMPIdentity& aGroupId ) const; |
|
174 IMPORT_C const MXIMPDataSubscriptionState& PresentityPresenceDataSubscriptionState( |
|
175 const MXIMPIdentity& aPresentityId ) const; |
|
176 IMPORT_C const MXIMPDataSubscriptionState& PresenceWatcherListDataSubscriptionState() const; |
|
177 IMPORT_C const MXIMPDataSubscriptionState& PresenceBlockDataSubscriptionState() const; |
|
178 IMPORT_C const MXIMPDataSubscriptionState& PresenceGrantRequestDataSubscriptionState() const; |
|
179 |
|
180 private: // Helper methods |
|
181 |
|
182 /** |
|
183 * Template method for removeMe when one subscription item is target. |
|
184 * @param aItem Reference to subscription item pointer to remove. |
|
185 * @param Pointer of item to remove. |
|
186 */ |
|
187 template< class Type > |
|
188 IMPORT_C static void RemoveMe( Type*& aItem, Type* aChild ); |
|
189 |
|
190 /** |
|
191 * Template method for removeme if target subscription item is in array. |
|
192 * @param aItemArray Array of subscription items where aChild should exists. |
|
193 * @param Pointer of item to remove. |
|
194 */ |
|
195 template< class Type > |
|
196 void RemoveMeFromArray( RPointerArray< Type >& aItemArray, Type* aChild ); |
|
197 |
|
198 /** |
|
199 * Templated item instance creation. If item is not found it is created. |
|
200 * @param aItem Reference to pointer where new item should be saved. |
|
201 * @return Reference to item created. |
|
202 */ |
|
203 template< class Type > |
|
204 Type& ItemLC( Type*& aItem ); |
|
205 |
|
206 /** |
|
207 * Templated item instance creation. If item is not found it is created. |
|
208 * @param aItemArray Array of items where new item should be created. |
|
209 * @param aIdentity. Key for finding item or for creating the new one. |
|
210 * @return Reference to item created. |
|
211 */ |
|
212 template< class Type > |
|
213 Type& ArrayItemLC( RPointerArray< Type >& aItemArray, const CXIMPIdentityImp& aIdentity ); |
|
214 |
|
215 /** |
|
216 * Templated item instance creation. If item is not found it is created. |
|
217 * @param aItemArray Array of items where new item should be created. |
|
218 * @param aContentArray. Content array for passing to new created item. |
|
219 * @param aIdentity. Key for finding item or for creating the new one. |
|
220 * @return Reference to item created. |
|
221 */ |
|
222 template< class Type, class ContentType > |
|
223 Type& ArrayItemLC( RPointerArray< Type >& aItemArray, |
|
224 RPointerArray< ContentType >& aContentArray, |
|
225 const CXIMPIdentityImp& aIdentity ); |
|
226 |
|
227 /** |
|
228 * Get data subscription state for item. |
|
229 * @param aItem Item which data subscription state should be found. |
|
230 * @return Data subscription state. |
|
231 */ |
|
232 template< class Type > |
|
233 const MXIMPDataSubscriptionState& DataSubscriptionState( Type* aItem ) const; |
|
234 |
|
235 /** |
|
236 * Get data subscription state for item. |
|
237 * @param aItemArray Item array where item should be found. |
|
238 * @aIdentity Key for finding right item. |
|
239 * @return Data subscription state. |
|
240 */ |
|
241 template< class Type > |
|
242 const MXIMPDataSubscriptionState& DataSubscriptionState( const RPointerArray< Type >& aItemArray, |
|
243 const MXIMPIdentity& aIdentity ) const; |
|
244 |
|
245 private: // Data |
|
246 |
|
247 /** |
|
248 * Access to host. |
|
249 */ |
|
250 MXIMPHost& iHost; |
|
251 |
|
252 /** |
|
253 * Does not own. Removed when RemoveMe called. |
|
254 */ |
|
255 COwnPresenceSubscriptionItem* iOwnSubscriptionItem; |
|
256 CGroupListSubscriptionItem* iGroupListSubscriptionItem; |
|
257 RPointerArray< CGroupContentSubscriptionItem > iGroupContentSubscriptionItems; |
|
258 RPointerArray< CPresentityPresenceSubscriptionItem > iPresentityPresenceSubscriptionItems; |
|
259 CWatcherListSubscriptionItem* iWatcherListSubscriptionItem; |
|
260 CGrantRequestListSubscriptionItem* iGrantRequestListSubscriptionItem; |
|
261 RPointerArray< CPresentityGroupMembersPresenceSubscriptionItem > iGroupMembersPresenceSubscriptionItems; |
|
262 CBlockListSubscriptionItem* iBlockListSubscriptionItem; |
|
263 |
|
264 RPointerArray< CXIMPSubscriptionItemBase > iExpiringSubscriptionItems; |
|
265 |
|
266 RPointerArray< CPresenceConfigurationItem > iPresenceConfigurationItems; |
|
267 CPresenceToEveryoneConfigurationItem* iPresenceToEveryoneConfigurationItem; |
|
268 RPointerArray< CGroupMembersPresenceConfigurationItem > iGroupMembersPresenceConfigurationItems; |
|
269 |
|
270 /** |
|
271 * Empty subscription state to pass adaptation exists request is subscription item does not exists. |
|
272 */ |
|
273 CXIMPDataSubscriptionStateImp* iEmptySubscriptionState; |
|
274 |
|
275 MPresenceCacheWriter *iExtPresenceCache; |
|
276 /* ======================================================================== */ |
|
277 |
|
278 }; |
|
279 #endif // CPRESENCEDATACACHEIMP_H |