Initialize Tizen 2.3
[apps/osp/Internet.git] / src / IntHistory.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.1 (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://floralicense.org/license/
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 //!Internet
19 /*@file: IntHistory.cpp
20  *@brief: Used to define History
21  */
22
23 #include "IntHistoryData.h"
24
25 using namespace Tizen::App;
26 using namespace Tizen::Base;
27 using namespace Tizen::Base::Collection;
28 using namespace Tizen::Base::Utility;
29 using namespace Tizen::Content;
30 using namespace Tizen::Graphics;
31 using namespace Tizen::Io;
32 using namespace Tizen::System;
33 using namespace Tizen::Locales;
34 using namespace Tizen::Media;
35 using namespace Tizen::Ui;
36 using namespace Tizen::Ui::Controls;
37
38 History::History(void)
39         : __historyId("")
40         , __historyTitle("")
41         , __historyUrl("")
42         , __iconPath("")
43         ,__bookmarkId(L"")
44         ,__faviconId(L"")
45     , __visitedCount(0)
46         , __pThumbnail(null)
47     , __thumbnailPath("")
48         ,__pFavIconData(null)
49         ,__favIconHeight(0)
50         ,__favIconWidth(0)
51 {
52         AppLog("History::History(void)");
53         __visitedTime.SetValue(0,0,0);
54 }
55
56 History::History(const History& hs)
57 {
58         AppLog("History::History(const History& hs)");
59         __historyId = hs.__historyId;
60         __historyTitle = hs.__historyTitle;
61         __historyUrl = hs.__historyUrl;
62 }
63
64 History::~History(void)
65 {
66         if (__pThumbnail != null)
67         {
68                 delete __pThumbnail; //TODO To get this reviewed
69         }
70         if (__pFavIconData)
71         {
72                 delete __pFavIconData;
73         }
74         AppLog("History::~History()");
75 }
76
77 History&
78 History::operator =(const History& rhs)
79 {
80         if (this != &rhs)
81         {
82                 __historyId = rhs.__historyId;
83                 __historyTitle = rhs.__historyTitle;
84                 __historyUrl = rhs.__historyUrl;
85         }
86         return *this;
87 }
88
89 String
90 History::GetHistoryId(void) const
91 {
92         return __historyId;
93 }
94
95 String
96 History::GetHistoryTitle(void) const
97 {
98         return __historyTitle;
99 }
100
101 String
102 History::GetHistoryUrl(void) const
103 {
104         return __historyUrl;
105 }
106
107 DateTime
108 History::GetVisitedTime(void) const
109 {
110         return __visitedTime;
111 }
112
113 String
114 History::GetHistoryIconPath(void) const
115 {
116         return __iconPath;
117 }
118
119 String
120 History::GetFaviconId(void) const
121 {
122         return __faviconId;
123 }
124
125 String
126 History::GetBookmarkId(void) const
127 {
128         return __bookmarkId;
129 }
130
131 int
132 History::GetVisitedCount(void) const
133 {
134         return __visitedCount;
135 }
136
137 Bitmap*
138 History::GetThumbnail(void) const
139 {
140         return __pThumbnail;
141 }
142
143 String
144 History::GetThumbnailPath(void) const
145 {
146         return __thumbnailPath;
147 }
148
149 void
150 History::SetHistoryId(const String& strHistoryId)
151 {
152         __historyId = strHistoryId;
153         return;
154 }
155
156 void
157 History::SetHistoryTitle(String& strHistoryTitle)
158 {
159         strHistoryTitle.Trim();
160         __historyTitle = strHistoryTitle;
161         return;
162 }
163
164 void
165 History::SetHistoryUrl(const String& strHistoryUrl)
166 {
167         __historyUrl = strHistoryUrl;
168         return;
169 }
170
171 void
172 History::SetVisitedTime(const DateTime& strVisitedTime)
173 {
174         __visitedTime = strVisitedTime;
175         return;
176 }
177
178 void
179 History::SetIconPath(const String& strFilePath)
180 {
181         __iconPath = strFilePath;
182         return;
183 }
184
185 void
186 History::SetFaviconId(const String& strFaviconId)
187 {
188         __faviconId = strFaviconId;
189 }
190
191 void
192 History::SetBookmarkId(const String& bookmarkId)
193 {
194         __bookmarkId = bookmarkId;
195 }
196
197 void
198 History::SetVisitedCount(int& visitedCount)
199 {
200         __visitedCount = visitedCount;
201 }
202
203 void
204 History::SetThumbnail(Bitmap* thumbnail)
205 {
206         //TODO To get this reviewed
207         if(__pThumbnail != thumbnail && __pThumbnail != null) {
208                 delete __pThumbnail;
209         }
210         __pThumbnail = thumbnail;
211 }
212
213 void
214 History::SetThumbnailPath(String& thumbnailPath)
215 {
216         __thumbnailPath = thumbnailPath;
217 }
218
219 void
220 History::SetFavIconBitmap(Tizen::Graphics::Bitmap& favIconImage)
221 {
222         Image* pImage = null;
223         pImage = new Image();
224         pImage->Construct();
225         if (__pFavIconData != null)
226         {
227                 delete __pFavIconData;
228                 __pFavIconData = null;
229         }
230         __pFavIconData = pImage->EncodeToBufferN(favIconImage,Tizen::Media::IMG_FORMAT_PNG);
231
232         __favIconWidth = favIconImage.GetWidth();
233         __favIconHeight = favIconImage.GetHeight();
234
235         delete pImage;
236 }
237
238 void
239 History::SetFavIconBuffer(Tizen::Base::ByteBuffer& favIconBuffer)
240 {
241         __pFavIconData = &favIconBuffer;
242 }
243
244 ByteBuffer*
245 History::GetFavIconBuffer()
246 {
247         return __pFavIconData;
248 }
249
250 Bitmap*
251 History::GetFavIconBitmap()
252 {
253         Bitmap *pBitmap = null;
254
255         if (__pFavIconData != null)
256         {
257                 Image *pImage = new(std::nothrow) Image();
258                 pImage->Construct();
259                 pBitmap = pImage->DecodeN(*__pFavIconData, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
260                 delete pImage;
261         }
262         return pBitmap;
263 }
264
265 int
266 History::GetFavIconWidth()
267 {
268         return __favIconWidth;
269 }
270
271 int
272 History::GetFavIconHeight()
273 {
274         return __favIconHeight;
275 }
276
277 void
278 History::SetFavIconWidth(int width)
279 {
280         __favIconWidth = width;
281 }
282
283 void
284 History::SetFavIconHeight(int height)
285 {
286         __favIconHeight = height;
287 }