Fix for CompatTC Fail
[framework/osp/social.git] / src / FSclUserProfile.cpp
1 //
2 // Copyright (c) 2013 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                FSclUserProfile.cpp
18  * @brief               This is the implementation for Profile class.
19  *
20  * This file contains definitions of @e UserProfile class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FSclAddress.h>
25 #include <FSclPhoneNumber.h>
26 #include <FSclEmail.h>
27 #include <FSclUrl.h>
28 #include <FSclImAddress.h>
29 #include <FSclOrganization.h>
30 #include <FSclContactEvent.h>
31 #include <FSclRelationship.h>
32 #include <FSclUserProfile.h>
33 #include "FScl_UserProfileImpl.h"
34
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Graphics;
38
39 namespace Tizen { namespace Social
40 {
41
42 UserProfile::UserProfile(void)
43 {
44         __pUserProfileImpl = new (std::nothrow) _UserProfileImpl();
45         SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
46 }
47
48 UserProfile::UserProfile(const UserProfile& rhs)
49 {
50         __pUserProfileImpl = new (std::nothrow) _UserProfileImpl(*rhs.__pUserProfileImpl);
51         SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
52 }
53
54 UserProfile::~UserProfile(void)
55 {
56         delete __pUserProfileImpl;
57 }
58
59 UserProfile&
60 UserProfile::operator =(const UserProfile& rhs)
61 {
62         if (this == &rhs)
63         {
64                 return *this;
65         }
66
67         *__pUserProfileImpl = *rhs.__pUserProfileImpl;
68
69         return *this;
70 }
71
72 bool
73 UserProfile::Equals(const Object& rhs) const
74 {
75         const UserProfile* pUserProfile = dynamic_cast<const UserProfile*>(&rhs);
76         if (pUserProfile == null)
77         {
78                 return false;
79         }
80
81         return __pUserProfileImpl->Equals(*_UserProfileImpl::GetInstance(*pUserProfile));
82 }
83
84 int
85 UserProfile::GetHashCode(void) const
86 {
87         return __pUserProfileImpl->GetHashCode();
88 }
89
90 AddressbookId
91 UserProfile::GetAddressbookId(void) const
92 {
93         return __pUserProfileImpl->GetAddressbookId();
94 }
95
96 String
97 UserProfile::GetThumbnailPath(void) const
98 {
99         return  __pUserProfileImpl->GetThumbnailPath();
100 }
101
102 result
103 UserProfile::SetThumbnail(const String& filePath)
104 {
105         result r = __pUserProfileImpl->SetThumbnail(filePath);
106         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
107
108         return E_SUCCESS;
109 }
110
111 String
112 UserProfile::GetValue(UserProfilePropertyId id) const
113 {
114         return __pUserProfileImpl->GetValue(id);
115 }
116
117 result
118 UserProfile::SetValue(UserProfilePropertyId id, const String& value)
119 {
120         result r = __pUserProfileImpl->SetValue(id, value);
121         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
122
123         return E_SUCCESS;
124 }
125
126 result
127 UserProfile::AddNote(const String& note)
128 {
129         result r = __pUserProfileImpl->AddNote(note);
130         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
131
132         return E_SUCCESS;
133 }
134
135 result
136 UserProfile::AddNickname(const String& nickname)
137 {
138         result r = __pUserProfileImpl->AddNickname(nickname);
139         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
140
141         return E_SUCCESS;
142 }
143
144 result
145 UserProfile::AddPhoneNumber(const PhoneNumber& phoneNumber)
146 {
147         result r = __pUserProfileImpl->AddPhoneNumber(phoneNumber);
148         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
149
150         return E_SUCCESS;
151 }
152
153 result
154 UserProfile::AddEmail(const Email& email)
155 {
156         result r = __pUserProfileImpl->AddEmail(email);
157         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
158
159         return E_SUCCESS;
160 }
161
162 result
163 UserProfile::AddUrl(const Url& url)
164 {
165         result r = __pUserProfileImpl->AddUrl(url);
166         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
167
168         return E_SUCCESS;
169 }
170
171 result
172 UserProfile::AddAddress(const Address& address)
173 {
174         result r = __pUserProfileImpl->AddAddress(address);
175         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
176
177         return E_SUCCESS;
178 }
179
180 result
181 UserProfile::AddImAddress(const ImAddress& imAddress)
182 {
183         result r = __pUserProfileImpl->AddImAddress(imAddress);
184         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
185
186         return E_SUCCESS;
187 }
188
189 result
190 UserProfile::AddOrganization(const Organization& organization)
191 {
192         result r = __pUserProfileImpl->AddOrganization(organization);
193         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
194
195         return E_SUCCESS;
196 }
197
198 result
199 UserProfile::AddEvent(const ContactEvent& event)
200 {
201         result r = __pUserProfileImpl->AddEvent(event);
202         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
203
204         return E_SUCCESS;
205 }
206
207 result
208 UserProfile::AddRelationship(const Relationship& relationship)
209 {
210         result r = __pUserProfileImpl->AddRelationship(relationship);
211         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
212
213         return E_SUCCESS;
214 }
215
216 result
217 UserProfile::RemoveAt(UserProfileMultiPropertyId id, int index)
218 {
219         result r = __pUserProfileImpl->RemoveAt(id, index);
220         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
221
222         return E_SUCCESS;
223 }
224
225 IList*
226 UserProfile::GetValuesN(UserProfileMultiPropertyId id) const
227 {
228         IList* pList = __pUserProfileImpl->GetValuesN(id);
229         SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
230
231         return pList;
232 }
233
234 result
235 UserProfile::SetNoteAt(int index, const String& note)
236 {
237         result r = __pUserProfileImpl->SetNoteAt(index, note);
238         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
239
240         return E_SUCCESS;
241 }
242
243 result
244 UserProfile::SetNicknameAt(int index, const String& nickname)
245 {
246         result r = __pUserProfileImpl->SetNicknameAt(index, nickname);
247         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
248
249         return E_SUCCESS;
250 }
251
252 result
253 UserProfile::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
254 {
255         result r = __pUserProfileImpl->SetPhoneNumberAt(index, phoneNumber);
256         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
257
258         return E_SUCCESS;
259 }
260
261 result
262 UserProfile::SetEmailAt(int index, const Email& email)
263 {
264         result r = __pUserProfileImpl->SetEmailAt(index, email);
265         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
266
267         return E_SUCCESS;
268 }
269
270 result
271 UserProfile::SetEventAt(int index, const ContactEvent& event)
272 {
273         result r = __pUserProfileImpl->SetEventAt(index, event);
274         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
275
276         return E_SUCCESS;
277 }
278
279 result
280 UserProfile::SetOrganizationAt(int index, const Organization& organization)
281 {
282         result r = __pUserProfileImpl->SetOrganizationAt(index, organization);
283         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
284
285         return E_SUCCESS;
286 }
287
288 result
289 UserProfile::SetUrlAt(int index, const Url& url)
290 {
291         result r = __pUserProfileImpl->SetUrlAt(index, url);
292         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
293
294         return E_SUCCESS;
295 }
296
297 result
298 UserProfile::SetAddressAt(int index, const Address& address)
299 {
300         result r = __pUserProfileImpl->SetAddressAt(index, address);
301         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
302
303         return E_SUCCESS;
304 }
305
306 result
307 UserProfile::SetImAddressAt(int index, const ImAddress& imAddress)
308 {
309         result r = __pUserProfileImpl->SetImAddressAt(index, imAddress);
310         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
311
312         return E_SUCCESS;
313 }
314
315 result
316 UserProfile::SetRelationshipAt(int index, const Relationship& relationship)
317 {
318         result r = __pUserProfileImpl->SetRelationshipAt(index, relationship);
319         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
320
321         return E_SUCCESS;
322 }
323
324 }} // Tizen::Social