|
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 #ifndef __MINPUTSTREAMOBSERVER_H__ |
|
17 #define __MINPUTSTREAMOBSERVER_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 |
|
21 class MHttpResponse; |
|
22 class MInputStreamObserver |
|
23 /** |
|
24 The MInputStream and MInputStreamObserver classes provide the API to receive |
|
25 data from a connected remote host. They encapsulate the inbound stream of a |
|
26 connected socket. |
|
27 |
|
28 The input socket observer must bind itself to the input stream before using |
|
29 any of the other MInputStream functions. The MInputStream::Bind() API is |
|
30 used to do this binding. The input stream does not do its first read until |
|
31 an observer has been bound to it. When done for the first time the input |
|
32 stream moves from the Idle state to the Read state. |
|
33 |
|
34 When the input stream is in the Read state, it requests a read from the |
|
35 socket. This moves the input stream into the ReceivedData state and it waits |
|
36 for the socket to notify it when it receives any data from the remote host. |
|
37 When the input stream receives the notification it notifies its observer via |
|
38 the MInputStreamObserver::ReceivedDataInd() API. The input stream moves into |
|
39 the PendingAck state. |
|
40 |
|
41 The buffer containing the received data remains valid until the observer |
|
42 notifies the input stream that it is no longer needed. The observer can do |
|
43 this using the MInputStream::ReceivedDataRes() API. The input stream returns |
|
44 to the Read state and issues another read request to the socket. |
|
45 |
|
46 The input stream can only be re-bound to another observer when it is in the |
|
47 PendingAck state. This does not change the state of the input stream. The |
|
48 new observer is responsible for notifying the input stream when the received |
|
49 data buffer is no longer needed. |
|
50 |
|
51 There are two ways to shutdown the stream - asynchronously (standard use) and |
|
52 synchronously. |
|
53 |
|
54 In normal use the asynchronous MInputSocket::ShutdownReq() API can be used. |
|
55 The input stream changes to the Closing state. The observer is notified that |
|
56 the stream has closed via the MInputStreamObserver::InputStreamCloseInd() |
|
57 API. The input stream is then in the Closed state. It is no longer valid to |
|
58 use the input stream and to do so will cause an access violation. |
|
59 |
|
60 With the asynchronous shutdown the corresponding output stream is also shutdown. |
|
61 Its observer is notified that the output stream has been closed. Similarly, |
|
62 if the corresponding output stream has been shutdown sychronously or |
|
63 asynchronously the input stream observer will be notified that the stream |
|
64 has been closed. |
|
65 |
|
66 The MInputSocket::Close() API closes the input stream synchronously. In |
|
67 this case the observer will not be notified. Once the the call completes |
|
68 the input stream is in the Closed state and is no longer valid. This |
|
69 synchronous close should be used when an asynchronous shutdown is not |
|
70 appropriate, e.g. when deleting the observer object in error conditions. |
|
71 |
|
72 Similar to the asynchronous shutdown the corresponding output stream is also |
|
73 shutdown and its observer notified. |
|
74 @see MInputStream |
|
75 */ |
|
76 { |
|
77 public: // methods |
|
78 |
|
79 /** |
|
80 Notifies the observer that data has been received from the connected host. |
|
81 The supplied buffer will remain valid until the input stream is notified |
|
82 that it is no longer needed. |
|
83 @param aBuffer A buffer containing the received data. |
|
84 @post The input stream is in the PendingAck state. |
|
85 */ |
|
86 virtual void ReceivedDataIndL(const TDesC8& aBuffer) =0; |
|
87 |
|
88 /** |
|
89 Notifies the input stream observer that secure upgrade on the connection |
|
90 has completed successfully. |
|
91 @internalComponent |
|
92 */ |
|
93 virtual void SecureServerCnf() =0; |
|
94 |
|
95 /** |
|
96 Notifies the input stream observer that the socket connection with the |
|
97 remote host has been closed. The input stream is no longer valid. |
|
98 @param aError The error code explaining why the socket connection has |
|
99 closed. A value of KErrNone indicates that either the |
|
100 input or output stream observer requested that the |
|
101 socket connection be closed. |
|
102 @post The input stream is in the Closed state and is no longer valid. |
|
103 */ |
|
104 virtual void InputStreamCloseInd(TInt aError) =0; |
|
105 |
|
106 virtual MHttpResponse* CurrentResponse() =0; |
|
107 |
|
108 virtual void OnReceiveTimeOut() =0; |
|
109 |
|
110 private: // methods |
|
111 |
|
112 /** |
|
113 Reserved function for future expansion. |
|
114 */ |
|
115 virtual void MInputStreamObserver_Reserved() =0; |
|
116 }; |
|
117 |
|
118 #endif // __MINPUTSTREAMOBSERVER_H__ |