|
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: Presentity group content subscription operator |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnection.h> |
|
20 #include <protocolpresentitygroups.h> |
|
21 #include <protocolpresencefeatures.h> |
|
22 |
|
23 #include "operationsubscribegroupcontent.h" |
|
24 #include "ximpobjecthelpers.h" |
|
25 #include "presencedatacacheimp.h" |
|
26 #include "ximppanics.h" |
|
27 #include "operationsynthesisesubscriptionevent.h" |
|
28 #include "ximprestrictedobjectcollectionimp.h" |
|
29 #include "ximpidentityimp.h" |
|
30 #include "ximphost.h" |
|
31 #include "ximpstatusimp.h" |
|
32 #include "ximppsccontextimp.h" |
|
33 #include "protocolpresencedatahostimp.h" |
|
34 |
|
35 #include "ximptrace.h" |
|
36 |
|
37 // ============================ MEMBER FUNCTIONS ============================= |
|
38 |
|
39 // --------------------------------------------------------------------------- |
|
40 // COperationSubscribeGroupContent::COperationSubscribeGroupContent() |
|
41 // --------------------------------------------------------------------------- |
|
42 // |
|
43 EXPORT_C COperationSubscribeGroupContent::COperationSubscribeGroupContent() |
|
44 { |
|
45 } |
|
46 |
|
47 |
|
48 // --------------------------------------------------------------------------- |
|
49 // COperationSubscribeGroupContent::~COperationSubscribeGroupContent() |
|
50 // --------------------------------------------------------------------------- |
|
51 // |
|
52 COperationSubscribeGroupContent::~COperationSubscribeGroupContent() |
|
53 { |
|
54 if( iSubItem ) |
|
55 { |
|
56 iSubItem->Close(); |
|
57 } |
|
58 delete iGroupId; |
|
59 } |
|
60 |
|
61 // --------------------------------------------------------------------------- |
|
62 // COperationSubscribeGroupContent::ConstructL() |
|
63 // --------------------------------------------------------------------------- |
|
64 // |
|
65 void COperationSubscribeGroupContent::ConstructL( const TDesC8& aParamPck ) |
|
66 { |
|
67 iGroupId = CXIMPIdentityImp::NewLC(); |
|
68 CleanupStack::Pop( iGroupId ); |
|
69 TXIMPObjectPacker< CXIMPIdentityImp >::UnPackL( *iGroupId, aParamPck ); |
|
70 } |
|
71 |
|
72 |
|
73 // --------------------------------------------------------------------------- |
|
74 // COperationSubscribeGroupContent::ProcessL() |
|
75 // --------------------------------------------------------------------------- |
|
76 // |
|
77 void COperationSubscribeGroupContent::ProcessL() |
|
78 { |
|
79 TRACE(_L("COperationSubscribeGroupContent::ProcessL()" ) ); |
|
80 CXIMPOperationBase::ProcessL(); |
|
81 |
|
82 CGroupContentSubscriptionItem& subItem = |
|
83 iMyHost->PresenceDataAccess().PresenceDataCache().GroupContentSubscriptionItemLC( *iGroupId ); |
|
84 CleanupStack::Pop(); // subItem |
|
85 iSubItem = &subItem; |
|
86 iSubscriptionStatus = iSubItem->SubscriptionStatus( iContext ); |
|
87 MProtocolPresentityGroups& presentityGroups = iMyHost->GetConnection().ProtocolPresenceFeatures().PresentityGroups(); |
|
88 |
|
89 switch( iSubscriptionStatus ) |
|
90 { |
|
91 case CGroupContentSubscriptionItem::ENotSubscribedAtAll: |
|
92 { |
|
93 presentityGroups.DoSubscribePresentityGroupContentL( *iGroupId, iReqId ); |
|
94 break; |
|
95 } |
|
96 |
|
97 case CGroupContentSubscriptionItem::ESubscribedForOtherCtxOnly: |
|
98 case CGroupContentSubscriptionItem::ESubscribedForCtxOnly: |
|
99 case CGroupContentSubscriptionItem::ESubscribedForCtxAndOthers: |
|
100 { |
|
101 iMyHost->FakeCompleteRequest( iReqId, KErrNone ); |
|
102 break; |
|
103 } |
|
104 |
|
105 XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus ); |
|
106 } |
|
107 } |
|
108 |
|
109 |
|
110 // --------------------------------------------------------------------------- |
|
111 // COperationSubscribeGroupContent::RequestCompleted() |
|
112 // --------------------------------------------------------------------------- |
|
113 // |
|
114 void COperationSubscribeGroupContent::RequestCompletedL() |
|
115 { |
|
116 TRACE(_L("COperationSubscribeGroupContent::RequestCompletedL()" ) ); |
|
117 CXIMPOperationBase::RequestCompletedL(); |
|
118 |
|
119 if( iStatusObj->ResultCode() == KErrNone ) |
|
120 { |
|
121 switch( iSubscriptionStatus ) |
|
122 { |
|
123 case CGroupContentSubscriptionItem::ENotSubscribedAtAll: |
|
124 { |
|
125 CXIMPIdentityImp* altGroupId = NULL; |
|
126 MXIMPBase* object = NULL; |
|
127 iObjCollection->GetByType( object, MXIMPIdentity::KInterfaceId ); |
|
128 if( object ) |
|
129 { |
|
130 // Got altered identity |
|
131 altGroupId = TXIMPGetImpClassOrPanic< CXIMPIdentityImp >::From( *object ); |
|
132 CleanupStack::PushL( altGroupId ); |
|
133 } |
|
134 |
|
135 if ( altGroupId && iGroupId->Identity().Compare( altGroupId->Identity() ) != 0 ) |
|
136 { |
|
137 CGroupContentSubscriptionItem& altSubItem = |
|
138 iMyHost->PresenceDataAccess().PresenceDataCache().GroupContentSubscriptionItemLC( *altGroupId ); |
|
139 CleanupStack::Pop(); // altSubItem |
|
140 iSubItem->Close(); |
|
141 iSubItem = &altSubItem; |
|
142 iSubItem->AddOrRenewSubscriberL( iContext ); |
|
143 } |
|
144 else |
|
145 { |
|
146 iSubItem->AddSubscriberL( iContext ); |
|
147 } |
|
148 |
|
149 if( altGroupId ) |
|
150 { |
|
151 CleanupStack::PopAndDestroy( altGroupId ); |
|
152 } |
|
153 break; |
|
154 } |
|
155 |
|
156 case CGroupContentSubscriptionItem::ESubscribedForOtherCtxOnly: |
|
157 { |
|
158 iSubItem->AddSubscriberL( iContext ); |
|
159 break; |
|
160 } |
|
161 |
|
162 case CGroupContentSubscriptionItem::ESubscribedForCtxOnly: |
|
163 case CGroupContentSubscriptionItem::ESubscribedForCtxAndOthers: |
|
164 { |
|
165 break; |
|
166 } |
|
167 |
|
168 XIMP_DEFAULT_CASE_UNSUPPORTED( NXIMPPrivPanic::EInvalidSubscriptionStatus ); |
|
169 } |
|
170 |
|
171 SynthesiseEventL(); |
|
172 } |
|
173 } |
|
174 |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // COperationSubscribeGroupContent::Type() |
|
178 // --------------------------------------------------------------------------- |
|
179 // |
|
180 TInt |
|
181 COperationSubscribeGroupContent::Type() const |
|
182 { |
|
183 return NPresenceOps::EPrSubscribeGroupContent; |
|
184 } |
|
185 |
|
186 // --------------------------------------------------------------------------- |
|
187 // COperationSubscribeGroupContent::SynthesiseEventL() |
|
188 // --------------------------------------------------------------------------- |
|
189 // |
|
190 void COperationSubscribeGroupContent::SynthesiseEventL() |
|
191 { |
|
192 TBool force = |
|
193 ( iSubscriptionStatus == CGroupContentSubscriptionItem::ESubscribedForCtxOnly || |
|
194 iSubscriptionStatus == CGroupContentSubscriptionItem::ESubscribedForCtxAndOthers ) ? ETrue : EFalse; |
|
195 |
|
196 COperationSynthesiseSubscriptionEvent* synthOp = |
|
197 new ( ELeave ) COperationSynthesiseSubscriptionEvent( |
|
198 COperationSynthesiseSubscriptionEvent::EPresentityGroupContent, force ); |
|
199 CleanupStack::PushL( synthOp ); |
|
200 synthOp->BaseConstructL( TXIMPRequestId(), iContext ); |
|
201 synthOp->ConstructL( *iGroupId ); |
|
202 iMyHost->AddNewOperationL( *synthOp ); |
|
203 CleanupStack::Pop( synthOp ); |
|
204 } |
|
205 |
|
206 |
|
207 |
|
208 // End of file |