Fixed Nabi Issues
[apps/osp/Internet.git] / src / IntBookmarkData.cpp
1 //
2
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
5 // Licensed under the Flora License, Version 1.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://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: IntBookmark.cpp
20  *@brief: Used to define bookmark
21  */
22
23 #include <FMedia.h>
24 #include "IntBookmarkData.h"
25
26 using namespace Tizen::Base;
27 using namespace Tizen::Media;
28 using namespace Tizen::Graphics;
29
30 BookmarkData::BookmarkData(void)
31         : __bookmarkId("")
32         , __bookmarkType(BOOKMARK_TYPE_URL)
33         , __bookmarkTitle("")
34         , __bookmarkUrl("")
35         , __parentId("-1")
36         , __iconPath("")
37     , __faviconId("")
38         , __pFavIconData(null)
39 {
40         __createdTime.SetValue(0, 0, 0);
41         __modifiedTime.SetValue(0, 0, 0);
42 }
43
44 BookmarkData::BookmarkData(const BookmarkData& bookmark)
45 {
46         __bookmarkId = bookmark.__bookmarkId;
47         __bookmarkType = bookmark.__bookmarkType;
48         __bookmarkTitle = bookmark.__bookmarkTitle;
49         __bookmarkUrl = bookmark.__bookmarkUrl;
50         __parentId = bookmark.__parentId;
51         __iconPath=bookmark.__iconPath;
52         __faviconId=bookmark.__faviconId;
53 }
54
55 BookmarkData::~BookmarkData(void)
56 {
57
58 }
59
60 BookmarkData&
61 BookmarkData::operator =(const BookmarkData& rhs)
62 {
63         if (this != &rhs)
64         {
65                 __bookmarkId = rhs.__bookmarkId;
66                 __bookmarkType = rhs.__bookmarkType;
67                 __bookmarkTitle = rhs.__bookmarkTitle;
68                 __bookmarkUrl = rhs.__bookmarkUrl;
69                 __parentId = rhs.__parentId;
70                 __iconPath = rhs.__iconPath;
71                 __faviconId = rhs.__faviconId;
72         }
73         return *this;
74 }
75
76 String
77 BookmarkData::GetBookmarkId(void)
78 {
79         return __bookmarkId;
80 }
81
82 type
83 BookmarkData::GetBookmarkType(void)
84 {
85         if (__bookmarkUrl.GetLength() > 0)
86                 __bookmarkType = BOOKMARK_TYPE_URL;
87         else
88                 __bookmarkType = BOOKMARK_TYPE_FOLDER;
89         return __bookmarkType;
90 }
91
92 String
93 BookmarkData::GetBookmarkTitle(void)
94 {
95         return __bookmarkTitle;
96 }
97
98 String
99 BookmarkData::GetUrl(void)
100 {
101         return __bookmarkUrl;
102 }
103
104 String
105 BookmarkData::GetParentId(void)
106 {
107         return __parentId;
108 }
109
110 DateTime
111 BookmarkData::GetCreatedTime(void)
112 {
113         return __createdTime;
114 }
115
116 DateTime
117 BookmarkData::GetModifiedTime(void)
118 {
119         return __modifiedTime;
120 }
121
122 String
123 BookmarkData::GetIconPath(void)
124 {
125         return __iconPath;
126 }
127
128 String
129 BookmarkData::GetFaviconId(void)
130 {
131         return __faviconId;
132 }
133
134 void
135 BookmarkData::SetBookmarkId(const String& strBookmarkId)
136 {
137         __bookmarkId = strBookmarkId;
138 }
139
140 void
141 BookmarkData::SetBookmarkTitle(String& strTitle)
142 {
143         strTitle.Trim();
144         __bookmarkTitle = strTitle;
145 }
146
147 void BookmarkData::SetBookmarkType(type bookmarkType)
148 {
149         __bookmarkType = bookmarkType;
150 }
151
152 void
153 BookmarkData::SetUrl(const String& strUrl)
154 {
155         __bookmarkUrl = strUrl;
156 }
157
158 void
159 BookmarkData::SetParentId(const String& strParentID)
160 {
161         __parentId = strParentID;
162 }
163
164 void
165 BookmarkData::SetCreatedTime(const DateTime& strCreatedTime)
166 {
167         __createdTime = strCreatedTime;
168 }
169
170 void
171 BookmarkData::SetModifiedTime(const DateTime& strModifiedTime)
172 {
173         __modifiedTime = strModifiedTime;
174 }
175
176 void
177 BookmarkData::SetIconPath(const String& strFilePath)
178 {
179         __iconPath = strFilePath;
180 }
181
182 void
183 BookmarkData::SetFaviconId(const String& strFaviconId)
184 {
185         __faviconId = strFaviconId;
186 }
187
188 void
189 BookmarkData::SetFavIconBitmap(Tizen::Graphics::Bitmap& favIconImage)
190 {
191         Image* pImage = null;
192 //      ByteBuffer* pEncodedBuffer = null;
193
194         __favIconWidth = favIconImage.GetWidth();
195         __favIconHeight = favIconImage.GetHeight();
196
197         pImage = new Image();
198         pImage->Construct();
199         //__pFavIconData = pImage->EncodeToBufferN(favIconImage,Tizen::Media::IMG_FORMAT_PNG);
200         __pFavIconData = pImage->EncodeToBufferN(favIconImage,IMG_FORMAT_PNG);
201
202         //__pFavIconData = pImage->DecodeToBufferN(*pEncodedBuffer, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888, __favIconWidth, __favIconHeight);
203
204         delete pImage;
205 }
206
207 void
208 BookmarkData::SetFavIconBuffer(Tizen::Base::ByteBuffer& favIconBuffer)
209 {
210         __pFavIconData = &favIconBuffer;
211 }
212
213 ByteBuffer*
214 BookmarkData::GetFavIconBuffer()
215 {
216         return __pFavIconData;
217 }
218
219 Bitmap*
220 BookmarkData::GetFavIconBitmap()
221 {
222         Bitmap *pBitmap = null;
223
224         if (__pFavIconData != null)
225         {
226                 Image *pImage = new(std::nothrow) Image();
227                 pImage->Construct();
228                 pBitmap = pImage->DecodeN(*__pFavIconData, IMG_FORMAT_PNG, BITMAP_PIXEL_FORMAT_ARGB8888);
229                 delete pImage;
230         }
231         return pBitmap;
232 }
233
234
235
236 int BookmarkData::GetFavIconWidth()
237 {
238         return __favIconWidth;
239 }
240
241 int BookmarkData::GetFavIconHeight()
242 {
243         return __favIconHeight;
244 }
245
246 void
247 BookmarkData::SetFavIconWidth(int favIconWidth)
248 {
249         __favIconWidth = favIconWidth;
250 }
251
252 void
253 BookmarkData::SetFavIconHeight(int favIconHeight)
254 {
255         __favIconHeight = favIconHeight;
256 }