2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
5 // Licensed under the Apache License, Version 2.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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
19 * @file FWeb_HistoryItemImplcpp
20 * @brief The file contains the definition of _HistoryItemImpl class.
22 * This file contains the definition of _HistoryItemImpl class.
24 #include <favorites.h>
25 #include <unique_ptr.h>
26 #include <FBaseBoolean.h>
27 #include <FBaseInteger.h>
28 #include <FBaseSysLog.h>
29 #include <FGrpBitmap.h>
30 #include <FGrpDimension.h>
31 #include <FUiCtrlFrame.h>
32 #include <FWebBookmarkItem.h>
33 #include "FWeb_BookmarkItemImpl.h"
34 #include "FWebCtrl_Utility.h"
37 using namespace Tizen::Base;
38 using namespace Tizen::Graphics;
39 using namespace Tizen::Ui::Controls;
40 using namespace Tizen::Web::Controls;
43 namespace Tizen { namespace Web
47 _BookmarkItemImpl::_BookmarkItemImpl(void)
58 _BookmarkItemImpl::~_BookmarkItemImpl(void)
64 _BookmarkItemImpl::SetBookmarkItem(RecordId id, const String& url, const String& title, RecordId parentId, bool isFolder)
69 __parentId = parentId;
70 __isFolder = isFolder;
75 _BookmarkItemImpl::GetTitle(void) const
82 _BookmarkItemImpl::GetUrl(void) const
89 _BookmarkItemImpl::GetFaviconN(void) const
94 Evas_Object* pIcon = null;
96 BufferInfo bufferInfo;
97 ByteBuffer byteBuffer;
99 std::unique_ptr<Bitmap> pImage;
103 pEvas = _Utility::GetEvasFromUiApp(pFrame);
104 SysTryCatch(NID_WEB, pEvas, , E_SYSTEM, "[E_SYSTEM] Propagating.");
106 ret = favorites_bookmark_get_favicon(__id, pEvas, &pIcon);
107 SysTryCatch(NID_WEB, ret == FAVORITES_ERROR_NONE, , E_SYSTEM, "[E_SYSTEM] Propagating.");
114 r = _Utility::GetPixelBufferFromEvasObject(pIcon, bufferInfo);
115 SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
117 dimension.width = bufferInfo.width;
118 dimension.height = bufferInfo.height;
120 r = byteBuffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
121 SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
123 pImage = std::unique_ptr<Bitmap>(new (std::nothrow) Bitmap());
124 SysTryCatch(NID_WEB, pImage.get(), , E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
126 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
127 SysTryCatch(NID_WEB, r == E_SUCCESS, , r, "[%s] Propagating.", GetErrorMessage(r));
131 return pImage.release();
141 _BookmarkItemImpl::GetParentFolderId(void) const
148 _BookmarkItemImpl::IsFolder(void) const
155 _BookmarkItemImpl::Equals(const Object& obj) const
157 const _BookmarkItemImpl* pRhs = dynamic_cast< const _BookmarkItemImpl* >(&obj);
163 return __id == pRhs->__id && __url == pRhs->__url && __title == pRhs->__title && __parentId == pRhs->__parentId
164 && __isFolder == pRhs->__isFolder;
169 _BookmarkItemImpl::GetHashCode(void) const
171 return Integer(__id).GetHashCode() + __url.GetHashCode() + __title.GetHashCode()
172 + Integer(__parentId).GetHashCode() + Boolean(__isFolder).GetHashCode();
177 _BookmarkItemImpl::GetInstance(BookmarkItem* pBookmarkItem)
179 return pBookmarkItem->__pBookmarkItemImpl;
183 const _BookmarkItemImpl*
184 _BookmarkItemImpl::GetInstance(const BookmarkItem* pBookmarkItem)
186 return pBookmarkItem->__pBookmarkItemImpl;