Fix : The exception handling according to the situation
[platform/framework/native/content.git] / src / FCntContentTransferInfo.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * @file                FCntContentTransferInfo.cpp
18  * @brief               This is the implementation file for the %ContentTransferInfo class.
19  *
20  * This file contains implementation of the %ContentTransferInfo class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FCntContentTransferInfo.h>
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Utility;
28
29 namespace Tizen { namespace Content
30 {
31
32 static const int HASH_CODE_INITIAL_VALUE = 17;
33 static const int HASH_CODE_COEFFICIENT_VALUE = 37;
34
35 ContentTransferInfo::ContentTransferInfo(void)
36         : Object()
37         , __requestId(INVALID_REQUEST_ID)
38         , __restRequestId(INVALID_REQUEST_ID)
39         , __status(CONTENT_TRANSFER_STATUS_NONE)
40         , __destPath(L"")
41         , __uri()
42         , __sourcePath(L"")
43         , __sourceFileSize(-1)
44         , __slotId(-1)
45         , __pListener(null)
46         , __timeout(-1)
47         , __isBuffer(false)
48         , __intervalValue(-1)
49         , __pImpl(null)
50 {
51
52 }
53
54 ContentTransferInfo::~ContentTransferInfo(void)
55 {
56
57 }
58
59 Utility::Uri
60 ContentTransferInfo::GetUri(void) const
61 {
62         return __uri;
63 }
64
65 RequestId
66 ContentTransferInfo::GetRequestId(void) const
67 {
68         return __requestId;
69 }
70
71 String
72 ContentTransferInfo::GetDestPath(void) const
73 {
74         return __destPath;
75 }
76
77 ContentTransferStatus
78 ContentTransferInfo::GetContentTransferStatus(void) const
79 {
80         return __status;
81 }
82
83 void
84 ContentTransferInfo::SetAllInfo(RequestId reqId, const Uri& uri, const String& destPath, const String& sourcePath,
85                                                                 int sourceFileSize, ContentTransferStatus status)
86 {
87         __requestId = reqId;
88         __uri = uri;
89         __destPath = destPath;
90         __sourcePath = sourcePath;
91         __status = status;
92         __sourceFileSize = sourceFileSize;
93 }
94
95 void
96 ContentTransferInfo::SetRestRequestId(RequestId reqId)
97 {
98         __restRequestId = reqId;
99 }
100
101 RequestId
102 ContentTransferInfo::GetRestRequestId(void) const
103 {
104         return __restRequestId;
105 }
106
107 int
108 ContentTransferInfo::GetSourceFileSize(void) const
109 {
110         return __sourceFileSize;
111 }
112
113 void
114 ContentTransferInfo::SetSlotId(int slot)
115 {
116         __slotId = slot;
117 }
118
119 int
120 ContentTransferInfo::GetSlotId(void) const
121 {
122         return __slotId;
123 }
124
125 void
126 ContentTransferInfo::SetTimeout(int sec)
127 {
128         __timeout = sec;
129 }
130
131 int
132 ContentTransferInfo::GetTimeout(void) const
133 {
134         return __timeout;
135 }
136
137
138 void
139 ContentTransferInfo::SetListener(IContentTransferListener* pListener)
140 {
141         __pListener = pListener;
142 }
143
144 ContentTransferInfo*
145 ContentTransferInfo::CopyN(void)
146 {
147         ClearLastResult();
148         result r = E_SUCCESS;
149         ContentTransferInfo* pContentTransferInfoCopy = null;
150         pContentTransferInfoCopy = new (std::nothrow) ContentTransferInfo;
151         SysTryCatch(NID_CNT, pContentTransferInfoCopy != null, r = E_OUT_OF_MEMORY, E_OUT_OF_MEMORY,
152                            "[E_OUT_OF_MEMORY] Propagating.");
153
154         pContentTransferInfoCopy->SetAllInfo(__requestId, __uri, __destPath, __sourcePath, __sourceFileSize, __status);
155
156 CATCH:
157         return pContentTransferInfoCopy;
158 }
159
160 void
161 ContentTransferInfo::SetIsBuffer(bool isBuffer)
162 {
163         __isBuffer = isBuffer;
164 }
165
166 bool
167 ContentTransferInfo::GetIsBuffer(void) const
168 {
169         return __isBuffer;
170 }
171
172 void
173 ContentTransferInfo::SetProgressInterval(int intervalValue)
174 {
175         __intervalValue = intervalValue;
176 }
177
178 int
179 ContentTransferInfo::GetProgressInterval(void) const
180 {
181         return __intervalValue;
182 }
183
184 void
185 ContentTransferInfo::SetDownloadStatus(ContentTransferStatus status)
186 {
187         __status = status;
188 }
189 }}