2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
17 * @file FSclUserProfile.cpp
18 * @brief This is the implementation for Profile class.
20 * This file contains definitions of @e UserProfile class.
23 #include <FBaseSysLog.h>
24 #include <FSclAddress.h>
25 #include <FSclPhoneNumber.h>
26 #include <FSclEmail.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"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Graphics;
39 namespace Tizen { namespace Social
42 UserProfile::UserProfile(void)
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));
48 UserProfile::UserProfile(const UserProfile& rhs)
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));
54 UserProfile::~UserProfile(void)
56 delete __pUserProfileImpl;
60 UserProfile::operator =(const UserProfile& rhs)
67 *__pUserProfileImpl = *rhs.__pUserProfileImpl;
73 UserProfile::Equals(const Object& rhs) const
75 const UserProfile* pUserProfile = dynamic_cast<const UserProfile*>(&rhs);
76 if (pUserProfile == null)
81 return __pUserProfileImpl->Equals(*_UserProfileImpl::GetInstance(*pUserProfile));
85 UserProfile::GetHashCode(void) const
87 return __pUserProfileImpl->GetHashCode();
91 UserProfile::GetAddressbookId(void) const
93 return __pUserProfileImpl->GetAddressbookId();
97 UserProfile::GetThumbnailPath(void) const
99 return __pUserProfileImpl->GetThumbnailPath();
103 UserProfile::SetThumbnail(const String& filePath)
105 result r = __pUserProfileImpl->SetThumbnail(filePath);
106 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
112 UserProfile::GetValue(UserProfilePropertyId id) const
114 return __pUserProfileImpl->GetValue(id);
118 UserProfile::SetValue(UserProfilePropertyId id, const String& value)
120 result r = __pUserProfileImpl->SetValue(id, value);
121 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
127 UserProfile::AddNote(const String& note)
129 result r = __pUserProfileImpl->AddNote(note);
130 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
136 UserProfile::AddNickname(const String& nickname)
138 result r = __pUserProfileImpl->AddNickname(nickname);
139 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
145 UserProfile::AddPhoneNumber(const PhoneNumber& phoneNumber)
147 result r = __pUserProfileImpl->AddPhoneNumber(phoneNumber);
148 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
154 UserProfile::AddEmail(const Email& email)
156 result r = __pUserProfileImpl->AddEmail(email);
157 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
163 UserProfile::AddUrl(const Url& url)
165 result r = __pUserProfileImpl->AddUrl(url);
166 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
172 UserProfile::AddAddress(const Address& address)
174 result r = __pUserProfileImpl->AddAddress(address);
175 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
181 UserProfile::AddImAddress(const ImAddress& imAddress)
183 result r = __pUserProfileImpl->AddImAddress(imAddress);
184 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
190 UserProfile::AddOrganization(const Organization& organization)
192 result r = __pUserProfileImpl->AddOrganization(organization);
193 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
199 UserProfile::AddEvent(const ContactEvent& event)
201 result r = __pUserProfileImpl->AddEvent(event);
202 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
208 UserProfile::AddRelationship(const Relationship& relationship)
210 result r = __pUserProfileImpl->AddRelationship(relationship);
211 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
217 UserProfile::RemoveAt(UserProfileMultiPropertyId id, int index)
219 result r = __pUserProfileImpl->RemoveAt(id, index);
220 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
226 UserProfile::GetValuesN(UserProfileMultiPropertyId id) const
228 IList* pList = __pUserProfileImpl->GetValuesN(id);
229 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
235 UserProfile::SetNoteAt(int index, const String& note)
237 result r = __pUserProfileImpl->SetNoteAt(index, note);
238 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
244 UserProfile::SetNicknameAt(int index, const String& nickname)
246 result r = __pUserProfileImpl->SetNicknameAt(index, nickname);
247 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
253 UserProfile::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
255 result r = __pUserProfileImpl->SetPhoneNumberAt(index, phoneNumber);
256 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
262 UserProfile::SetEmailAt(int index, const Email& email)
264 result r = __pUserProfileImpl->SetEmailAt(index, email);
265 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
271 UserProfile::SetEventAt(int index, const ContactEvent& event)
273 result r = __pUserProfileImpl->SetEventAt(index, event);
274 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
280 UserProfile::SetOrganizationAt(int index, const Organization& organization)
282 result r = __pUserProfileImpl->SetOrganizationAt(index, organization);
283 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
289 UserProfile::SetUrlAt(int index, const Url& url)
291 result r = __pUserProfileImpl->SetUrlAt(index, url);
292 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
298 UserProfile::SetAddressAt(int index, const Address& address)
300 result r = __pUserProfileImpl->SetAddressAt(index, address);
301 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
307 UserProfile::SetImAddressAt(int index, const ImAddress& imAddress)
309 result r = __pUserProfileImpl->SetImAddressAt(index, imAddress);
310 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
316 UserProfile::SetRelationshipAt(int index, const Relationship& relationship)
318 result r = __pUserProfileImpl->SetRelationshipAt(index, relationship);
319 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));