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