merge with master
[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         return __pBookmarkItemImpl->GetFaviconN();
85 }
86
87
88 RecordId
89 BookmarkItem::GetParentFolderId(void) const
90 {
91         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
92
93         return __pBookmarkItemImpl->GetParentFolderId();
94 }
95
96
97 bool
98 BookmarkItem::IsFolder(void) const
99 {
100         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
101
102         return __pBookmarkItemImpl->IsFolder();
103 }
104
105
106 int
107 BookmarkItem::GetHashCode(void) const
108 {
109         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
110
111         return __pBookmarkItemImpl->GetHashCode();
112 }
113
114
115 bool
116 BookmarkItem::Equals(const Object& obj) const
117 {
118         SysAssertf(__pBookmarkItemImpl != null, "Not yet constructed. Construct() should be called before use.");
119
120         const BookmarkItem* pRhs = dynamic_cast< const BookmarkItem* >(&obj);
121         if (pRhs == null)
122         {
123                 return false;
124         }
125
126         return __pBookmarkItemImpl->Equals(*pRhs->__pBookmarkItemImpl);
127 }
128
129
130 BookmarkItem&
131 BookmarkItem::operator =(const BookmarkItem& rhs)
132 {
133         if (&rhs == this)
134         {
135                 return *this;
136         }
137
138         Object::operator =(rhs);
139         _BookmarkItemImpl* pImpl = _BookmarkItemImpl::GetInstance(this);
140         if (pImpl)
141         {
142                 *pImpl = *_BookmarkItemImpl::GetInstance(&rhs);
143         }
144
145         return *this;
146 }
147
148
149 }} // Tizen::Web