merge with master
[platform/framework/native/content.git] / src / inc / FCnt_DownloadManagerImpl.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  * @file                FCnt_DownloadManagerImpl.h
19  * @brief               This is the header file for the %_DownloadManagerImpl class.
20  *
21  * This header file contains the declarations of the %_DownloadManagerImpl class.
22  */
23 #ifndef _FCNT_DOWNLOAD_MANAGER_IMPL_H_
24 #define _FCNT_DOWNLOAD_MANAGER_IMPL_H_
25
26 #include <FBaseResult.h>
27 #include <FBaseString.h>
28 #include <FBaseRtEvent.h>
29 #include <FBaseColHashMapT.h>
30
31 namespace Tizen { namespace Content
32 {
33
34 class DownloadRequest;
35 class _DownloadRequestImpl;
36
37 class IDownloadListener;
38
39 class _OSP_EXPORT_ _DownloadManagerImpl
40         : public Tizen::Base::Object
41 {
42 public:
43         enum State
44         {
45                 STATE_NONE = 0,
46                 STATE_QUEUED,
47                 STATE_DOWNLOADING,
48                 STATE_PAUSED,
49                 STATE_CANCELLED,
50                 STATE_COMPLETED,
51                 STATE_FAILED
52         };
53
54         enum NetworkType
55         {
56                 NETWORK_DATA = 1,
57                 NETWORK_WIFI,
58                 NETWORK_ALL = 100
59         };
60
61 public:
62         _DownloadManagerImpl(void);
63         virtual ~_DownloadManagerImpl(void);
64
65         result Construct(void);
66
67         result Start(const DownloadRequest& request, RequestId& reqId);
68         result Pause(RequestId reqId);
69         result Resume(RequestId reqId);
70         result Cancel(RequestId reqId);
71
72         DownloadRequest* GetDownloadRequestN(RequestId reqId);
73
74         State GetState(RequestId reqId) const;
75
76         result GetMimeType(RequestId reqId, Tizen::Base::String& mimeType);
77
78         result GetProgress(RequestId reqId, int& progress);
79
80         result SetAllowedNetwork(unsigned long flags);
81
82         void SetDownloadListener(IDownloadListener* pListener);
83
84         void DestroyResources(RequestId reqId);
85
86         static result ConvertToResult(int error);
87
88         static _DownloadManagerImpl* GetInstance(void);
89
90 public:
91         IDownloadListener* __pListener;
92         Tizen::Base::Runtime::Event* __pEvent;
93
94 private:
95         _DownloadManagerImpl(const _DownloadManagerImpl& clientChannel);
96         _DownloadManagerImpl& operator =(const _DownloadManagerImpl& clientChannel);
97
98         static void InitSingleton(void);
99         static void DestroySingleton(void);
100
101         enum DownloadOperation
102         {
103                 DOWNLOAD_OPERATION_START,
104                 DOWNLOAD_OPERATION_PAUSE,
105                 DOWNLOAD_OPERATION_RESUME,
106                 DOWNLOAD_OPERATION_CANCEL,
107         };
108
109         result CheckPrestate(DownloadOperation operation, State current);
110
111         result RegisterCallback(RequestId reqId);
112         void UnregisterCallback(RequestId reqId);
113
114 private:
115         Tizen::Base::Collection::HashMapT<RequestId, DownloadRequest*> __handleMap;
116
117         static _DownloadManagerImpl* __pInstance;
118 }; // _DownloadManagerImpl
119
120 } } // Tizen::Content
121
122 #endif //_FCNT_DOWNLOAD_MANAGER_IMPL_H_
123