|
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: IMPS Protocol implementation for Presence Framework |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnectionhost.h> |
|
20 #include "CImpsPluginGroupSubscribePresentityGroupListRequest.h" |
|
21 #include "impsconnectionmanagercontrolif.h" |
|
22 #include "impsdebugprint.h" |
|
23 #include "CImpsPluginAccessHandler.h" |
|
24 #include "CImpsPluginPureDataHandler.h" |
|
25 |
|
26 |
|
27 #include "CPEngXMLParser.h" |
|
28 #include "MPEngXMLParser.h" |
|
29 #include "CPEngXmlSerializer.h" |
|
30 #include "MPEngXmlSerializer.h" |
|
31 #include "CImpsPluginConnectionManager.h" |
|
32 #include "PEngXMLTags.h" |
|
33 |
|
34 #include <ximpobjectfactory.h> |
|
35 #include <ximpobjectcollection.h> |
|
36 #include <protocolpresentitygroupsdatahost.h> |
|
37 #include <presentitygroupinfo.h> |
|
38 #include <presentitygroupmemberinfo.h> |
|
39 #include <ximpidentity.h> |
|
40 |
|
41 |
|
42 |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 // --------------------------------------------------------------------------- |
|
47 // CImpsPluginGroupSubscribePresentityGroupListRequest::CImpsPluginGroupSubscribePresentityGroupListRequest |
|
48 // --------------------------------------------------------------------------- |
|
49 // |
|
50 CImpsPluginGroupSubscribePresentityGroupListRequest::CImpsPluginGroupSubscribePresentityGroupListRequest( MImpsPrtPluginConnectionManager& aConnMan, |
|
51 TXIMPRequestId aRequestId ) : |
|
52 CActive( EPriorityNormal ), |
|
53 iRequestId( aRequestId ), |
|
54 iConnMan( aConnMan ) |
|
55 //iPtrbuffer( NULL, 0 ) |
|
56 { |
|
57 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::CImpsPluginGroupSubscribePresentityGroupListRequest Start" ) ); |
|
58 CActiveScheduler::Add( this ); |
|
59 |
|
60 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::CImpsPluginGroupSubscribePresentityGroupListRequest End" ) ); |
|
61 } |
|
62 |
|
63 |
|
64 // --------------------------------------------------------------------------- |
|
65 // CImpsPluginGroupSubscribePresentityGroupListRequest::ConstructL |
|
66 // --------------------------------------------------------------------------- |
|
67 // |
|
68 void CImpsPluginGroupSubscribePresentityGroupListRequest::ConstructL() |
|
69 { |
|
70 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::ConstructL Start-End" ) ); |
|
71 |
|
72 iParser = CreateXMLParserL(); |
|
73 |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CImpsPluginGroupSubscribePresentityGroupListRequest::NewL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CImpsPluginGroupSubscribePresentityGroupListRequest* CImpsPluginGroupSubscribePresentityGroupListRequest::NewL( |
|
82 MImpsPrtPluginConnectionManager& aConnMan, |
|
83 TXIMPRequestId aRequestId ) |
|
84 { |
|
85 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::NewL Start" ) ); |
|
86 |
|
87 CImpsPluginGroupSubscribePresentityGroupListRequest* self = new( ELeave ) |
|
88 CImpsPluginGroupSubscribePresentityGroupListRequest( aConnMan, aRequestId ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 |
|
93 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::NewL End" ) ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CImpsPluginGroupSubscribePresentityGroupListRequest::NewLC |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CImpsPluginGroupSubscribePresentityGroupListRequest* CImpsPluginGroupSubscribePresentityGroupListRequest::NewLC( |
|
103 MImpsPrtPluginConnectionManager& aConnMan, |
|
104 TXIMPRequestId aRequestId ) |
|
105 { |
|
106 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::NewLC Start" ) ); |
|
107 |
|
108 CImpsPluginGroupSubscribePresentityGroupListRequest* self = new( ELeave ) |
|
109 CImpsPluginGroupSubscribePresentityGroupListRequest( aConnMan, aRequestId ); |
|
110 CleanupStack::PushL( self ); |
|
111 self->ConstructL(); |
|
112 |
|
113 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::NewLC End" ) ); |
|
114 return self; |
|
115 } |
|
116 |
|
117 // --------------------------------------------------------------------------- |
|
118 // CImpsPluginGroupSubscribePresentityGroupListRequest::~CImpsPluginGroupSubscribePresentityGroupListRequest |
|
119 // --------------------------------------------------------------------------- |
|
120 // |
|
121 CImpsPluginGroupSubscribePresentityGroupListRequest::~CImpsPluginGroupSubscribePresentityGroupListRequest() |
|
122 { |
|
123 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::~CImpsPluginGroupSubscribePresentityGroupListRequest Start" ) ); |
|
124 |
|
125 delete iResponse; |
|
126 delete iListId; |
|
127 CActive::Cancel(); |
|
128 iConnMan.Remove( this ); |
|
129 delete iParser; |
|
130 |
|
131 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::~CImpsPluginGroupSubscribePresentityGroupListRequest End" ) ); |
|
132 } |
|
133 |
|
134 |
|
135 // --------------------------------------------------------------------------- |
|
136 // CImpsPluginGroupSubscribePresentityGroupListRequest::DoCancel() |
|
137 // --------------------------------------------------------------------------- |
|
138 // |
|
139 void CImpsPluginGroupSubscribePresentityGroupListRequest::DoCancel() |
|
140 { |
|
141 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::DoCancel Start" ) ); |
|
142 |
|
143 iConnMan.DataHandler().CancelSending( iSendId ); |
|
144 |
|
145 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::DoCancel End" ) ); |
|
146 } |
|
147 |
|
148 |
|
149 // --------------------------------------------------------------------------- |
|
150 // CImpsPluginGroupSubscribePresentityGroupListRequest::RunL() |
|
151 // --------------------------------------------------------------------------- |
|
152 // |
|
153 void CImpsPluginGroupSubscribePresentityGroupListRequest::RunL() |
|
154 { |
|
155 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::RunL Start" ) ); |
|
156 |
|
157 User::LeaveIfError( iStatus.Int() ); |
|
158 |
|
159 iResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
160 |
|
161 MXIMPObjectFactory& objFact = iConnMan.HandleToHost().ObjectFactory(); |
|
162 MXIMPObjectCollection* listOfLists = objFact.NewObjectCollectionLC(); |
|
163 |
|
164 IMPS_DP( D_IMPS_LIT( " listOfLists::%x" ), &listOfLists ); |
|
165 |
|
166 if ( iParser->DecodeL( *iResponse, KContactList, EFalse ) ) |
|
167 { |
|
168 |
|
169 TInt countResults( iParser->Count() ); |
|
170 for ( TInt i = 0 ; i < countResults; ++i ) |
|
171 { |
|
172 // convert to 16 unicode |
|
173 //HBufC16* listId = iParser->ResultAsUnicodeTextL( i ); |
|
174 iListId = iParser->ResultAsUnicodeTextL( i ); |
|
175 iListId->Des().Fold(); |
|
176 |
|
177 IMPS_DP( D_IMPS_LIT( " iResponse::%x" ), &iListId ); |
|
178 |
|
179 MPresentityGroupInfo* groupInfo = objFact.NewPresentityGroupInfoLC(); |
|
180 |
|
181 IMPS_DP( D_IMPS_LIT( " groupInfo::%x" ), &groupInfo ); |
|
182 MXIMPIdentity* groupIdentity = objFact.NewIdentityLC(); |
|
183 IMPS_DP( D_IMPS_LIT( " groupIdentity::%x" ), &groupIdentity ); |
|
184 |
|
185 groupIdentity->SetIdentityL( *iListId ); |
|
186 groupInfo->SetGroupIdL( groupIdentity ); |
|
187 |
|
188 listOfLists->AddObjectL( groupInfo ); |
|
189 |
|
190 delete iListId; |
|
191 iListId = NULL; |
|
192 CleanupStack::Pop( 2 ); // groupInfo, groupIdentity |
|
193 } |
|
194 |
|
195 } |
|
196 |
|
197 iConnMan.HandleToHost().GroupsDataHost().HandlePresentityGroupListL( listOfLists ); |
|
198 CleanupStack::Pop(); //listOfLists |
|
199 |
|
200 IMPS_DP( D_IMPS_LIT( " iResponse::%x" ), &iResponse ); |
|
201 |
|
202 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, KErrNone ); |
|
203 |
|
204 delete this; |
|
205 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::RunL End" ) ); |
|
206 } |
|
207 |
|
208 |
|
209 // --------------------------------------------------------------------------- |
|
210 // CImpsPluginGroupSubscribePresentityGroupListRequest::RunError |
|
211 // --------------------------------------------------------------------------- |
|
212 // |
|
213 TInt CImpsPluginGroupSubscribePresentityGroupListRequest::RunError( TInt aError ) |
|
214 { |
|
215 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::RunError Start" ) ); |
|
216 |
|
217 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
218 |
|
219 delete this; |
|
220 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::RunError End" ) ); |
|
221 return KErrNone; |
|
222 } |
|
223 |
|
224 // --------------------------------------------------------------------------- |
|
225 // CImpsPluginGroupSubscribePresentityGroupListRequest::SubscribePresentityGroupListRequest |
|
226 // --------------------------------------------------------------------------- |
|
227 // |
|
228 void CImpsPluginGroupSubscribePresentityGroupListRequest::SubscribePresentityGroupListRequestL() |
|
229 { |
|
230 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::SubscribePresentityGroupListRequest Start" ) ); |
|
231 |
|
232 //iPtrbuffer.Set( iConnMan.DataHandler().TransferBufferL() ); |
|
233 TPtr8 ptrbuffer( iConnMan.DataHandler().TransferBufferL() ); |
|
234 MPEngXMLSerializer* serializer = CreateXmlSerializerLC( ptrbuffer ); |
|
235 |
|
236 |
|
237 IMPS_DP( D_IMPS_LIT( "SubscribePresentityGroupListRequest Manufacture XML " ) ); |
|
238 |
|
239 serializer->StartTagL( KTransactionContent ); |
|
240 serializer->AttributeL( KXmlXmlns, KTransactionContentNS_CSP12 ); |
|
241 serializer->StartTagL( KGetListOfList ).EndTagL( KGetListOfList ); |
|
242 serializer->EndTagL( KTransactionContent ); |
|
243 |
|
244 CleanupStack::PopAndDestroy(); //serializer |
|
245 |
|
246 |
|
247 iSendId = iConnMan.DataHandler().SendDataL( iStatus ); |
|
248 |
|
249 IMPS_DP( D_IMPS_LIT( " SendData Request id %d " ), iSendId ); |
|
250 // signal the scheduler |
|
251 SetActive(); |
|
252 |
|
253 IMPS_DP( D_IMPS_LIT( "CImpsPluginGroupSubscribePresentityGroupListRequest::SubscribePresentityGroupListRequest End" ) ); |
|
254 } |
|
255 |
|
256 // End of file |