Tizen 2.2.1
[framework/osp/web.git] / src / FWebBookmarkItem.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
4 //
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
8 //
9 //     http://www.apache.org/licenses/LICENSE-2.0
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 /**
19  * @file                FWebHistoryItem.cpp
20  * @brief               The file contains the definition of HistoryItem class.
21  *
22  * This file contains the definition of HistoryItem class.
23  */
24 #include <new>
25 #include <FBaseResult.h>
26 #include <FBaseSysLog.h>
27 #include <FGrpBitmap.h>
28 #include <FWebBookmarkItem.h>
29 #include "FWeb_BookmarkItemImpl.h"
30
31
32 using namespace Tizen::Base;
33 using namespace Tizen::Graphics;
34
35
36 namespace Tizen { namespace Web
37 {
38
39
40 BookmarkItem::BookmarkItem(void)
41         : __pBookmarkItemImpl(new (std::nothrow) _BookmarkItemImpl())
42 {
43         SysTryReturnVoidResult(NID_WEB, __pBookmarkItemImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
44 }
45
46
47 BookmarkItem::BookmarkItem(const BookmarkItem& rhs)
48         : __pBookmarkItemImpl(new (std::nothrow) _BookmarkItemImpl(*_BookmarkItemImpl::GetInstance(&rhs)))
49 {
50         SysTryReturnVoidResult(NID_WEB, __pBookmarkItemImpl, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
51 }
52
53
54 BookmarkItem::~BookmarkItem(void)
55 {
56         delete __pBookmarkItemImpl;
57         __pBookmarkItemImpl = null;
58 }
59
60
61 String
62 BookmarkItem::GetTitle(void) const
63 {
64         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
65
66         return __pBookmarkItemImpl->GetTitle();
67 }
68
69
70 String
71 BookmarkItem::GetUrl(void) const
72 {
73         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
74
75         return __pBookmarkItemImpl->GetUrl();
76 }
77
78
79 Bitmap*
80 BookmarkItem::GetFaviconN(void) const
81 {
82         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
83
84         ClearLastResult();
85
86         Bitmap* pFavicon = __pBookmarkItemImpl->GetFaviconN();
87         SysTryReturn(NID_WEB, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
88
89         return pFavicon;
90 }
91
92
93 RecordId
94 BookmarkItem::GetParentFolderId(void) const
95 {
96         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
97
98         return __pBookmarkItemImpl->GetParentFolderId();
99 }
100
101
102 bool
103 BookmarkItem::IsFolder(void) const
104 {
105         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
106
107         return __pBookmarkItemImpl->IsFolder();
108 }
109
110
111 int
112 BookmarkItem::GetHashCode(void) const
113 {
114         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
115
116         return __pBookmarkItemImpl->GetHashCode();
117 }
118
119
120 bool
121 BookmarkItem::Equals(const Object& obj) const
122 {
123         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
124
125         const BookmarkItem* pRhs = dynamic_cast< const BookmarkItem* >(&obj);
126         if (pRhs == null)
127         {
128                 return false;
129         }
130
131         return __pBookmarkItemImpl->Equals(*pRhs->__pBookmarkItemImpl);
132 }
133
134
135 BookmarkItem&
136 BookmarkItem::operator =(const BookmarkItem& rhs)
137 {
138         if (&rhs == this)
139         {
140                 return *this;
141         }
142
143         Object::operator =(rhs);
144         _BookmarkItemImpl* pImpl = _BookmarkItemImpl::GetInstance(this);
145         if (pImpl)
146         {
147                 *pImpl = *_BookmarkItemImpl::GetInstance(&rhs);
148         }
149
150         return *this;
151 }
152
153
154 }} // Tizen::Web