add to resume event
[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         AppLog("History::~History()");
71 }
72
73 History&
74 History::operator =(const History& rhs)
75 {
76         if (this != &rhs)
77         {
78                 __historyId = rhs.__historyId;
79                 __historyTitle = rhs.__historyTitle;
80                 __historyUrl = rhs.__historyUrl;
81         }
82         return *this;
83 }
84
85 String
86 History::GetHistoryId(void) const
87 {
88         return __historyId;
89 }
90
91 String
92 History::GetHistoryTitle(void) const
93 {
94         return __historyTitle;
95 }
96
97 String
98 History::GetHistoryUrl(void) const
99 {
100         return __historyUrl;
101 }
102
103 DateTime
104 History::GetVisitedTime(void) const
105 {
106         return __visitedTime;
107 }
108
109 String
110 History::GetHistoryIconPath(void) const
111 {
112         return __iconPath;
113 }
114
115 String
116 History::GetFaviconId(void) const
117 {
118         return __faviconId;
119 }
120
121 String
122 History::GetBookmarkId(void) const
123 {
124         return __bookmarkId;
125 }
126
127 int
128 History::GetVisitedCount(void) const
129 {
130         return __visitedCount;
131 }
132
133 Bitmap*
134 History::GetThumbnail(void) const
135 {
136         return __pThumbnail;
137 }
138
139 String
140 History::GetThumbnailPath(void) const
141 {
142         return __thumbnailPath;
143 }
144
145 void
146 History::SetHistoryId(const String& strHistoryId)
147 {
148         __historyId = strHistoryId;
149         return;
150 }
151
152 void
153 History::SetHistoryTitle(String& strHistoryTitle)
154 {
155         strHistoryTitle.Trim();
156         __historyTitle = strHistoryTitle;
157         return;
158 }
159
160 void
161 History::SetHistoryUrl(const String& strHistoryUrl)
162 {
163         __historyUrl = strHistoryUrl;
164         return;
165 }
166
167 void
168 History::SetVisitedTime(const DateTime& strVisitedTime)
169 {
170         __visitedTime = strVisitedTime;
171         return;
172 }
173
174 void
175 History::SetIconPath(const String& strFilePath)
176 {
177         __iconPath = strFilePath;
178         return;
179 }
180
181 void
182 History::SetFaviconId(const String& strFaviconId)
183 {
184         __faviconId = strFaviconId;
185 }
186
187 void
188 History::SetBookmarkId(const String& bookmarkId)
189 {
190         __bookmarkId = bookmarkId;
191 }
192
193 void
194 History::SetVisitedCount(int& visitedCount)
195 {
196         __visitedCount = visitedCount;
197 }
198
199 void
200 History::SetThumbnail(Bitmap* thumbnail)
201 {
202         //TODO To get this reviewed
203         if(__pThumbnail != thumbnail && __pThumbnail != null) {
204                 delete __pThumbnail;
205         }
206         __pThumbnail = thumbnail;
207 }
208
209 void
210 History::SetThumbnailPath(String& thumbnailPath)
211 {
212         __thumbnailPath = thumbnailPath;
213 }
214
215 void
216 History::SetFavIconBitmap(Tizen::Graphics::Bitmap& favIconImage)
217 {
218         Image* pImage = null;
219         pImage = new Image();
220         pImage->Construct();
221         __pFavIconData = pImage->EncodeToBufferN(favIconImage,Tizen::Media::IMG_FORMAT_PNG);
222
223         __favIconWidth = favIconImage.GetWidth();
224         __favIconHeight = favIconImage.GetHeight();
225
226         delete pImage;
227 }
228
229 void
230 History::SetFavIconBuffer(Tizen::Base::ByteBuffer& favIconBuffer)
231 {
232         __pFavIconData = &favIconBuffer;
233 }
234
235 ByteBuffer*
236 History::GetFavIconBuffer()
237 {
238         return __pFavIconData;
239 }
240
241 Bitmap*
242 History::GetFavIconBitmap()
243 {
244         Bitmap *pBitmap = null;
245
246         if (__pFavIconData != null)
247         {
248                 Image *pImage = new(std::nothrow) Image();
249                 pImage->Construct();
250                 pBitmap = pImage->DecodeN(*__pFavIconData, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
251                 delete pImage;
252         }
253         return pBitmap;
254 }
255
256 int
257 History::GetFavIconWidth()
258 {
259         return __favIconWidth;
260 }
261
262 int
263 History::GetFavIconHeight()
264 {
265         return __favIconHeight;
266 }
267
268 void
269 History::SetFavIconWidth(int width)
270 {
271         __favIconWidth = width;
272 }
273
274 void
275 History::SetFavIconHeight(int height)
276 {
277         __favIconHeight = height;
278 }