1 /* |
|
2 * Copyright (c) 2007-2008 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: Add notification handler |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnectionhost.h> |
|
20 #include "caddcontactenotificationhandler.h" |
|
21 |
|
22 #include "mossprotocolconnectionmanager.h" |
|
23 #include "ossprotocolpluginlogger.h" |
|
24 #include "waittimer.h" |
|
25 #include "cossprotocolconnectionmanager.h" |
|
26 |
|
27 #include <ximpobjectfactory.h> |
|
28 #include <ximpobjectcollection.h> |
|
29 #include <protocolpresentitygroupsdatahost.h> |
|
30 #include <presentitygroupinfo.h> |
|
31 #include <presentitygroupmemberinfo.h> |
|
32 #include <ximpidentity.h> |
|
33 #include <protocolpresencepublishingdatahost.h> |
|
34 #include <protocolpresencedatahost.h> |
|
35 #include <presenceobjectfactory.h> |
|
36 #include <presencegrantrequestinfo.h> |
|
37 |
|
38 |
|
39 #include <personpresenceinfo.h> |
|
40 #include <servicepresenceinfo.h> |
|
41 #include <devicepresenceinfo.h> |
|
42 #include <presenceinfo.h> |
|
43 |
|
44 #include <presenceinfofield.h> |
|
45 #include <presenceinfofieldcollection.h> |
|
46 #include <presenceinfofieldvalueenum.h> |
|
47 #include <presenceinfofieldvaluetext.h> |
|
48 #include <ximpcontext.h> |
|
49 #include <ximpclient.h> |
|
50 #include <devicepresenceinfo.h> |
|
51 #include <protocolpresencewatchingdatahost.h> |
|
52 #include <presencegrantrequestinfo.h> |
|
53 #include <protocolpresenceauthorizationdatahost.h> |
|
54 #include <e32des16.h> |
|
55 #include <string.h> |
|
56 #include <sys/types.h> |
|
57 #include <stdio.h> |
|
58 #include <stdlib.h> |
|
59 #include "msgliterals.h" |
|
60 |
|
61 #include "ossprotocoladaptationuids.h" |
|
62 #include "ossprotocoladaptutils.h" |
|
63 |
|
64 // ======== MEMBER FUNCTIONS ======== |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CAddContactNotificationHandler::CAddContactNotificationHandler |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 CAddContactNotificationHandler::CAddContactNotificationHandler ( |
|
71 MOSSProtocolConnectionManager& aConnMan ) : |
|
72 CActive ( EPriorityNormal ), |
|
73 iConnMan ( aConnMan ) |
|
74 { |
|
75 LOGGER ( TXT ( "CAddContactNotificationHandler::CAddContactNotificationHandler Start" ) ); |
|
76 CActiveScheduler::Add ( this ); |
|
77 |
|
78 LOGGER ( TXT ( "CAddContactNotificationHandler::CAddContactNotificationHandler End" ) ); |
|
79 } |
|
80 |
|
81 |
|
82 // --------------------------------------------------------------------------- |
|
83 // CAddContactNotificationHandler::ConstructL |
|
84 // --------------------------------------------------------------------------- |
|
85 // |
|
86 void CAddContactNotificationHandler::ConstructL() |
|
87 { |
|
88 LOGGER ( TXT ( "CAddContactNotificationHandler::ConstructL Start-End" ) ); |
|
89 |
|
90 } |
|
91 |
|
92 |
|
93 // --------------------------------------------------------------------------- |
|
94 // CAddContactNotificationHandler::NewL |
|
95 // --------------------------------------------------------------------------- |
|
96 // |
|
97 CAddContactNotificationHandler* CAddContactNotificationHandler::NewL ( |
|
98 MOSSProtocolConnectionManager& aConnMan ) |
|
99 { |
|
100 LOGGER ( TXT ( "CAddContactNotificationHandler::NewL Start" ) ); |
|
101 |
|
102 CAddContactNotificationHandler* self = new ( ELeave ) CAddContactNotificationHandler ( aConnMan ); |
|
103 CleanupStack::PushL ( self ); |
|
104 self->ConstructL(); |
|
105 CleanupStack::Pop ( self ); |
|
106 |
|
107 LOGGER ( TXT ( "CAddContactNotificationHandler::NewL End" ) ); |
|
108 return self; |
|
109 } |
|
110 |
|
111 |
|
112 // --------------------------------------------------------------------------- |
|
113 // CAddContactNotificationHandler::NewLC |
|
114 // --------------------------------------------------------------------------- |
|
115 // |
|
116 CAddContactNotificationHandler* CAddContactNotificationHandler::NewLC ( |
|
117 MOSSProtocolConnectionManager& aConnMan ) |
|
118 { |
|
119 LOGGER ( TXT ( "CAddContactNotificationHandler::NewLC Start" ) ); |
|
120 |
|
121 CAddContactNotificationHandler* self = CAddContactNotificationHandler::NewL ( aConnMan ); |
|
122 CleanupStack::PushL ( self ); |
|
123 |
|
124 LOGGER ( TXT ( "CAddContactNotificationHandler::NewLC End" ) ); |
|
125 return self; |
|
126 } |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CAddContactNotificationHandler::~CAddContactNotificationHandler |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 CAddContactNotificationHandler::~CAddContactNotificationHandler() |
|
133 { |
|
134 LOGGER ( TXT ( "::~CAddContactNotificationHandler Start" ) ); |
|
135 |
|
136 Cancel(); |
|
137 |
|
138 LOGGER ( TXT ( "::~CAddContactNotificationHandler End" ) ); |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CAddContactNotificationHandler::DoCancel() |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CAddContactNotificationHandler::DoCancel() |
|
147 { |
|
148 LOGGER ( TXT ( "CAddContactNotificationHandler::DoCancel Start" ) ); |
|
149 |
|
150 iConnMan.DataHandler().CancelListeningAddNotication(); |
|
151 |
|
152 LOGGER ( TXT ( "CAddContactNotificationHandler::DoCancel End" ) ); |
|
153 } |
|
154 |
|
155 // --------------------------------------------------------------------------- |
|
156 // CAddContactNotificationHandler::RunL() |
|
157 // --------------------------------------------------------------------------- |
|
158 // |
|
159 void CAddContactNotificationHandler::RunL() |
|
160 { |
|
161 LOGGER ( TXT ( "CAddContactNotificationHandler::RunL Start" ) ); |
|
162 |
|
163 // something is coming from the xmpp server |
|
164 User::LeaveIfError ( iStatus.Int() ); |
|
165 |
|
166 ProcessIncomingDataL(); |
|
167 StartListeningL(); |
|
168 |
|
169 LOGGER ( TXT ( "CAddContactNotificationHandler::RunL End" ) ); |
|
170 } |
|
171 |
|
172 // --------------------------------------------------------------------------- |
|
173 // CAddContactNotificationHandler::ProcessIncomingDataL() |
|
174 // --------------------------------------------------------------------------- |
|
175 /* This Function is used to convert the received |
|
176 * presence notification from Isolation Server Message queue |
|
177 * into the ximpfw data types. and storing the presence information |
|
178 * in to the presence cache ( available in ximpfw ) |
|
179 * client has to read the presence information from the |
|
180 * presence cache. when the change in status notification is received |
|
181 * while updating presence cache, client will receive the notification if subscribed. |
|
182 */ |
|
183 void CAddContactNotificationHandler::ProcessIncomingDataL() |
|
184 { |
|
185 LOGGER ( TXT ( "CAddContactNotificationHandler::ProcessIncomingDataL Start" ) ); |
|
186 char* pResponse = NULL, *pOrigResponse = NULL; |
|
187 TInt len = 0; |
|
188 pOrigResponse = pResponse = iConnMan.DataHandler().ResponseL ( 4 ); |
|
189 CleanupStack::PushL(pOrigResponse) ; |
|
190 RPointerArray<HBufC>& invitations = iConnMan.GetContactManager().GetInvitationListL(); |
|
191 if( pResponse ) |
|
192 { |
|
193 pResponse += sizeof ( message_hdr_resp ); |
|
194 while(1) |
|
195 { |
|
196 len = strlen(pResponse) + 1; |
|
197 if (1 == len) |
|
198 { |
|
199 break; |
|
200 } |
|
201 HBufC16* AuthreqId = OssProtocolAdapUtils::ConvertCharToTUint16LC( pResponse ); |
|
202 pResponse += len; |
|
203 TInt len1 = AuthreqId->Length(); |
|
204 MXIMPObjectFactory& ObjFact = iConnMan.HandleToHost().ObjectFactory(); |
|
205 MPresenceObjectFactory& prfwObjFact = iConnMan.HandleToHost().ProtocolPresenceDataHost().PresenceObjectFactory(); |
|
206 |
|
207 invitations.AppendL( AuthreqId ); |
|
208 MPresenceGrantRequestInfo* presenceGrant; |
|
209 presenceGrant = prfwObjFact.NewPresenceGrantRequestInfoLC();//1 |
|
210 MXIMPIdentity* AuthReqIdentity; |
|
211 AuthReqIdentity = ObjFact.NewIdentityLC();//2 |
|
212 AuthReqIdentity->SetIdentityL(*AuthreqId); |
|
213 AuthreqId->Des().Fold(); |
|
214 presenceGrant->SetRequestorIdL(AuthReqIdentity); |
|
215 iConnMan.HandleToHost().ProtocolPresenceDataHost().AuthorizationDataHost().HandlePresenceGrantRequestReceivedL (presenceGrant); |
|
216 TInt count = iConnMan.PresenceAuthGrantReqList()->Count(); |
|
217 iConnMan.PresenceAuthGrantReqList()->Append(*AuthreqId); |
|
218 count = iConnMan.PresenceAuthGrantReqList()->Count(); |
|
219 CleanupStack::Pop(2); //AuthReqIdentity,presenceGrant |
|
220 CleanupStack::Pop ( 1 );//AuthreqId |
|
221 } |
|
222 } |
|
223 CleanupStack::PopAndDestroy ( 1 );//pOrigResponse |
|
224 LOGGER ( TXT ( "CAddContactNotificationHandler::ProcessIncomingDataL End" ) ); |
|
225 } |
|
226 |
|
227 |
|
228 // --------------------------------------------------------------------------- |
|
229 // CAddContactNotificationHandler::RunError |
|
230 // --------------------------------------------------------------------------- |
|
231 // |
|
232 TInt CAddContactNotificationHandler::RunError ( TInt aError ) |
|
233 { |
|
234 LOGGER ( TXT ( "CAddContactNotificationHandler::RunError Start %d" ), aError ); |
|
235 |
|
236 LOGGER ( TXT ( "CAddContactNotificationHandler::RunError End" ) ); |
|
237 return KErrNone; |
|
238 } |
|
239 |
|
240 // --------------------------------------------------------------------------- |
|
241 // CAddContactNotificationHandler::StartListeningL |
|
242 // --------------------------------------------------------------------------- |
|
243 // |
|
244 void CAddContactNotificationHandler::StartListeningL() |
|
245 { |
|
246 LOGGER ( TXT ( "CAddContactNotificationHandler::StartListeningL Start" ) ); |
|
247 |
|
248 if ( ! ( this->IsActive() ) ) |
|
249 { |
|
250 iConnMan.DataHandler().ListenAddNotification ( iStatus ); |
|
251 SetActive(); |
|
252 } |
|
253 LOGGER ( TXT ( "CAddContactNotificationHandler::StartListeningL End" ) ); |
|
254 } |
|
255 |
|
256 // End of file |
|