44
|
1 |
// Copyright (c) 2003-2009 Nokia Corporation and/or its subsidiary(-ies).
|
|
2 |
// All rights reserved.
|
|
3 |
// This component and the accompanying materials are made available
|
|
4 |
// under the terms of "Eclipse Public License v1.0"
|
|
5 |
// which accompanies this distribution, and is available
|
|
6 |
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
|
|
7 |
//
|
|
8 |
// Initial Contributors:
|
|
9 |
// Nokia Corporation - initial contribution.
|
|
10 |
//
|
|
11 |
// Contributors:
|
|
12 |
//
|
|
13 |
// Description:
|
|
14 |
//
|
|
15 |
|
|
16 |
#include "WapBoundCLPush.h"
|
|
17 |
#include "WapMsgUtils.h"
|
|
18 |
#include <wapmsgerr.h>
|
|
19 |
|
|
20 |
CSWSWapBoundCLPushService* CSWSWapBoundCLPushService::NewL()
|
|
21 |
/**
|
|
22 |
Static new function
|
|
23 |
@internalComponent
|
|
24 |
@released
|
|
25 |
@since v8.0
|
|
26 |
*/
|
|
27 |
{
|
|
28 |
CSWSWapBoundCLPushService* me = new(ELeave)CSWSWapBoundCLPushService();
|
|
29 |
CleanupStack::PushL(me);
|
|
30 |
me->ConstructL();
|
|
31 |
CleanupStack::Pop(me);
|
|
32 |
return me;
|
|
33 |
}
|
|
34 |
|
|
35 |
CSWSWapBoundCLPushService::~CSWSWapBoundCLPushService()
|
|
36 |
/**
|
|
37 |
Destructor
|
|
38 |
@internalComponent
|
|
39 |
@released
|
|
40 |
@since v8.0
|
|
41 |
*/
|
|
42 |
{
|
|
43 |
delete iAgent;
|
|
44 |
}
|
|
45 |
|
|
46 |
CSWSWapBoundCLPushService::CSWSWapBoundCLPushService()
|
|
47 |
/**
|
|
48 |
Constructor
|
|
49 |
@internalComponent
|
|
50 |
@released
|
|
51 |
@since v8.0
|
|
52 |
*/
|
|
53 |
{
|
|
54 |
}
|
|
55 |
|
|
56 |
void CSWSWapBoundCLPushService::ConstructL()
|
|
57 |
/**
|
|
58 |
Second Phase Constructor
|
|
59 |
@internalComponent
|
|
60 |
@released
|
|
61 |
@since v8.0
|
|
62 |
*/
|
|
63 |
{
|
|
64 |
// Parent class construction
|
|
65 |
CWapBoundCLPushService::ConstructL();
|
|
66 |
iAgent=CWspMessageApiAgent::NewL();
|
|
67 |
}
|
|
68 |
|
|
69 |
TInt CSWSWapBoundCLPushService::Connect(Wap::TBearer aBearer, Wap::TPort aPort, TBool aSecure, TInetAddr /*aInetAddr*/)
|
|
70 |
/**
|
|
71 |
Opens a Wsp EndPoint which is to be used to listen for subsequent incoming Push messages from any sender;
|
|
72 |
@internalComponent
|
|
73 |
@released
|
|
74 |
@since v8.0
|
|
75 |
@param aBearer (in) the bearer to listen on (use EAll for all bearers)
|
|
76 |
@param aPort (in) the port to listen on. If set to 0, a local port will be chosen for the client's first SendTo
|
|
77 |
@param aSecure (in) security flag indicates whether WTLS will be used or not
|
|
78 |
@param aInetAddr (in) the address of the adapter to use
|
|
79 |
@returns TInt KErrNone on successful completion, or one of the system error codes on failure.
|
|
80 |
*/
|
|
81 |
{
|
|
82 |
if(aSecure)
|
|
83 |
{
|
|
84 |
return KErrNotSupported;
|
|
85 |
}
|
|
86 |
return iAgent->Connect(aBearer, aPort, aSecure);
|
|
87 |
}
|
|
88 |
|
|
89 |
TInt CSWSWapBoundCLPushService::Connect(Wap::TBearer aBearer, Wap::TPort aPort, TBool aSecure)
|
|
90 |
/**
|
|
91 |
Opens a socket which is to be used to listen for subsequent incoming Push messages from any sender;
|
|
92 |
@internalComponent
|
|
93 |
@released
|
|
94 |
@since v8.0
|
|
95 |
@param aBearer (in) the bearer to listen on (use EAll for all bearers)
|
|
96 |
@param aPort (in) the port to listen on. If set to 0, a local port will be chosen for the client's first SendTo
|
|
97 |
@param aSecure (in) security flag indicates whether WTLS will be used or not
|
|
98 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
99 |
*/
|
|
100 |
{
|
|
101 |
TInetAddr inetAddr( KInetAddrAny, 0);
|
|
102 |
return( Connect(aBearer, aPort, aSecure, inetAddr) );
|
|
103 |
}
|
|
104 |
|
|
105 |
TInt CSWSWapBoundCLPushService::AwaitPush(TDes8& aPushHeaders, TDes8& aPushBody, TPckgBuf<TUint8>& aPushIdPckg, TRequestStatus& aReqStatus)
|
|
106 |
/**
|
|
107 |
Request an asynchronous notification upon arrival of the next push messages on the listening connection.
|
|
108 |
The request completes upon receipt of the message, filling the buffers with as much received data as possible.
|
|
109 |
A return code will indicate whether further data remains. The call must be re-issued for subsequent messages
|
|
110 |
or to receive remaining data from a previous push message.
|
|
111 |
@internalComponent
|
|
112 |
@released
|
|
113 |
@since v8.0
|
|
114 |
@param aPushHeaders (out) (client-allocated) - when a push message arrives the header data is written here
|
|
115 |
@param aPushBody (out) (client-allocated) - when a push message arrives the body data is written here
|
|
116 |
@param aPushIdPckg (out) when a push message arrives an integer ID that uniquely specifies the message is written here
|
|
117 |
@param aReqStatus (inout) used by the service provider to notify the client when a push has arrived.
|
|
118 |
EMoreData is returned if more pushed data is available
|
|
119 |
@retval KErrNone on successful completion, or one of the system error codes on failure.
|
|
120 |
*/
|
|
121 |
{
|
|
122 |
TInt err = iAgent->ReceiveWspMessage(aPushHeaders, aPushBody, aPushIdPckg, iWspStatus, aReqStatus, 0);
|
|
123 |
if(err == Wap::EMoreData)
|
|
124 |
{
|
|
125 |
return KErrNone;
|
|
126 |
}
|
|
127 |
return err;
|
|
128 |
}
|
|
129 |
|
|
130 |
void CSWSWapBoundCLPushService::CancelAwaitPush()
|
|
131 |
/**
|
|
132 |
Cancel a previously-requested push message notification. If a push message arrives the client will not be notified.
|
|
133 |
@internalComponent
|
|
134 |
@released
|
|
135 |
@since v8.0
|
|
136 |
*/
|
|
137 |
{
|
|
138 |
iAgent->CancelRequest();
|
|
139 |
}
|
|
140 |
|
|
141 |
TInt CSWSWapBoundCLPushService::GetLocalPort(Wap::TPort& aPort)
|
|
142 |
/**
|
|
143 |
Get the local address of this endpoint.
|
|
144 |
@internalComponent
|
|
145 |
@released
|
|
146 |
@since v8.0
|
|
147 |
@param aPort (out) the port of the local host
|
|
148 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
149 |
*/
|
|
150 |
{
|
|
151 |
return iAgent->GetLocalPort(aPort);
|
|
152 |
}
|
|
153 |
|
|
154 |
TInt CSWSWapBoundCLPushService::GetLocalAddress(HBufC8*& aLocalHost)
|
|
155 |
/**
|
|
156 |
Get the local address of this endpoint.
|
|
157 |
@internalComponent
|
|
158 |
@released
|
|
159 |
@since v8.0
|
|
160 |
@param aLocalHost (inout) the address of the local host. A reference to a HBufC8 pointer should
|
|
161 |
be passed in. This pointer MUST be null! A HBufC8 will be allocated to hold the address, ownership
|
|
162 |
of this buffer will be passed over to the client.
|
|
163 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
164 |
*/
|
|
165 |
{
|
|
166 |
return iAgent->GetLocalAddress(aLocalHost);
|
|
167 |
}
|
|
168 |
|
|
169 |
TInt CSWSWapBoundCLPushService::GetBearer(Wap::TBearer& aBearer)
|
|
170 |
/**
|
|
171 |
Get the bearer on which the push message arrived.
|
|
172 |
Useful when EAll was specified in Connect()
|
|
173 |
@internalComponent
|
|
174 |
@released
|
|
175 |
@since v8.0
|
|
176 |
@param aBearer (out) the bearer
|
|
177 |
@returns KErrNone on successful completion, or one of the system error codes on failure.
|
|
178 |
*/
|
|
179 |
{
|
|
180 |
return iAgent->GetBearer(aBearer);
|
|
181 |
}
|
|
182 |
|
|
183 |
TInt CSWSWapBoundCLPushService::GetServerAddress(HBufC8*& aRemoteHost)
|
|
184 |
/**
|
|
185 |
Get the address of the remote server
|
|
186 |
@internalComponent
|
|
187 |
@released
|
|
188 |
@since v8.0
|
|
189 |
Cannot be called when there is an outstanding AwaitPush().
|
|
190 |
@param aRemoteHost the address of the remote server.
|
|
191 |
A reference to a HBufC8 pointer should be passed in. An HBufC8 will be allocated
|
|
192 |
to hold the address ,ownership of this buffer will be passed over to the client.
|
|
193 |
@returns KErrNone on successful completion, KErrNotSupported if not implemented or one of the system error codes on failure.
|
|
194 |
*/
|
|
195 |
{
|
|
196 |
return iAgent->GetServerAddress(aRemoteHost);
|
|
197 |
}
|
|
198 |
|