merge commits of 2.2.1 to public
[platform/framework/native/image.git] / src / FMedia_ImageUriData.h
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
10 //
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.
16 //
17
18 /**
19  * @file   FMedia_ImageUriData.h
20  * @brief  This file contains the declaration of _ImageUriData class,
21  *               required internally by Image::DecodeUrl.
22  */
23
24 #ifndef FMEDIA_INTERNAL_IMAGEURIDATA_H_
25 #define FMEDIA_INTERNAL_IMAGEURIDATA_H_
26
27 #include <unique_ptr.h>
28
29 namespace Tizen { namespace Net { namespace Http
30 {
31 class HttpTransaction;
32 class HttpSession;
33 class HttpRequest;
34
35 class _HttpTransactionImpl;
36 class _HttpSessionImpl;
37 class _HttpRequestImpl;
38 }}}
39 namespace Tizen{ namespace Media{
40
41 class _ImageUriDataEvent;
42 class _ImageDownloadListener;
43 class IImageDecodeUrlEventListener;
44
45 /**
46  *      @brief  This class provides the _ImageUriData
47  *
48  *      @see    Image
49  */
50 class _ImageUriData
51         : virtual public Tizen::Base::Object
52         , virtual public Tizen::Base::Runtime::ITimerEventListener
53         , virtual public Tizen::Base::Runtime::IEventListener
54 {
55 public:
56         _ImageUriData(void);
57         virtual ~_ImageUriData(void);
58
59         result Construct(Tizen::Base::Runtime::IEventListener& listener);
60         result RequestDecode(const Tizen::Base::Utility::Uri &uri,
61           Tizen::Graphics::BitmapPixelFormat colorFormat,
62           const Tizen::Graphics::Dimension& destDim, RequestId& reqId, long msec);
63         result Cancel(RequestId reqId, result res);
64         RequestId GetRequestId(void) const;
65
66         Tizen::Base::Utility::Uri GetDownloadableUri(void) const;
67
68 private:
69         _ImageUriData(const _ImageUriData& rhs);
70         _ImageUriData& operator =(const _ImageUriData& rhs);
71
72         result RequestDownload(const Tizen::Base::Utility::Uri &downloadUri, RequestId& reqId, long msec );
73
74         void  OnTimerExpired (Tizen::Base::Runtime::Timer &timer);
75
76         Tizen::Base::Utility::Uri __srcUri;
77         Tizen::Base::Utility::Uri __downloadableUri;
78         int __destWidth;
79         int __destHeight;
80         std::unique_ptr<Tizen::Net::Http::HttpSession> __pSession;
81         Tizen::Net::Http::_HttpSessionImpl* __pSessionImpl;
82         std::unique_ptr<Tizen::Net::Http::HttpTransaction> __pTransaction;
83         Tizen::Net::Http::_HttpTransactionImpl* __pTransactionImpl;
84         Tizen::Net::Http::HttpRequest* __pRequest;
85         Tizen::Net::Http::_HttpRequestImpl* __pRequestImpl;
86         std::unique_ptr<_ImageDownloadListener> __pListener;
87         std::unique_ptr<_ImageUriDataEvent> __pDataEvent;
88         Tizen::Base::Runtime::Timer __requestTimeout;
89         Tizen::Graphics::BitmapPixelFormat __colorFormat;
90         RequestId __requestId;
91         int __refCount;
92         bool __isTimerStarted;
93 };
94
95 }} // Tizen::Media
96
97 #endif // FMEDIA_INTERNAL_IMAGEURIDATA_H_