2 // Open Service Platform
3 // Copyright (c) 2012-2013 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.0 (the License);
6 // you may not use this file except in compliance with the License.
7 // You may obtain a copy of the License at
9 // http://www.apache.org/licenses/LICENSE-2.0
11 // Unless required by applicable law or agreed to in writing, software
12 // distributed under the License is distributed on an "AS IS" BASIS,
13 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 // See the License for the specific language governing permissions and
15 // limitations under the License.
19 * @file FNetHttpIHttpTransactionEventListener.h
20 * @brief This is the header file for the %IHttpTransactionEventListener interface.
22 * This header file contains the declarations of the %IHttpTransactionEventListener interface.
25 #ifndef _FNET_HTTP_IHTTP_TRANSACTION_EVENT_LISTENER_H_
26 #define _FNET_HTTP_IHTTP_TRANSACTION_EVENT_LISTENER_H_
28 #include <unique_ptr.h>
29 #include <FBaseTypes.h>
30 #include <FBaseString.h>
31 #include <FBaseColIList.h>
32 #include <FBaseRtIEventListener.h>
34 namespace Tizen { namespace Net { namespace Http
37 class HttpTransaction;
39 * @interface IHttpTransactionEventListener
40 * @brief This interface provides listeners for the HTTP transaction events.
44 * @remarks If a user-defined class is derived from multiple classes including this interface, a compile error for using an ambiguous base class can occur. @n
45 * In this case, type casting is required to declare an explicit base class for the user-defined class.
47 * The %IHttpTransactionEventListener interface provides listeners for the HTTP transaction events. To use this listener, you must add it to the HttpTransaction instance
48 * through the AddListener() method. If an HTTP transaction event is generated, a method of this class is called.
50 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/net/http_transaction.htm">HTTP Transaction</a>.
53 class _OSP_EXPORT_ IHttpTransactionEventListener
54 : virtual public Tizen::Base::Runtime::IEventListener
59 * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes are called when the destructor of this interface is called.
63 virtual ~IHttpTransactionEventListener(void) {}
67 * Called to notify when the content body of the response has been received.
71 * @param[in] httpSession The session information of the %Http transaction event
72 * @param[in] httpTransaction The transaction information of the %Http transaction event
73 * @param[in] availableBodyLen The length of the available body of the %Http transaction
74 * @see HttpResponse::ReadBodyN()
76 virtual void OnTransactionReadyToRead(HttpSession& httpSession, HttpTransaction& httpTransaction, int availableBodyLen) = 0;
79 * Called to notify when the process of transaction has been aborted.
83 * @param[in] httpSession The session information of the %Http transaction event
84 * @param[in] httpTransaction The transaction information of the %Http transaction event
85 * @param[in] r The cause of the error
86 * @exception E_INVALID_ARG A specified input parameter is invalid.
87 * @exception E_OUT_OF_MEMORY The memory is insufficient.
88 * @exception E_IO The method has failed to read the data.
89 * @exception E_TIMEOUT An attempt to connect to the server has timed out.
90 * @exception E_NETWORK_UNAVAILABLE The network is unavailable.
91 * @exception E_HOST_UNREACHABLE The network cannot be reached from this host at this time.
92 * @exception E_SYSTEM An internal error has occurred.
93 * @exception E_UNKNOWN An unknown error has occurred.
94 * @exception E_NOT_RESPONDING There is no response.
95 * @exception E_INVALID_CONTENT The content is invalid.
96 * @exception E_CONNECTION_RESET The network connection has been reset.
97 * @exception E_HTTP_USER The HTTP user is canceled.
98 * @exception E_NO_CERTIFICATE The client certificate is required to connect to the server.
99 * @exception E_UNSUPPORTED_SERVICE The service is not allowed.
100 * @exception E_USER_AGENT_NOT_ALLOWED The user agent is not allowed.
101 * @exception E_RESOURCE_UNAVAILABLE The network resource is unavailable.
102 * @remarks If the E_NO_CERTIFICATE exception is thrown, start the AppControl(L"tizen.certificatemanager") for getting the selected client certificate. @n
103 * For more information, see <a href="../org.tizen.native.appprogramming/html/guide/app/appcontrol_certmgr.htm">here</a>.
105 virtual void OnTransactionAborted(HttpSession& httpSession, HttpTransaction& httpTransaction, result r) = 0;
108 * Called to add chunks to the request.
112 * @param[in] httpSession The session information of the %Http transaction event
113 * @param[in] httpTransaction The transaction information of the %Http transaction event
114 * @param[in] recommendedChunkSize The length of the chunked %Http transaction
115 * @remarks To enable this listener, HttpTransaction::EnableTransactionReadyToWrite() must be called.
116 * @see HttpRequest::WriteBody()
118 virtual void OnTransactionReadyToWrite(HttpSession& httpSession, HttpTransaction& httpTransaction, int recommendedChunkSize) = 0;
121 * Called to notify when the header of response has been received.
125 * @param[in] httpSession The session information of the %Http transaction event
126 * @param[in] httpTransaction The transaction information of the %Http transaction event
127 * @param[in] headerLen The length of the %Http transaction's header
128 * @param[in] bAuthRequired Set to @c true if the transaction requires authentication, @n
130 * @see HttpResponse::GetHeader()
132 virtual void OnTransactionHeaderCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction, int headerLen, bool bAuthRequired) = 0;
135 * Called to notify when the process of transaction has been completed.
139 * @param[in] httpSession The session information of the %Http transaction event
140 * @param[in] httpTransaction The transaction information of the %Http transaction event
141 * @see HttpResponse::GetHeader()
142 * @see HttpResponse::ReadBodyN()
144 virtual void OnTransactionCompleted(HttpSession& httpSession, HttpTransaction& httpTransaction) = 0;
147 * Called to accept input from the user on whether to resume or pause the transaction in case the certificate is not verified.
151 * @param[in] httpSession The session information of the %Http transaction event
152 * @param[in] httpTransaction The transaction information of the %Http transaction event
153 * @param[in] pCert The certificate information
154 * @see HttpTransaction::Resume()
155 * @see HttpTransaction::Pause()
157 virtual void OnTransactionCertVerificationRequiredN(HttpSession& httpSession, HttpTransaction& httpTransaction, Tizen::Base::String* pCert) = 0;
160 * Called to notify when the server certificate verification has been requested.
164 * @return The result for certificate verification
165 * @param[in] httpSession The session information of the %Http transaction event
166 * @param[in] httpTransaction The transaction information of the %Http transaction event
167 * @param[in] pCertList The server certificate chain @n A Tizen::Base::Collection::IList whose element is of the type Tizen::Security::Cert::X509Certificate *.
169 * @remarks Do not delete the instance of @c httpSession or @c httpTransaction in this listener before the IHttpTransactionEventListener::OnTransactionCompleted() or IHttpTransactionEventListener::OnTransactionAborted() method is called.
170 * @see HttpTransaction::SetServerCertificateVerification()
172 virtual bool OnTransactionCertVerificationRequestedN(HttpSession& httpSession, HttpTransaction& httpTransaction, Tizen::Base::Collection::IList* pCertList)
174 std::unique_ptr<Tizen::Base::Collection::IList> upCertList(pCertList);
180 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
182 // This method is reserved and may change its name at any time without prior notice.
186 virtual void IHttpTransactionEventListener_Reserved1(void) {}
190 } } } // Tizen::Net::Http
191 #endif // _FNET_HTTP_IHTTP_TRANSACTION_EVENT_LISTENER_H_