2 // Open Service Platform
3 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
9 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @file FSclUserProfile.cpp
19 * @brief This is the implementation for Profile class.
21 * This file contains definitions of @e UserProfile class.
24 #include <FBaseSysLog.h>
25 #include <FSclAddress.h>
26 #include <FSclPhoneNumber.h>
27 #include <FSclEmail.h>
29 #include <FSclImAddress.h>
30 #include <FSclOrganization.h>
31 #include <FSclContactEvent.h>
32 #include <FSclRelationship.h>
33 #include <FSclUserProfile.h>
34 #include "FScl_UserProfileImpl.h"
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Graphics;
40 namespace Tizen { namespace Social
43 UserProfile::UserProfile(void)
45 __pUserProfileImpl = new (std::nothrow) _UserProfileImpl();
46 SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
49 UserProfile::UserProfile(const UserProfile& rhs)
51 __pUserProfileImpl = new (std::nothrow) _UserProfileImpl(*rhs.__pUserProfileImpl);
52 SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
55 UserProfile::~UserProfile(void)
57 delete __pUserProfileImpl;
61 UserProfile::operator =(const UserProfile& rhs)
68 *__pUserProfileImpl = *rhs.__pUserProfileImpl;
74 UserProfile::Equals(const Object& rhs) const
76 const UserProfile* pUserProfile = dynamic_cast<const UserProfile*>(&rhs);
77 if (pUserProfile == null)
82 return __pUserProfileImpl->Equals(*_UserProfileImpl::GetInstance(*pUserProfile));
86 UserProfile::GetHashCode(void) const
88 return __pUserProfileImpl->GetHashCode();
92 UserProfile::GetAddressbookId(void) const
94 return __pUserProfileImpl->GetAddressbookId();
98 UserProfile::GetThumbnailPath(void) const
100 return __pUserProfileImpl->GetThumbnailPath();
104 UserProfile::SetThumbnail(const String& filePath)
106 result r = __pUserProfileImpl->SetThumbnail(filePath);
107 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
113 UserProfile::GetValue(UserProfilePropertyId id) const
115 return __pUserProfileImpl->GetValue(id);
119 UserProfile::SetValue(UserProfilePropertyId id, const String& value)
121 result r = __pUserProfileImpl->SetValue(id, value);
122 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
128 UserProfile::AddNote(const String& note)
130 result r = __pUserProfileImpl->AddNote(note);
131 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
137 UserProfile::AddNickname(const String& nickname)
139 result r = __pUserProfileImpl->AddNickname(nickname);
140 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
146 UserProfile::AddPhoneNumber(const PhoneNumber& phoneNumber)
148 result r = __pUserProfileImpl->AddPhoneNumber(phoneNumber);
149 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
155 UserProfile::AddEmail(const Email& email)
157 result r = __pUserProfileImpl->AddEmail(email);
158 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
164 UserProfile::AddUrl(const Url& url)
166 result r = __pUserProfileImpl->AddUrl(url);
167 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
173 UserProfile::AddAddress(const Address& address)
175 result r = __pUserProfileImpl->AddAddress(address);
176 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
182 UserProfile::AddImAddress(const ImAddress& imAddress)
184 result r = __pUserProfileImpl->AddImAddress(imAddress);
185 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
191 UserProfile::AddOrganization(const Organization& organization)
193 result r = __pUserProfileImpl->AddOrganization(organization);
194 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
200 UserProfile::AddEvent(const ContactEvent& event)
202 result r = __pUserProfileImpl->AddEvent(event);
203 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
209 UserProfile::AddRelationship(const Relationship& relationship)
211 result r = __pUserProfileImpl->AddRelationship(relationship);
212 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
218 UserProfile::RemoveAt(UserProfileMultiPropertyId id, int index)
220 result r = __pUserProfileImpl->RemoveAt(id, index);
221 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
227 UserProfile::GetValuesN(UserProfileMultiPropertyId id) const
229 IList* pList = __pUserProfileImpl->GetValuesN(id);
230 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
236 UserProfile::SetNoteAt(int index, const String& note)
238 result r = __pUserProfileImpl->SetNoteAt(index, note);
239 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
245 UserProfile::SetNicknameAt(int index, const String& nickname)
247 result r = __pUserProfileImpl->SetNicknameAt(index, nickname);
248 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
254 UserProfile::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
256 result r = __pUserProfileImpl->SetPhoneNumberAt(index, phoneNumber);
257 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
263 UserProfile::SetEmailAt(int index, const Email& email)
265 result r = __pUserProfileImpl->SetEmailAt(index, email);
266 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
272 UserProfile::SetEventAt(int index, const ContactEvent& event)
274 result r = __pUserProfileImpl->SetEventAt(index, event);
275 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
281 UserProfile::SetOrganizationAt(int index, const Organization& organization)
283 result r = __pUserProfileImpl->SetOrganizationAt(index, organization);
284 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
290 UserProfile::SetUrlAt(int index, const Url& url)
292 result r = __pUserProfileImpl->SetUrlAt(index, url);
293 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
299 UserProfile::SetAddressAt(int index, const Address& address)
301 result r = __pUserProfileImpl->SetAddressAt(index, address);
302 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
308 UserProfile::SetImAddressAt(int index, const ImAddress& imAddress)
310 result r = __pUserProfileImpl->SetImAddressAt(index, imAddress);
311 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
317 UserProfile::SetRelationshipAt(int index, const Relationship& relationship)
319 result r = __pUserProfileImpl->SetRelationshipAt(index, relationship);
320 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));