|
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 "WapFullySpecCLPush.h" |
|
17 #include "WapMsgUtils.h" |
|
18 #include <wapmsgerr.h> |
|
19 |
|
20 CSWSWapFullySpecCLPushService* CSWSWapFullySpecCLPushService::NewL() |
|
21 /** |
|
22 Static new function |
|
23 @internalComponent |
|
24 @released |
|
25 @since v8.0 |
|
26 */ |
|
27 { |
|
28 CSWSWapFullySpecCLPushService* me = new(ELeave)CSWSWapFullySpecCLPushService(); |
|
29 CleanupStack::PushL(me); |
|
30 me->ConstructL(); |
|
31 CleanupStack::Pop(me); |
|
32 return me; |
|
33 } |
|
34 |
|
35 CSWSWapFullySpecCLPushService::~CSWSWapFullySpecCLPushService() |
|
36 /** |
|
37 Destructor |
|
38 @internalComponent |
|
39 @released |
|
40 @since v8.0 |
|
41 */ |
|
42 { |
|
43 delete iAgent; |
|
44 } |
|
45 |
|
46 CSWSWapFullySpecCLPushService::CSWSWapFullySpecCLPushService() |
|
47 /** |
|
48 Constructor |
|
49 @internalComponent |
|
50 @released |
|
51 @since v8.0 |
|
52 */ |
|
53 { |
|
54 } |
|
55 |
|
56 void CSWSWapFullySpecCLPushService::ConstructL() |
|
57 /** |
|
58 Second Phase Constructor |
|
59 @internalComponent |
|
60 @released |
|
61 @since v8.0 |
|
62 */ |
|
63 { |
|
64 // Parent class construction |
|
65 CWapFullySpecCLPushService::ConstructL(); |
|
66 iAgent=CWspMessageApiAgent::NewL(); |
|
67 } |
|
68 |
|
69 TInt CSWSWapFullySpecCLPushService::Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TBool aSecure, TInetAddr /*aInetAddr*/) |
|
70 /** |
|
71 Opens a socket which is to be used only with a single, named remote host. |
|
72 @internalComponent |
|
73 @released |
|
74 @since v8.0 |
|
75 @param aRemoteHost the bearer-dependent address of the remote host with which the data will be exchanged |
|
76 @param aRemotePort the port on the remote host to which data will be sent |
|
77 @param aBearer the bearer to use (not EAll) |
|
78 @param aSecure security flag indicates whether WTLS will be used or not |
|
79 @param aInetAddr the address of the adapter to use |
|
80 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
81 */ |
|
82 { |
|
83 if(aSecure) |
|
84 { |
|
85 return KErrNotSupported; |
|
86 } |
|
87 return iAgent->Connect(aRemoteHost, aRemotePort, aBearer, aSecure); |
|
88 } |
|
89 |
|
90 TInt CSWSWapFullySpecCLPushService::Connect(const TDesC8& aRemoteHost, Wap::TPort aRemotePort, Wap::TBearer aBearer, TBool aSecure) |
|
91 /** |
|
92 Opens a socket which is to be used only with a single, named remote host. |
|
93 @internalComponent |
|
94 @released |
|
95 @since v8.0 |
|
96 @param aRemoteHost (in) the bearer-dependent address of the remote host with which the data will be exchanged |
|
97 @param aRemotePort (in) the port on the remote host to which data will be sent |
|
98 @param aBearer (in) the bearer to use (not EAll) |
|
99 @param aSecure (in) security flag indicates whether WTLS will be used or not |
|
100 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
101 */ |
|
102 { |
|
103 TInetAddr inetAddr( KInetAddrAny, 0); |
|
104 return( Connect(aRemoteHost, aRemotePort, aBearer, aSecure, inetAddr) ); |
|
105 } |
|
106 |
|
107 TInt CSWSWapFullySpecCLPushService::AwaitPush(TDes8& aPushHeaders, TDes8& aPushBody, TPckgBuf<TUint8>& aPushIdPckg, TRequestStatus& aReqStatus) |
|
108 /** |
|
109 Request an asynchronous notification upon arrival of the next push messages on the listening connection. |
|
110 The request completes upon receipt of the message, filling the buffers with as much received data as possible. |
|
111 A return code will indicate whether further data remains. The call must be re-issued for subsequent messages |
|
112 or to receive remaining data from a previous push message. |
|
113 @internalComponent |
|
114 @released |
|
115 @since v8.0 |
|
116 @param aPushHeaders (out) (client-allocated) - when a push message arrives the header data is written here |
|
117 @param aPushBody (out) (client-allocated) - when a push message arrives the body data is written here |
|
118 @param aPushIdPckg (out) when a push message arrives an integer ID that uniquely specifies the message is written here |
|
119 @param aReqStatus (inout) used by the service provider to notify the client when a push has arrived |
|
120 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
121 */ |
|
122 { |
|
123 TInt err = iAgent->ReceiveWspMessage(aPushHeaders, aPushBody, aPushIdPckg, iWspStatus, aReqStatus, 0); |
|
124 if(err == Wap::EMoreData) |
|
125 { |
|
126 return KErrNone; |
|
127 } |
|
128 return err; |
|
129 } |
|
130 |
|
131 void CSWSWapFullySpecCLPushService::CancelAwaitPush() |
|
132 /** |
|
133 Cancel a previously-requested push message notification. If a push message arrives the client will not be notified. |
|
134 @internalComponent |
|
135 @released |
|
136 @since v8.0 |
|
137 */ |
|
138 { |
|
139 iAgent->CancelRequest(); |
|
140 } |
|
141 |
|
142 TInt CSWSWapFullySpecCLPushService::GetLocalPort(Wap::TPort& aPort) |
|
143 /** |
|
144 Get the local port of this endpoint.Useful if one was chosen automatically. |
|
145 @internalComponent |
|
146 @released |
|
147 @since v8.0 |
|
148 @param aPort (out) the port number |
|
149 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
150 */ |
|
151 { |
|
152 return iAgent->GetLocalPort(aPort); |
|
153 } |
|
154 |
|
155 TInt CSWSWapFullySpecCLPushService::GetLocalAddress(HBufC8*& aLocalHost) |
|
156 /** |
|
157 Get the local address of this endpoint. |
|
158 @internalComponent |
|
159 @released |
|
160 @since v8.0 |
|
161 @param aLocalHost (inout) the address of the local host. A reference to a HBufC8 pointer should |
|
162 be passed in. This pointer MUST be null! A HBufC8 will be allocated to hold the address, ownership |
|
163 of this buffer will be passed over to the client. |
|
164 @returns KErrNone on successful completion, or one of the system error codes on failure. |
|
165 */ |
|
166 { |
|
167 return iAgent->GetLocalAddress(aLocalHost); |
|
168 } |
|
169 |