[N_SE-32914, 33582] Fixed priority converting codes
[framework/osp/social.git] / src / FSclCategory.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  * @file                FSclCategory.cpp
19  * @brief               This is the implementation for Category class.
20  *
21  * This file contains definitions of @e Category class.
22  */
23
24 #include <FBaseSysLog.h>
25 #include <FSclCategory.h>
26 #include "FScl_CategoryImpl.h"
27
28 using namespace Tizen::Base;
29 using namespace Tizen::Base::Collection;
30
31 namespace Tizen { namespace Social
32 {
33
34 Category::Category(void)
35         : Record(RECORD_TYPE_CATEGORY)
36 {
37         __pCategoryImpl = new (std::nothrow) _CategoryImpl();
38         SysTryReturnVoidResult(NID_SCL, __pCategoryImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
39 }
40
41 Category::Category(const Category& rhs)
42         : Record(rhs)
43 {
44         __pCategoryImpl = new (std::nothrow) _CategoryImpl(*rhs.__pCategoryImpl);
45         SysTryReturnVoidResult(NID_SCL, __pCategoryImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
46 }
47
48 Category::~Category(void)
49 {
50         delete __pCategoryImpl;
51 }
52
53 Category&
54 Category::operator =(const Category& rhs)
55 {
56         if (this == &rhs)
57         {
58                 return *this;
59         }
60
61         Record::operator =(rhs);
62
63         *__pCategoryImpl = *rhs.__pCategoryImpl;
64
65         return *this;
66 }
67
68 bool
69 Category::Equals(const Object& rhs) const
70 {
71         const Category* pCategory = dynamic_cast<const Category*>(&rhs);
72         if (pCategory == null)
73         {
74                 return false;
75         }
76
77         if (GetRecordId() == INVALID_RECORD_ID)
78         {
79                 return false;
80         }
81
82         if (GetRecordId() == pCategory->GetRecordId())
83         {
84                 return true;
85         }
86
87         return false;
88 }
89
90 int
91 Category::GetHashCode(void) const
92 {
93         return GetRecordId();
94 }
95
96 AddressbookId
97 Category::GetAddressbookId(void) const
98 {
99         return __pCategoryImpl->GetAddressbookId();
100 }
101
102 result
103 Category::AddMember(RecordId contactId)
104 {
105         result r = __pCategoryImpl->AddMember(contactId);
106         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
107
108         return E_SUCCESS;
109 }
110
111 int
112 Category::GetMemberCount(void) const
113 {
114         return __pCategoryImpl->GetMemberCount();
115 }
116
117 String
118 Category::GetName(void) const
119 {
120         return __pCategoryImpl->GetName();
121 }
122
123 bool
124 Category::HasMember(RecordId contactId) const
125 {
126         bool hasMember = __pCategoryImpl->HasMember(contactId);
127
128         result r = GetLastResult();
129         SysTryReturn(NID_SCL, !IsFailed(r), hasMember, r, "[%s] Propagating.", GetErrorMessage(r));
130
131         return hasMember;
132 }
133
134 result
135 Category::RemoveMember(RecordId contactId)
136 {
137         result r = __pCategoryImpl->RemoveMember(contactId);
138         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
139
140         return E_SUCCESS;
141 }
142
143 result
144 Category::SetName(const String& name)
145 {
146         result r = __pCategoryImpl->SetName(name);
147         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
148
149         return E_SUCCESS;
150 }
151
152 result
153 Category::SetRingtonePath(const String& filePath)
154 {
155         result r = __pCategoryImpl->SetRingtonePath(filePath);
156         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
157
158         return E_SUCCESS;
159 }
160
161 String
162 Category::GetRingtonePath(void) const
163 {
164         return __pCategoryImpl->GetRingtonePath();
165 }
166
167 result
168 Category::SetThumbnail(const String& filePath)
169 {
170         result r = __pCategoryImpl->SetThumbnail(filePath);
171         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
172
173         return E_SUCCESS;
174 }
175
176 String
177 Category::GetThumbnailPath(void) const
178 {
179         return __pCategoryImpl->GetThumbnailPath();
180 }
181
182 bool
183 Category::IsDefault(void) const
184 {
185         return __pCategoryImpl->IsDefault();
186 }
187
188 }} // Tizen::Social