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