|
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: Grant presence to presentity group members operation |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnection.h> |
|
20 #include <protocolpresenceauthorization.h> |
|
21 #include <protocolpresencefeatures.h> |
|
22 |
|
23 #include "operationgrantpresencetopresentitygroupmembers.h" |
|
24 #include "presenceinfofilterimp.h" |
|
25 #include "ximpidentityimp.h" |
|
26 #include "presencedatacacheimp.h" |
|
27 #include "ximpobjecthelpers.h" |
|
28 #include "documentutils.h" |
|
29 #include "ximprestrictedobjectcollectionimp.h" |
|
30 #include "ximphost.h" |
|
31 #include "ximpstatusimp.h" |
|
32 #include "ximppsccontextimp.h" |
|
33 #include "ximppanics.h" |
|
34 #include "protocolpresencedatahostimp.h" |
|
35 |
|
36 #include "ximptrace.h" |
|
37 // ============================ MEMBER FUNCTIONS ============================= |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // COperationGrantPresenceToPresentityGroupMembers::COperationGrantPresenceToPresentityGroupMembers() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C COperationGrantPresenceToPresentityGroupMembers::COperationGrantPresenceToPresentityGroupMembers() |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // COperationGrantPresenceToPresentityGroupMembers::~COperationGrantPresenceToPresentityGroupMembers() |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 COperationGrantPresenceToPresentityGroupMembers::~COperationGrantPresenceToPresentityGroupMembers() |
|
53 { |
|
54 delete iPif; |
|
55 delete iGroupId; |
|
56 delete iMergedPif; |
|
57 |
|
58 if( iConfItem ) |
|
59 { |
|
60 iConfItem->Close(); |
|
61 } |
|
62 } |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // COperationGrantPresenceToPresentityGroupMembers::ConstructL() |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void COperationGrantPresenceToPresentityGroupMembers::ConstructL( const TDesC8& aParamPck ) |
|
69 { |
|
70 // Read params. PIF and identity |
|
71 RDesReadStream rs; |
|
72 rs.Open( aParamPck ); // CSI: 65 # Does not return a value. |
|
73 CleanupClosePushL( rs ); |
|
74 |
|
75 // group id |
|
76 iPif = CPresenceInfoFilterImp::NewLC(); |
|
77 CleanupStack::Pop( iPif ); |
|
78 iPif->InternalizeL( rs ); |
|
79 |
|
80 // identity |
|
81 iGroupId = CXIMPIdentityImp::NewLC(); |
|
82 CleanupStack::Pop( iGroupId ); |
|
83 iGroupId->InternalizeL( rs ); |
|
84 |
|
85 CleanupStack::PopAndDestroy(); // rs |
|
86 } |
|
87 |
|
88 |
|
89 // --------------------------------------------------------------------------- |
|
90 // COperationGrantPresenceToPresentityGroupMembers::ProcessL() |
|
91 // --------------------------------------------------------------------------- |
|
92 // |
|
93 void COperationGrantPresenceToPresentityGroupMembers::ProcessL() |
|
94 { |
|
95 TRACE(_L("COperationGrantPresenceToPresentityGroupMembers::ProcessL()" ) ); |
|
96 CXIMPOperationBase::ProcessL(); |
|
97 |
|
98 CGroupMembersPresenceConfigurationItem& confItem = |
|
99 iMyHost->PresenceDataAccess().PresenceDataCache().GroupMembersPresenceConfigurationItemLC( *iGroupId ); |
|
100 CleanupStack::Pop(); // subItem |
|
101 iConfItem = &confItem; |
|
102 |
|
103 iConfigurationStatus = iConfItem->ConfigurationStatus( iContext ); |
|
104 |
|
105 MProtocolPresenceAuthorization& authorization = |
|
106 iMyHost->GetConnection().ProtocolPresenceFeatures().PresenceAuthorization(); |
|
107 |
|
108 switch( iConfigurationStatus ) |
|
109 { |
|
110 case CGroupMembersPresenceConfigurationItem::ENotConfiguredAtAll: |
|
111 { |
|
112 iMergedPif = TXIMPObjectCloner< CPresenceInfoFilterImp >::CloneL( *iPif ); |
|
113 authorization.DoGrantPresenceForPresentityGroupMembersL( *iGroupId, |
|
114 *iMergedPif, |
|
115 iReqId ); |
|
116 break; |
|
117 } |
|
118 case CGroupMembersPresenceConfigurationItem::EConfiguredForOtherCtxOnly: |
|
119 { |
|
120 // Aggregate subscription and context pifs |
|
121 // Check aggregate and if needed.. update subscription |
|
122 iMergedPif = DocumentUtils::InfoFilterUnionL( iConfItem->ConfigurationPif(), *iPif ); |
|
123 if( iMergedPif->Contains( iConfItem->ConfigurationPif() ) ) |
|
124 { |
|
125 authorization.DoUpdatePresenceGrantPifForPresentityGroupMembersL( *iGroupId, |
|
126 *iMergedPif, |
|
127 iReqId ); |
|
128 } |
|
129 else |
|
130 { |
|
131 iMyHost->FakeCompleteRequest( iReqId, KErrNone ); |
|
132 } |
|
133 break; |
|
134 } |
|
135 case CGroupMembersPresenceConfigurationItem::EConfiguredForCtxOnly: |
|
136 case CGroupMembersPresenceConfigurationItem::EConfiguredForCtxAndOthers: |
|
137 { |
|
138 CPresenceInfoFilterImp* oldPif = |
|
139 iContext->PresenceInfoFilter( MXIMPPscContext::EGrantPresenceToGroupMemberFilter, iGroupId ); |
|
140 CPresenceInfoFilterImp& oldMergedPif = iConfItem->ConfigurationPif(); |
|
141 TBool makeUnion( EFalse ); |
|
142 if( !oldPif ) |
|
143 { |
|
144 TRACE(_L("COperationGrantPresenceToPresentityGroupMembers::ProcessL() no old pif" ) ); |
|
145 makeUnion = ETrue; |
|
146 } |
|
147 else if ( *oldPif != *iPif ) |
|
148 { |
|
149 makeUnion = ETrue; |
|
150 } |
|
151 if( makeUnion ) |
|
152 { |
|
153 iDoNotForce = ETrue; |
|
154 CPresenceInfoFilterImp* withoutPif = |
|
155 iConfItem->CollectConfigurationPifWithoutCtxL( iContext ); |
|
156 iMergedPif = DocumentUtils::InfoFilterUnionL( *withoutPif, *iPif ); |
|
157 } |
|
158 else |
|
159 { |
|
160 iMergedPif = TXIMPObjectCloner< CPresenceInfoFilterImp >::CloneL( oldMergedPif ); |
|
161 } |
|
162 |
|
163 if( iMergedPif->Contains( oldMergedPif ) ) |
|
164 { |
|
165 iDoNotForce = ETrue; |
|
166 authorization.DoUpdatePresenceGrantPifForPresentityGroupMembersL( *iGroupId, |
|
167 *iMergedPif, |
|
168 iReqId ); |
|
169 } |
|
170 else |
|
171 { |
|
172 iMyHost->FakeCompleteRequest( iReqId, KErrNone ); |
|
173 } |
|
174 break; |
|
175 } |
|
176 |
|
177 XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus ); |
|
178 } |
|
179 } |
|
180 |
|
181 |
|
182 // --------------------------------------------------------------------------- |
|
183 // COperationGrantPresenceToPresentityGroupMembers::RequestCompleted() |
|
184 // --------------------------------------------------------------------------- |
|
185 // |
|
186 void COperationGrantPresenceToPresentityGroupMembers::RequestCompletedL() |
|
187 { |
|
188 TRACE(_L("COperationGrantPresenceToPresentityGroupMembers::RequestCompletedL()" ) ); |
|
189 CXIMPOperationBase::RequestCompletedL(); |
|
190 |
|
191 if( iStatusObj->ResultCode() == KErrNone ) |
|
192 { |
|
193 |
|
194 if( iConfigurationStatus == CGroupMembersPresenceConfigurationItem::ENotSubscribedAtAll ) |
|
195 { |
|
196 MXIMPBase* object = NULL; |
|
197 iObjCollection->GetByType( object, MXIMPIdentity::KInterfaceId ); |
|
198 if( object ) |
|
199 { |
|
200 delete iGroupId; |
|
201 iGroupId = TXIMPGetImpClassOrPanic< CXIMPIdentityImp >::From( *object ); |
|
202 |
|
203 // Got altered identity. If it differs from original |
|
204 // we'll create a new subscription item and close the old. |
|
205 CGroupMembersPresenceConfigurationItem& altSubItem = |
|
206 iMyHost->PresenceDataAccess().PresenceDataCache().GroupMembersPresenceConfigurationItemLC( *iGroupId ); |
|
207 |
|
208 iConfItem->Close(); |
|
209 iConfItem = &altSubItem; |
|
210 |
|
211 CleanupStack::Pop(); // altSubItem |
|
212 } |
|
213 } |
|
214 |
|
215 if( iConfigurationStatus == CGroupMembersPresenceConfigurationItem::ENotSubscribedAtAll || |
|
216 iConfigurationStatus == CGroupMembersPresenceConfigurationItem::ESubscribedForOtherCtxOnly ) |
|
217 { |
|
218 iConfItem->AddConfiguratorL( iContext ); |
|
219 } |
|
220 |
|
221 iContext->SetPresenceInfoFilterL( MXIMPPscContext::EGrantPresenceToGroupMemberFilter, |
|
222 iPif, iGroupId ); |
|
223 iPif = NULL; |
|
224 iConfItem->SetConfigurationPif( iMergedPif ); |
|
225 iMergedPif = NULL; |
|
226 |
|
227 SynthesiseEventL(); |
|
228 } |
|
229 } |
|
230 |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // COperationGrantPresenceToPresentityGroupMembers::Type() |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 TInt |
|
237 COperationGrantPresenceToPresentityGroupMembers::Type() const |
|
238 { |
|
239 return NPresenceOps::EPrGrantPresenceToPresentityGroupMembers; |
|
240 } |
|
241 |
|
242 // --------------------------------------------------------------------------- |
|
243 // COperationGrantPresenceToPresentityGroupMembers::SynthesiseEventL() |
|
244 // --------------------------------------------------------------------------- |
|
245 // |
|
246 void COperationGrantPresenceToPresentityGroupMembers::SynthesiseEventL() |
|
247 { |
|
248 } |
|
249 |
|
250 |
|
251 |
|
252 // End of file |