|
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 group list subscription implementation. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include "presentitygroupmemberspresencesubscriptionitem.h" |
|
20 #include "groupcontentsubscriptionitem.h" |
|
21 #include "presenceinfofilterimp.h" |
|
22 #include "ximpitemparent.h" |
|
23 #include "ximppanics.h" |
|
24 #include "ximppsccontext.h" |
|
25 #include "documentutils.h" // Perhaps this should be renamed |
|
26 #include "presentitypresenceeventimp.h" |
|
27 #include "presentitygroupmemberinfoimp.h" |
|
28 #include "ximpidentityimp.h" |
|
29 |
|
30 #include "ximptrace.h" |
|
31 |
|
32 // --------------------------------------------------------------------------- |
|
33 // CPresentityGroupMembersPresenceSubscriptionItem::CPresentityGroupMembersPresenceSubscriptionItem() |
|
34 // --------------------------------------------------------------------------- |
|
35 // |
|
36 CPresentityGroupMembersPresenceSubscriptionItem::CPresentityGroupMembersPresenceSubscriptionItem( MXIMPItemParentBase& aParent, CGroupContentSubscriptionItem& aContentItem ) |
|
37 : CXIMPSubscriptionItemBase( aParent ), iContentItem( aContentItem ) |
|
38 { |
|
39 } |
|
40 |
|
41 |
|
42 // --------------------------------------------------------------------------- |
|
43 // CPresentityGroupMembersPresenceSubscriptionItem::ConstructL() |
|
44 // --------------------------------------------------------------------------- |
|
45 // |
|
46 void CPresentityGroupMembersPresenceSubscriptionItem::ConstructL() |
|
47 { |
|
48 BaseConstructL(); |
|
49 iContentItem.RegisterEventObserverL( this ); |
|
50 } |
|
51 |
|
52 |
|
53 // --------------------------------------------------------------------------- |
|
54 // CPresentityGroupMembersPresenceSubscriptionItem::NewLC() |
|
55 // --------------------------------------------------------------------------- |
|
56 // |
|
57 CPresentityGroupMembersPresenceSubscriptionItem* |
|
58 CPresentityGroupMembersPresenceSubscriptionItem::NewLC( MXIMPItemParentBase& aParent, |
|
59 CGroupContentSubscriptionItem& aContentItem ) |
|
60 { |
|
61 CleanupClosePushL( aContentItem ); |
|
62 CPresentityGroupMembersPresenceSubscriptionItem* self = |
|
63 new( ELeave ) CPresentityGroupMembersPresenceSubscriptionItem( aParent, aContentItem ); |
|
64 CleanupStack::Pop(); //aContentItem |
|
65 CleanupClosePushL( *self ); |
|
66 self->ConstructL(); |
|
67 return self; |
|
68 } |
|
69 |
|
70 |
|
71 // --------------------------------------------------------------------------- |
|
72 // CPresentityGroupMembersPresenceSubscriptionItem::~CPresentityGroupMembersPresenceSubscriptionItem() |
|
73 // --------------------------------------------------------------------------- |
|
74 // |
|
75 CPresentityGroupMembersPresenceSubscriptionItem::~CPresentityGroupMembersPresenceSubscriptionItem() |
|
76 { |
|
77 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
78 presCache->RemoveMe( this ); |
|
79 |
|
80 |
|
81 delete iIdentity; |
|
82 delete iPresenceInfo; |
|
83 |
|
84 delete iPif; |
|
85 iContentItem.UnregisterEventObserver( this ); |
|
86 } |
|
87 |
|
88 // --------------------------------------------------------------------------- |
|
89 // CPresentityGroupMembersPresenceSubscriptionItem::SubscriptionPif() |
|
90 // --------------------------------------------------------------------------- |
|
91 // |
|
92 EXPORT_C CPresenceInfoFilterImp& |
|
93 CPresentityGroupMembersPresenceSubscriptionItem::SubscriptionPif() |
|
94 { |
|
95 TRACE(_L("CPresentityGroupMembersPresenceSubscriptionItem::SubscriptionPif" ) ); |
|
96 __ASSERT_ALWAYS( iPif, User::Panic( NXIMPPrivPanic::KCategory, |
|
97 NXIMPPrivPanic::EOwnPresencePifNotSet ) ); |
|
98 return *iPif; |
|
99 } |
|
100 |
|
101 // --------------------------------------------------------------------------- |
|
102 // CPresentityGroupMembersPresenceSubscriptionItem::SetSubscriptionPif() |
|
103 // --------------------------------------------------------------------------- |
|
104 // |
|
105 EXPORT_C void CPresentityGroupMembersPresenceSubscriptionItem::SetSubscriptionPif( |
|
106 CPresenceInfoFilterImp* aPif ) |
|
107 { |
|
108 TRACE(_L("CPresentityGroupMembersPresenceSubscriptionItem::SetSubscriptionPif" ) ); |
|
109 delete iPif; |
|
110 iPif = aPif; |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // CPresentityGroupMembersPresenceSubscriptionItem::CollectSubscriptionPifWithoutCtxL() |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 EXPORT_C CPresenceInfoFilterImp* |
|
118 CPresentityGroupMembersPresenceSubscriptionItem::CollectSubscriptionPifWithoutCtxL( |
|
119 MXIMPPscContext* aContext ) |
|
120 { |
|
121 TRACE(_L("CPresentityGroupMembersPresenceSubscriptionItem::CollectSubscriptionPifWithoutCtxL" ) ); |
|
122 RPointerArray< CPresenceInfoFilterImp > arrayOfPifs; |
|
123 CleanupClosePushL( arrayOfPifs ); |
|
124 |
|
125 TInt count = iContexts.Count(); |
|
126 for( TInt a = 0; a < count; ++a ) |
|
127 { |
|
128 if( iContexts[ a ] != aContext ) |
|
129 { |
|
130 CPresenceInfoFilterImp* filter = iContexts[ a ]->PresenceInfoFilter( |
|
131 MXIMPPscContext::EPresentityGroupMemberPresenceFilter, iIdentity ); |
|
132 if ( filter ) |
|
133 { |
|
134 arrayOfPifs.AppendL( filter ); |
|
135 } |
|
136 } |
|
137 } |
|
138 CPresenceInfoFilterImp* pifWithoutCtx = DocumentUtils::InfoFilterUnionL( arrayOfPifs ); |
|
139 CleanupStack::PopAndDestroy(); // arrayOfPifs |
|
140 TRACE(_L("CPresentityGroupMembersPresenceSubscriptionItem::CollectSubscriptionPifWithoutCtxL done" ) ); |
|
141 return pifWithoutCtx; |
|
142 } |
|
143 |
|
144 // --------------------------------------------------------------------------- |
|
145 // CPresentityGroupMembersPresenceSubscriptionItem::SetPresenceInfoL() |
|
146 // --------------------------------------------------------------------------- |
|
147 // |
|
148 EXPORT_C void CPresentityGroupMembersPresenceSubscriptionItem::SetPresenceInfoL( |
|
149 CPresenceInfoImp* aPresenceInfo ) |
|
150 { |
|
151 TRACE(_L("CPresentityGroupMembersPresenceSubscriptionItem::SetPresenceInfoL" ) ); |
|
152 delete iPresenceInfo; |
|
153 iPresenceInfo = aPresenceInfo; |
|
154 iSubscriptionState->SetDataStateL( MXIMPDataSubscriptionState::EDataAvailable ); |
|
155 } |
|
156 |
|
157 // --------------------------------------------------------------------------- |
|
158 // CPresentityGroupMembersPresenceSubscriptionItem::Order() |
|
159 // --------------------------------------------------------------------------- |
|
160 // |
|
161 EXPORT_C TInt CPresentityGroupMembersPresenceSubscriptionItem::Order( |
|
162 const CPresentityGroupMembersPresenceSubscriptionItem& aA, |
|
163 const CPresentityGroupMembersPresenceSubscriptionItem& aB ) |
|
164 { |
|
165 return IdentityOrder( aA.iIdentity, aB ); |
|
166 } |
|
167 // --------------------------------------------------------------------------- |
|
168 // CPresentityGroupMembersPresenceSubscriptionItem::Order() |
|
169 // --------------------------------------------------------------------------- |
|
170 // |
|
171 EXPORT_C TInt CPresentityGroupMembersPresenceSubscriptionItem::IdentityOrder( |
|
172 const CXIMPIdentityImp* aA, |
|
173 const CPresentityGroupMembersPresenceSubscriptionItem& aB ) |
|
174 { |
|
175 return aA->Compare( *aB.iIdentity ); |
|
176 } |
|
177 |
|
178 // --------------------------------------------------------------------------- |
|
179 // CPresentityGroupMembersPresenceSubscriptionItem::Identity() |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 EXPORT_C const MXIMPIdentity& CPresentityGroupMembersPresenceSubscriptionItem::Identity() const |
|
183 { |
|
184 return *iIdentity; |
|
185 } |
|
186 |
|
187 // --------------------------------------------------------------------------- |
|
188 // CPresentityGroupMembersPresenceSubscriptionItem::SetIdentity() |
|
189 // --------------------------------------------------------------------------- |
|
190 // |
|
191 EXPORT_C void CPresentityGroupMembersPresenceSubscriptionItem::SetIdentity( |
|
192 CXIMPIdentityImp* aIdentity ) |
|
193 { |
|
194 delete iIdentity; |
|
195 iIdentity = aIdentity; |
|
196 } |
|
197 |
|
198 // --------------------------------------------------------------------------- |
|
199 // From class MXIMPSubscriptionItem. |
|
200 // CPresentityGroupMembersPresenceSubscriptionItem::SynthesiseSubscriptionEventTo() |
|
201 // --------------------------------------------------------------------------- |
|
202 // |
|
203 void CPresentityGroupMembersPresenceSubscriptionItem::SynthesiseSubscriptionEventToL( |
|
204 MXIMPPscContext* aContext, |
|
205 TBool aForceEvent ) |
|
206 { |
|
207 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::SynthesiseSubscriptionEventTo() aForce=%d"), aForceEvent ); |
|
208 // Synthesise event to all members |
|
209 TInt count = iContentItem.MemberCount(); |
|
210 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::SynthesiseSubscriptionEventTo() iContentItem.MemberCount=%d"), count ); |
|
211 |
|
212 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
213 for( TInt a = 0; a < count; ++a ) |
|
214 { |
|
215 CPresentityGroupMemberInfoImp& memberInfo = iContentItem.MemberAt( a ); |
|
216 const CXIMPIdentityImp& identity = memberInfo.IdentityImp(); |
|
217 |
|
218 presCache->SynthesisePresentityPresenceSubscriptionEventToL( identity, aContext, aForceEvent ); |
|
219 } |
|
220 } |
|
221 |
|
222 |
|
223 // --------------------------------------------------------------------------- |
|
224 // CPresentityGroupMembersPresenceSubscriptionItem::ActivateSubscriberL() |
|
225 // --------------------------------------------------------------------------- |
|
226 // |
|
227 void CPresentityGroupMembersPresenceSubscriptionItem::ActivateSubscriberL( MXIMPPscContext* aContext ) |
|
228 { |
|
229 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::ActivateSubscriberL(aContext ) : aContext = %d"), aContext ); |
|
230 |
|
231 CXIMPSubscriptionItemBase::ActivateSubscriberL( aContext ); |
|
232 |
|
233 // Subscribe presentity presence items. |
|
234 TInt count = iContentItem.MemberCount(); |
|
235 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::ActivateSubscriberL(aContext ) : iContentItem.MemberCount = %d"), count ); |
|
236 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
237 for( TInt a = 0; a < count; ++a ) |
|
238 { |
|
239 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::ActivateSubscriberL(aContext ) : a = %d"), a ); |
|
240 CPresentityGroupMemberInfoImp& memberInfo = iContentItem.MemberAt( a ); |
|
241 const CXIMPIdentityImp& identity = memberInfo.IdentityImp(); |
|
242 TInt error ( KErrNone ); |
|
243 TRAP( error , presCache->ActivatePresentityPresenceSubscriberL( identity, this );); |
|
244 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::ActivateSubscriberL( aContext ) i...eSubscriberL = %d"), error ); |
|
245 } |
|
246 } |
|
247 |
|
248 |
|
249 // --------------------------------------------------------------------------- |
|
250 // CPresentityGroupMembersPresenceSubscriptionItem::CleanExpired() |
|
251 // --------------------------------------------------------------------------- |
|
252 // |
|
253 void CPresentityGroupMembersPresenceSubscriptionItem::CleanExpired() |
|
254 { |
|
255 |
|
256 } |
|
257 |
|
258 // --------------------------------------------------------------------------- |
|
259 // CPresentityGroupMembersPresenceSubscriptionItem::AddSubscriberL() |
|
260 // --------------------------------------------------------------------------- |
|
261 // |
|
262 EXPORT_C void CPresentityGroupMembersPresenceSubscriptionItem::AddSubscriberL( MXIMPPscContext* aContext ) |
|
263 { |
|
264 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::AddSubscriberL( MXIMPPscContext* aContext ) : aContext = %d"), aContext ); |
|
265 |
|
266 CXIMPSubscriptionItemBase::AddSubscriberL( aContext ); |
|
267 |
|
268 // Subscribe presentity presence items. |
|
269 TInt count = iContentItem.MemberCount(); |
|
270 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::AddSubscriberL( MXIMPPscContext* aContext ) : iContentItem.MemberCount = %d"), count ); |
|
271 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
272 for( TInt a = 0; a < count; ++a ) |
|
273 { |
|
274 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::AddSubscriberL( MXIMPPscContext* aContext ) : a = %d"), a ); |
|
275 |
|
276 CPresentityGroupMemberInfoImp& memberInfo = iContentItem.MemberAt( a ); |
|
277 const CXIMPIdentityImp& identity = memberInfo.IdentityImp(); |
|
278 TInt error ( KErrNone ); |
|
279 TRAP( error , presCache->AddPresentityPresenceSubscriberL( identity, this, iIdentity );); |
|
280 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::AddSubscriberL( MXIMPPscContext* aContext ) : TRAPD( error , iParent.AddPresentityPresenceSubscriberL = %d"), error ); |
|
281 |
|
282 } |
|
283 } |
|
284 |
|
285 |
|
286 // --------------------------------------------------------------------------- |
|
287 // CPresentityGroupMembersPresenceSubscriptionItem::RemoveSubscriber() |
|
288 // --------------------------------------------------------------------------- |
|
289 // |
|
290 EXPORT_C void CPresentityGroupMembersPresenceSubscriptionItem::RemoveSubscriber( MXIMPPscContext* aContext ) |
|
291 { |
|
292 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::RemoveSubscriber( MXIMPPscContext* aContext ) : aContext = %d"), aContext ); |
|
293 |
|
294 // Subscribe presentity presence items. |
|
295 TInt count = iContentItem.MemberCount(); |
|
296 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::RemoveSubscriber( MXIMPPscContext* aContext ) : iContentItem.MemberCount = %d"), count ); |
|
297 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
298 for( TInt a = 0; a < count; ++a ) |
|
299 { |
|
300 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::RemoveSubscriber( MXIMPPscContext* aContext ) : a = %d"), a ); |
|
301 |
|
302 CPresentityGroupMemberInfoImp& memberInfo = iContentItem.MemberAt( a ); |
|
303 const CXIMPIdentityImp& identity = memberInfo.IdentityImp(); |
|
304 |
|
305 presCache->RemovePresentityPresenceSubscriber( identity, this ); |
|
306 } |
|
307 |
|
308 TRACE( _L("CPresentityGroupMembersPresenceSubscriptionItem::RemoveSubscriber( MXIMPPscContext* aContext ) : CXIMPSubscriptionItemBase::RemoveSubscriber( aContext )") ); |
|
309 CXIMPSubscriptionItemBase::RemoveSubscriber( aContext ); |
|
310 } |
|
311 |
|
312 // --------------------------------------------------------------------------- |
|
313 // CPresentityGroupMembersPresenceSubscriptionItem::HandleChangeL() |
|
314 // --------------------------------------------------------------------------- |
|
315 // |
|
316 void CPresentityGroupMembersPresenceSubscriptionItem::HandleChangeL( |
|
317 RPrGrpMemInfoImpArray& aAdded, RPrGrpMemInfoImpArray& aRemoved ) |
|
318 { |
|
319 TRACE_2( _L("CPresentityGroupMembersPresenceSubscriptionItem::HandleChangeL aAdded =%d aRemoved=%d"), aAdded.Count(), aRemoved.Count() ); |
|
320 TInt count = aAdded.Count(); |
|
321 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
322 for( TInt a = 0; a < count; ++a ) |
|
323 { |
|
324 CPresentityGroupMemberInfoImp& memberInfo = *aAdded[ a ]; |
|
325 const CXIMPIdentityImp& identity = memberInfo.IdentityImp(); |
|
326 |
|
327 presCache->AddPresentityPresenceSubscriberL( identity, this, iIdentity ); |
|
328 } |
|
329 count = aRemoved.Count(); |
|
330 for( TInt a = 0; a < count; ++a ) |
|
331 { |
|
332 CPresentityGroupMemberInfoImp& memberInfo = *aRemoved[ a ]; |
|
333 const CXIMPIdentityImp& identity = memberInfo.IdentityImp(); |
|
334 |
|
335 presCache->RemovePresentityPresenceSubscriber( identity, this ); |
|
336 } |
|
337 } |
|
338 |
|
339 // --------------------------------------------------------------------------- |
|
340 // CPresentityGroupMembersPresenceSubscriptionItem::HandleSynthesiseL() |
|
341 // --------------------------------------------------------------------------- |
|
342 // |
|
343 void CPresentityGroupMembersPresenceSubscriptionItem::HandleSynthesiseL( |
|
344 RPrGrpMemInfoImpArray& aTarget ) |
|
345 { |
|
346 TInt count = aTarget.Count(); |
|
347 TRACE_1( _L("CPresentityGroupMembersPresenceSubscriptionItem::HandleSynthesiseL aTarget=%d"), aTarget.Count() ); |
|
348 MXIMPItemParent* presCache = static_cast<MXIMPItemParent*>(iParent.GetInterface(PRESENCE_ITEM_PARENT)); |
|
349 for( TInt a = 0; a < count; ++a ) |
|
350 { |
|
351 CPresentityGroupMemberInfoImp& memberInfo = *aTarget[ a ]; |
|
352 const CXIMPIdentityImp& identity = memberInfo.IdentityImp(); |
|
353 |
|
354 presCache->ActivatePresentityPresenceSubscriberL( identity, this ); |
|
355 TInt contextCount = iContexts.Count(); |
|
356 for( TInt b = 0; b < contextCount; ++b ) |
|
357 { |
|
358 presCache->SynthesisePresentityPresenceSubscriptionEventToL( identity, iContexts[ a ], EFalse ); |
|
359 } |
|
360 } |
|
361 } |
|
362 |
|
363 // End of file |