|
1 // Copyright (c) 2006-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 __MOUTPUTSTREAM_H__ |
|
17 #define __MOUTPUTSTREAM_H__ |
|
18 |
|
19 #include <e32std.h> |
|
20 |
|
21 // Forward declarations |
|
22 class MOutputStreamObserver; |
|
23 class MOutputStreamSecureObserver; |
|
24 class TCertInfo; |
|
25 |
|
26 /** |
|
27 The MOutputStream and MOutputStreamObserver classes provide the API to send |
|
28 data to a connected remote host. They encapsulate the outbound stream of a |
|
29 connected socket. |
|
30 |
|
31 The output socket observer must bind itself to the output stream before using |
|
32 any of the other MOutputStream functions. The MOutputStream::Bind() API is |
|
33 used to do this binding. When done for the first time the output stream moves |
|
34 from the Idle state to the PendingSend state. |
|
35 |
|
36 Once an observer has been bound to the output stream data can be sent to the |
|
37 connected host using the MOutputStream::SendDataReq() API. This can only be |
|
38 done when the output stream is in the PendingSend state otherwise a panic |
|
39 occurs. The MOutputStream::SendDataReq() API changes the output stream state |
|
40 to the SentData state. |
|
41 |
|
42 The supplied data buffer must remain valid until the observer is notified |
|
43 that the send has been successful. This is done using the |
|
44 MOutputStreamObserver::SendDataCnf() API. The output stream moves back to |
|
45 the PendingSend state. |
|
46 |
|
47 The output stream can only be re-bound to another observer when in the |
|
48 PendingSend state. The re-binding does not change the state of the output |
|
49 stream. |
|
50 |
|
51 The MOutputSocket::Close() API closes the output stream synchronously. In |
|
52 this case the output stream observer will not be notified. Once the the call |
|
53 completes the output stream is in the Closed state and is no longer valid. |
|
54 This synchronous close should be used when an asynchronous shutdown is not |
|
55 appropriate, e.g. when deleting the observer object in error conditions. |
|
56 |
|
57 Similar to the asynchronous shutdown the corresponding input stream is also |
|
58 shutdown and its observer notified. |
|
59 |
|
60 @see MOutputStreamObserver |
|
61 @internalTechnology |
|
62 @prototype |
|
63 */ |
|
64 class MOutputStream |
|
65 { |
|
66 public: |
|
67 /** |
|
68 This binds an observer to the output stream. |
|
69 @param aObserver An output stream observer. |
|
70 @param aLogId Log file identifier |
|
71 @pre The output stream is either in the Idle or PendingSend state. |
|
72 @post The output stream is in the PendingSend state. |
|
73 @panic EBadOutputStreamState The output stream is not in the Idle or |
|
74 PendingSend state. |
|
75 */ |
|
76 virtual void Bind(MOutputStreamObserver& aObserver, TInt aLogId) =0; |
|
77 |
|
78 /** |
|
79 This binds a secure socket notification observer to the output stream. |
|
80 @param aObserver An output stream secure observer. |
|
81 @pre The output stream is either in the Idle or PendingSend state. |
|
82 @panic EBadOutputStreamState The output stream is not in the Idle or |
|
83 PendingSend state. |
|
84 */ |
|
85 virtual void BindSecure(MOutputStreamSecureObserver& aObserver) =0; |
|
86 |
|
87 /** |
|
88 Requests that the output stream send the supplied data to the connected host. |
|
89 The observer will be notified when the data has been successfully sent. The |
|
90 data buffer must remain valid until this notification. |
|
91 @param aBuffer The buffer to send on the socket. |
|
92 @post The output stream is in the SentData state. |
|
93 @panic EOutputStreamNotBound The output stream has no observer bound |
|
94 to it. |
|
95 @panic EBadOutputStreamState The output stream is not in the |
|
96 PendingSend state. |
|
97 */ |
|
98 virtual void SendDataReq(const TDesC8& aBuffer, TInt aIdleTime = 0) =0; |
|
99 /** |
|
100 Upgrade to a secure (client) connection |
|
101 @param aSSLDomainName The SSL domain name to use for certificate validation. |
|
102 */ |
|
103 virtual void SecureClientReq(const TDesC8& aSSLDomainName) = 0; |
|
104 /** |
|
105 Closes the output stream synchronously. The observer is not notified. The |
|
106 corresponding input stream is also closed and its observer notified. |
|
107 @pre The output stream is not in the Closing or Closed state and an |
|
108 observer has been bound to it. |
|
109 @post The output stream is in the Closed state and no longer valid. |
|
110 @panic EOutputStreamNotBound The output stream has no observer bound |
|
111 to it. |
|
112 @panic EBadOutputStreamState The output stream is in the Closing or |
|
113 Closed state. |
|
114 */ |
|
115 virtual void Close() =0; |
|
116 }; |
|
117 |
|
118 #endif // __MOUTPUTSTREAM_H__ |