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: Request for Rejecting add invite to the Network Server. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <ximpprotocolconnectionhost.h> |
|
20 #include "cwithdrawpresencegrantfrompresentityrequest.h" |
|
21 #include "mossprotocolconnectionmanager.h" |
|
22 #include "ossprotocolpluginlogger.h" |
|
23 #include <presenceinfo.h> |
|
24 |
|
25 #include <ximpobjectfactory.h> |
|
26 #include <ximpobjectcollection.h> |
|
27 #include <protocolpresentitygroupsdatahost.h> |
|
28 #include <presentitygroupinfo.h> |
|
29 #include <presentitygroupmemberinfo.h> |
|
30 #include <ximpidentity.h> |
|
31 #include <presenceinfofilter.h> |
|
32 |
|
33 #include <glib/gstrfuncs.h> |
|
34 #include <gtypes.h> |
|
35 #include <stdlib.h> |
|
36 #include "stringutils.h" |
|
37 #include <string.h> |
|
38 #include <sys/types.h> |
|
39 #include <stdio.h> |
|
40 #include <glib/gprintf.h> |
|
41 #include "msgliterals.h" |
|
42 #include "msg_enums.h" |
|
43 #include "waittimer.h" |
|
44 #include <ximperrors.hrh> |
|
45 #include "ossprotocoladaptutils.h" |
|
46 |
|
47 // ======== MEMBER FUNCTIONS ======== |
|
48 |
|
49 // --------------------------------------------------------------------------- |
|
50 // CWithdrawPresenceGrantFromPresentityRequest::CWithdrawPresenceGrantFromPresentityRequest |
|
51 // --------------------------------------------------------------------------- |
|
52 // |
|
53 CWithdrawPresenceGrantFromPresentityRequest::CWithdrawPresenceGrantFromPresentityRequest( |
|
54 MOSSProtocolConnectionManager& aConnMan, |
|
55 TXIMPRequestId aRequestId ) : |
|
56 CActive( EPriorityNormal ), |
|
57 iRequestId( aRequestId ), |
|
58 iConnMan( aConnMan ) |
|
59 { |
|
60 LOGGER ( TXT("::CWithdrawPresenceGrantFromPresentityRequest Start") ); |
|
61 CActiveScheduler::Add( this ); |
|
62 LOGGER ( TXT("::CWithdrawPresenceGrantFromPresentityRequest End") ); |
|
63 } |
|
64 |
|
65 |
|
66 // --------------------------------------------------------------------------- |
|
67 // CWithdrawPresenceGrantFromPresentityRequest::ConstructL |
|
68 // --------------------------------------------------------------------------- |
|
69 // |
|
70 void CWithdrawPresenceGrantFromPresentityRequest::ConstructL() |
|
71 { |
|
72 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::ConstructL Start-End") ); |
|
73 |
|
74 } |
|
75 |
|
76 |
|
77 // --------------------------------------------------------------------------- |
|
78 // CWithdrawPresenceGrantFromPresentityRequest::NewL |
|
79 // --------------------------------------------------------------------------- |
|
80 // |
|
81 CWithdrawPresenceGrantFromPresentityRequest* CWithdrawPresenceGrantFromPresentityRequest::NewL( |
|
82 MOSSProtocolConnectionManager& aConnMan, |
|
83 TXIMPRequestId aRequestId ) |
|
84 { |
|
85 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::NewL Start") ); |
|
86 |
|
87 CWithdrawPresenceGrantFromPresentityRequest* self = |
|
88 new( ELeave ) CWithdrawPresenceGrantFromPresentityRequest( aConnMan, aRequestId ); |
|
89 CleanupStack::PushL( self ); |
|
90 self->ConstructL(); |
|
91 CleanupStack::Pop( self ); |
|
92 |
|
93 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::NewL End") ); |
|
94 return self; |
|
95 } |
|
96 |
|
97 |
|
98 // --------------------------------------------------------------------------- |
|
99 // CWithdrawPresenceGrantFromPresentityRequest::NewLC |
|
100 // --------------------------------------------------------------------------- |
|
101 // |
|
102 CWithdrawPresenceGrantFromPresentityRequest* CWithdrawPresenceGrantFromPresentityRequest::NewLC( |
|
103 MOSSProtocolConnectionManager& aConnMan, |
|
104 TXIMPRequestId aRequestId ) |
|
105 { |
|
106 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::NewLC Start") ); |
|
107 |
|
108 CWithdrawPresenceGrantFromPresentityRequest* self = |
|
109 CWithdrawPresenceGrantFromPresentityRequest::NewL( aConnMan, aRequestId ); |
|
110 CleanupStack::PushL( self ); |
|
111 |
|
112 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::NewLC End") ); |
|
113 return self; |
|
114 } |
|
115 |
|
116 // --------------------------------------------------------------------------- |
|
117 // CWithdrawPresenceGrantFromPresentityRequest::~CWithdrawPresenceGrantFromPresentityRequest |
|
118 // --------------------------------------------------------------------------- |
|
119 // |
|
120 CWithdrawPresenceGrantFromPresentityRequest::~CWithdrawPresenceGrantFromPresentityRequest() |
|
121 { |
|
122 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::~CWithdrawPresenceGrantFromPresentityRequest Start") ); |
|
123 CActive::Cancel(); |
|
124 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::~CWithdrawPresenceGrantFromPresentityRequest End") ); |
|
125 } |
|
126 |
|
127 |
|
128 // --------------------------------------------------------------------------- |
|
129 // CWithdrawPresenceGrantFromPresentityRequest::DoCancel() |
|
130 // --------------------------------------------------------------------------- |
|
131 // |
|
132 void CWithdrawPresenceGrantFromPresentityRequest::DoCancel() |
|
133 { |
|
134 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::DoCancel Start") ); |
|
135 |
|
136 // iConnMan.DataHandler().CancelSending( iSendId ); |
|
137 |
|
138 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::DoCancel End") ); |
|
139 } |
|
140 |
|
141 |
|
142 // --------------------------------------------------------------------------- |
|
143 // CWithdrawPresenceGrantFromPresentityRequest::RunL() |
|
144 // --------------------------------------------------------------------------- |
|
145 // |
|
146 void CWithdrawPresenceGrantFromPresentityRequest::RunL() |
|
147 { |
|
148 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::RunL Start") ); |
|
149 |
|
150 message_hdr_resp* msg_struct = NULL; |
|
151 char* pResponse = NULL; |
|
152 TInt error_code(KErrNone); |
|
153 User::LeaveIfError( iStatus.Int() ); |
|
154 |
|
155 pResponse = iConnMan.DataHandler().ResponseL( iSendId ); |
|
156 |
|
157 msg_struct = ( message_hdr_resp* )pResponse ; |
|
158 error_code = msg_struct->error_type; |
|
159 if( !( msg_struct->response ) ) |
|
160 { |
|
161 iConnMan.HandleToHost().HandleRequestCompleted ( iRequestId, error_code ); |
|
162 } |
|
163 else |
|
164 { |
|
165 iConnMan.HandleToHost().HandleRequestCompleted ( iRequestId, KErrNone ); |
|
166 } |
|
167 |
|
168 free( pResponse ); |
|
169 delete this; |
|
170 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::RunL End") ); |
|
171 } |
|
172 |
|
173 |
|
174 // --------------------------------------------------------------------------- |
|
175 // CWithdrawPresenceGrantFromPresentityRequest::RunError |
|
176 // --------------------------------------------------------------------------- |
|
177 // |
|
178 TInt CWithdrawPresenceGrantFromPresentityRequest::RunError( TInt aError ) |
|
179 { |
|
180 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::RunError Start") ); |
|
181 |
|
182 iConnMan.HandleToHost().HandleRequestCompleted( iRequestId, aError ); |
|
183 |
|
184 delete this; |
|
185 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::RunError End") ); |
|
186 return KErrNone; |
|
187 } |
|
188 |
|
189 // --------------------------------------------------------------------------- |
|
190 // CWithdrawPresenceGrantFromPresentityRequest::WithdrawPresenceGrantFromPresentityL |
|
191 // --------------------------------------------------------------------------- |
|
192 // |
|
193 void CWithdrawPresenceGrantFromPresentityRequest::WithdrawPresenceGrantFromPresentityL( |
|
194 const MXIMPIdentity& aIdentity) |
|
195 { |
|
196 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::WithdrawPresenceGrantFromPresentity Start") ); |
|
197 char *smsg = NULL; |
|
198 char *tmpmsg = NULL; |
|
199 int userLen = 0; |
|
200 int totalLen = 0; |
|
201 |
|
202 message_hdr_req msgHdr = {0,}; |
|
203 msgHdr.message_type = EReject_Contact_Request ; |
|
204 |
|
205 TInt headerLength = sizeof( message_hdr_req ); |
|
206 totalLen += headerLength; |
|
207 // adding add contact |
|
208 charFormatData tmpmsgData = OssProtocolAdapUtils::ConvertTUint16ToCharLC( aIdentity.Identity() ); |
|
209 tmpmsg = tmpmsgData.data; |
|
210 userLen = tmpmsgData.dataSize; |
|
211 totalLen += userLen; |
|
212 |
|
213 if ( totalLen > MAX_MSG_SIZE ) |
|
214 { |
|
215 User::Leave(KErrArgument); |
|
216 } |
|
217 |
|
218 smsg = ( char* ) User::AllocLC(totalLen); |
|
219 memcpy( smsg, &msgHdr, headerLength ); |
|
220 memcpy ( smsg + headerLength, tmpmsg, userLen ); |
|
221 |
|
222 iSendId = iConnMan.DataHandler().SendDataL ( iStatus, smsg, totalLen ); |
|
223 |
|
224 // signal the scheduler |
|
225 SetActive(); |
|
226 |
|
227 CleanupStack::PopAndDestroy ( 2 );//smsg, tmpmsg. |
|
228 |
|
229 LOGGER ( TXT("CWithdrawPresenceGrantFromPresentityRequest::WithdrawPresenceGrantFromPresentity End") ); |
|
230 } |
|
231 |
|
232 |
|
233 |
|
234 // End of file |
|