2 // Open Service Platform
3 // Copyright (c) 2012 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 FWebCtrlIWebDownloadListener.h
20 * @brief This is the header file for the %IWebDownloadListener interface.
22 * This header file contains the declarations of the %IWebDownloadListener interface.
24 #ifndef _FWEB_CTRL_IWEB_DOWNLOAD_LISTENER_H_
25 #define _FWEB_CTRL_IWEB_DOWNLOAD_LISTENER_H_
27 #include <FBaseByteBuffer.h>
28 #include <FBaseRtIEventListener.h>
29 #include <FWebCtrlILoadingListener.h>
31 namespace Tizen { namespace Web { namespace Controls
35 * @interface IWebDownloadListener
36 * @brief This interface downloads data from the internet.
40 * The %IWebDownloadListener interface downloads data from the internet.
41 * An application receives content from a network incrementally
42 * when it decides to download the content after checking the Multipurpose Internet Mail Extensions (MIME).
43 * This is useful when the content is not supported by the framework itself and the application wants to handle it.
45 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/web/controls_namespace.htm">Web Controls Guide</a>.
47 * The following examples demonstrate how to use the %IWebDownloadListener interface.
50 * #include <FUiControls.h>
52 * using namespace Tizen::Web;
53 * using namespace Tizen::Ui::Controls;
55 * // Adds a Web control to the parent container
57 * WebSample::CreateControl(Form* pParentForm)
59 * result r = E_SUCCESS;
62 * r = pWeb->Construct( pParentForm->GetClientAreaBounds());
63 * r = pParentForm->AddControl(pWeb);
65 * // Sets a loading listener and a Web downloading listener
66 * pWeb->SetDownloadListener(pMyDownloadListener);
67 * pWeb->SetLoadingListener(pMyLoadingListener);
73 * As soon as the first chunk of data is received, OnWebDataReceived() is fired with the MIME type.
74 * If you want to download the data, return @c WEB_DECISION_DOWNLOAD.
78 * MyLoadingListener::OnWebDataReceived(const Tizen::Base::String& mime, const Tizen::Net::Http::HttpHeader& header)
80 * return WEB_DECISION_DOWNLOAD;
84 * Then, the data is routed to OnWebChunkedDataReceived().
88 * MyDownloadListener::OnWebChunkedDataReceived(Tizen::Base::ByteBuffer& chunk)
94 class _OSP_EXPORT_ IWebDownloadListener
95 : public virtual Tizen::Base::Runtime::IEventListener
99 * This polymorphic destructor should be overridden if required. @n
100 * This way, the destructors of the derived classes are called when the destructor of this interface is called.
104 virtual ~IWebDownloadListener(void) {}
107 * Called when the HyperText Transfer Protocol (HTTP) protocol receives the next chunked data.
111 * @param[in] chunk The chunked data
112 * @remarks The received data size is less than the capacity of the specified Tizen::Base::ByteBuffer by @c 1.
114 virtual void OnWebChunkedDataReceived(const Tizen::Base::ByteBuffer& chunk) = 0;
117 * Called when the downloading of the content is completed.
121 virtual void OnWebDataDownloadCompleted(void) = 0;
124 * Called when an error occurs while downloading content.
128 * @param[in] error The type of error that occurs while downloading data
130 virtual void OnWebDownloadFailed(LoadingErrorType error) = 0;
134 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
136 // Gets the Impl instance.
140 virtual void IWebDownloadListener_Reserved1(void) {}
143 // This method is for internal use only. Using this method can cause behavioral, security-related, and consistency-related issues in the application.
145 // Gets the Impl instance.
149 virtual void IWebDownloadListener_Reserved2(void) {}
151 }; // IWebDownloadListener
153 }}} // Tizen::Web::Controls
154 #endif // _FWEB_CTRL_IWEB_DOWNLOAD_LISTENER_H_