Modify the spec file for secure log
[framework/osp/social.git] / src / FSclCategory.cpp
1 //
2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
3 //
4 // Licensed under the Apache License, Version 2.0 (the License);
5 // you may not use this file except in compliance with the License.
6 // You may obtain a copy of the License at
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
10 // Unless required by applicable law or agreed to in writing, software
11 // distributed under the License is distributed on an "AS IS" BASIS,
12 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 // See the License for the specific language governing permissions and
14 // limitations under the License.
15 //
16 /**
17  * @file                FSclCategory.cpp
18  * @brief               This is the implementation for Category class.
19  *
20  * This file contains definitions of @e Category class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FSclCategory.h>
25 #include "FScl_CategoryImpl.h"
26
27 using namespace Tizen::Base;
28 using namespace Tizen::Base::Collection;
29
30 namespace Tizen { namespace Social
31 {
32
33 Category::Category(void)
34         : Record(RECORD_TYPE_CATEGORY)
35 {
36         __pCategoryImpl = new (std::nothrow) _CategoryImpl();
37         SysTryReturnVoidResult(NID_SCL, __pCategoryImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
38 }
39
40 Category::Category(const Category& rhs)
41         : Record(rhs)
42 {
43         __pCategoryImpl = new (std::nothrow) _CategoryImpl(*rhs.__pCategoryImpl);
44         SysTryReturnVoidResult(NID_SCL, __pCategoryImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
45 }
46
47 Category::~Category(void)
48 {
49         delete __pCategoryImpl;
50 }
51
52 Category&
53 Category::operator =(const Category& rhs)
54 {
55         if (this == &rhs)
56         {
57                 return *this;
58         }
59
60         Record::operator =(rhs);
61
62         *__pCategoryImpl = *rhs.__pCategoryImpl;
63
64         return *this;
65 }
66
67 bool
68 Category::Equals(const Object& rhs) const
69 {
70         const Category* pCategory = dynamic_cast<const Category*>(&rhs);
71         if (pCategory == null)
72         {
73                 return false;
74         }
75
76         if (GetRecordId() == INVALID_RECORD_ID)
77         {
78                 return false;
79         }
80
81         if (GetRecordId() != pCategory->GetRecordId())
82         {
83                 return false;
84         }
85
86         return __pCategoryImpl->Equals(*pCategory->__pCategoryImpl);
87 }
88
89 int
90 Category::GetHashCode(void) const
91 {
92         return GetRecordId();
93 }
94
95 AddressbookId
96 Category::GetAddressbookId(void) const
97 {
98         return __pCategoryImpl->GetAddressbookId();
99 }
100
101 result
102 Category::AddMember(RecordId contactId)
103 {
104         result r = __pCategoryImpl->AddMember(contactId);
105         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
106
107         return E_SUCCESS;
108 }
109
110 int
111 Category::GetMemberCount(void) const
112 {
113         return __pCategoryImpl->GetMemberCount();
114 }
115
116 String
117 Category::GetName(void) const
118 {
119         return __pCategoryImpl->GetName();
120 }
121
122 bool
123 Category::HasMember(RecordId contactId) const
124 {
125         bool hasMember = __pCategoryImpl->HasMember(contactId);
126
127         result r = GetLastResult();
128         SysTryReturn(NID_SCL, !IsFailed(r), hasMember, r, "[%s] Propagating.", GetErrorMessage(r));
129
130         return hasMember;
131 }
132
133 result
134 Category::RemoveMember(RecordId contactId)
135 {
136         result r = __pCategoryImpl->RemoveMember(contactId);
137         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
138
139         return E_SUCCESS;
140 }
141
142 result
143 Category::SetName(const String& name)
144 {
145         result r = __pCategoryImpl->SetName(name);
146         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
147
148         return E_SUCCESS;
149 }
150
151 result
152 Category::SetRingtonePath(const String& filePath)
153 {
154         result r = __pCategoryImpl->SetRingtonePath(filePath);
155         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
156
157         return E_SUCCESS;
158 }
159
160 String
161 Category::GetRingtonePath(void) const
162 {
163         return __pCategoryImpl->GetRingtonePath();
164 }
165
166 result
167 Category::SetThumbnail(const String& filePath)
168 {
169         result r = __pCategoryImpl->SetThumbnail(filePath);
170         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
171
172         return E_SUCCESS;
173 }
174
175 String
176 Category::GetThumbnailPath(void) const
177 {
178         return __pCategoryImpl->GetThumbnailPath();
179 }
180
181 bool
182 Category::IsDefault(void) const
183 {
184         return __pCategoryImpl->IsDefault();
185 }
186
187 bool
188 Category::IsReadOnly(void) const
189 {
190         return __pCategoryImpl->IsReadOnly();
191 }
192
193 IMap*
194 Category::GetExtraDataN(void) const
195 {
196         return __pCategoryImpl->GetExtraDataN();
197 }
198
199 }} // Tizen::Social