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 <FWebBookmarkItem.h>
32 #include "FWeb_BookmarkItemImpl.h"
33 #include "FWebCtrl_Utility.h"
36 using namespace Tizen::Base;
37 using namespace Tizen::Graphics;
38 using namespace Tizen::Web::Controls;
41 namespace Tizen { namespace Web
45 _BookmarkItemImpl::_BookmarkItemImpl(void)
56 _BookmarkItemImpl::~_BookmarkItemImpl(void)
62 _BookmarkItemImpl::SetBookmarkItem(RecordId id, const String& url, const String& title, RecordId parentId, bool isFolder)
67 __parentId = parentId;
68 __isFolder = isFolder;
73 _BookmarkItemImpl::GetTitle(void) const
80 _BookmarkItemImpl::GetUrl(void) const
87 _BookmarkItemImpl::GetFaviconN(void) const
91 Evas* pEvas = _Utility::GetEvasFromUiApp();
92 SysTryReturn(NID_WEB, pEvas, null, E_SYSTEM, "[E_SYSTEM] Propagating.");
94 Evas_Object* pIcon = null;
95 int ret = favorites_bookmark_get_favicon(__id, pEvas, &pIcon);
96 SysTryReturn(NID_WEB, ret == FAVORITES_ERROR_NONE, null, E_SYSTEM, "[E_SYSTEM] Propagating.");
103 BufferInfo bufferInfo;
104 r = _Utility::GetPixelBufferFromEvasObject(pIcon, bufferInfo);
105 SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
107 const Dimension dimension(bufferInfo.width, bufferInfo.height);
109 ByteBuffer byteBuffer;
110 r = byteBuffer.Construct(reinterpret_cast < byte* >(bufferInfo.pPixels), 0, dimension.height * dimension.width * 32, dimension.height * dimension.width * 32 );
111 SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
113 std::unique_ptr<Bitmap> pImage(new (std::nothrow) Bitmap());
114 SysTryReturn(NID_WEB, pImage.get(), null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
116 r = pImage->Construct(byteBuffer, dimension, BITMAP_PIXEL_FORMAT_ARGB8888);
117 SysTryReturn(NID_WEB, r == E_SUCCESS, null, r, "[%s] Propagating.", GetErrorMessage(r));
119 return pImage.release();
124 _BookmarkItemImpl::GetParentFolderId(void) const
131 _BookmarkItemImpl::IsFolder(void) const
138 _BookmarkItemImpl::Equals(const Object& obj) const
140 const _BookmarkItemImpl* pRhs = dynamic_cast< const _BookmarkItemImpl* >(&obj);
146 return __id == pRhs->__id && __url == pRhs->__url && __title == pRhs->__title && __parentId == pRhs->__parentId
147 && __isFolder == pRhs->__isFolder;
152 _BookmarkItemImpl::GetHashCode(void) const
154 return Integer(__id).GetHashCode() + __url.GetHashCode() + __title.GetHashCode()
155 + Integer(__parentId).GetHashCode() + Boolean(__isFolder).GetHashCode();
160 _BookmarkItemImpl::GetInstance(BookmarkItem* pBookmarkItem)
162 return pBookmarkItem->__pBookmarkItemImpl;
166 const _BookmarkItemImpl*
167 _BookmarkItemImpl::GetInstance(const BookmarkItem* pBookmarkItem)
169 return pBookmarkItem->__pBookmarkItemImpl;