2 // Copyright (c) 2012 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 FSclContact.cpp
18 * @brief This is the implementation for Profile class.
20 * This file contains definitions of @e Contact 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 <FSclContact.h>
33 #include "FScl_ContactImpl.h"
35 using namespace Tizen::Base;
36 using namespace Tizen::Base::Collection;
37 using namespace Tizen::Graphics;
39 namespace Tizen { namespace Social
42 Contact::Contact(void)
43 : Record(RECORD_TYPE_CONTACT)
45 __pContactImpl = new (std::nothrow) _ContactImpl();
46 SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
49 Contact::Contact(const Contact& rhs)
52 __pContactImpl = new (std::nothrow) _ContactImpl(*rhs.__pContactImpl);
53 SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
56 Contact::~Contact(void)
58 delete __pContactImpl;
62 Contact::operator =(const Contact& rhs)
69 Record::operator=(rhs);
71 *__pContactImpl = *rhs.__pContactImpl;
77 Contact::Equals(const Object& rhs) const
79 const Contact* pContact = dynamic_cast<const Contact*>(&rhs);
85 if (GetRecordId() == INVALID_RECORD_ID)
90 if (GetRecordId() == pContact->GetRecordId())
99 Contact::GetHashCode(void) const
101 return GetRecordId();
105 Contact::GetPersonId(void) const
107 return __pContactImpl->GetPersonId();
111 Contact::GetAddressbookId(void) const
113 return __pContactImpl->GetAddressbookId();
117 Contact::GetThumbnailN(void) const
119 Bitmap* pBitmap = __pContactImpl->GetThumbnailN();
120 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
126 Contact::GetThumbnailPath(void) const
128 return __pContactImpl->GetThumbnailPath();
132 Contact::SetThumbnail(const String& filePath)
134 result r = __pContactImpl->SetThumbnailPath(filePath);
135 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
141 Contact::GetValue(ContactPropertyId id, String& value) const
143 result r = __pContactImpl->GetValue(id, value);
144 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
150 Contact::GetValue(ContactPropertyId id, DateTime& value) const
152 result r = __pContactImpl->GetValue(id, value);
153 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
159 Contact::SetValue(ContactPropertyId id, const String& value)
161 result r = __pContactImpl->SetValue(id, value);
162 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
168 Contact::SetValue(ContactPropertyId id, const DateTime& value)
170 result r = __pContactImpl->SetValue(id, value);
171 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
177 Contact::AddNote(const String& note)
179 result r = __pContactImpl->AddNote(note);
180 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
186 Contact::AddNickname(const String& nickname)
188 result r = __pContactImpl->AddNickname(nickname);
189 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
195 Contact::AddPhoneNumber(const PhoneNumber& phoneNumber)
197 result r = __pContactImpl->AddPhoneNumber(phoneNumber);
198 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
204 Contact::AddEmail(const Email& email)
206 result r = __pContactImpl->AddEmail(email);
207 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
213 Contact::AddUrl(const Url& url)
215 result r = __pContactImpl->AddUrl(url);
216 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
222 Contact::AddAddress(const Address& address)
224 result r = __pContactImpl->AddAddress(address);
225 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
231 Contact::AddImAddress(const ImAddress& imAddress)
233 result r = __pContactImpl->AddImAddress(imAddress);
234 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
240 Contact::AddOrganization(const Organization& organization)
242 result r = __pContactImpl->AddOrganization(organization);
243 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
249 Contact::AddEvent(const ContactEvent& event)
251 result r = __pContactImpl->AddEvent(event);
252 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
258 Contact::AddRelationship(const Relationship& relationship)
260 result r = __pContactImpl->AddRelationship(relationship);
261 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
267 Contact::RemoveAt(ContactMultiPropertyId id, int index)
269 result r = __pContactImpl->RemoveAt(id, index);
270 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
276 Contact::GetValuesN(ContactMultiPropertyId id) const
278 IList* pList = __pContactImpl->GetValuesN(id);
279 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
285 Contact::SetNoteAt(int index, const String& note)
287 result r = __pContactImpl->SetNoteAt(index, note);
288 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
294 Contact::SetNicknameAt(int index, const String& nickname)
296 result r = __pContactImpl->SetNicknameAt(index, nickname);
297 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
303 Contact::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
305 result r = __pContactImpl->SetPhoneNumberAt(index, phoneNumber);
306 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
312 Contact::SetEmailAt(int index, const Email& email)
314 result r = __pContactImpl->SetEmailAt(index, email);
315 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
321 Contact::SetEventAt(int index, const ContactEvent& event)
323 result r = __pContactImpl->SetEventAt(index, event);
324 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
330 Contact::SetOrganizationAt(int index, const Organization& organization)
332 result r = __pContactImpl->SetOrganizationAt(index, organization);
333 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
339 Contact::SetRelationshipAt(int index, const Relationship& relationship)
341 result r = __pContactImpl->SetRelationshipAt(index, relationship);
342 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
348 Contact::SetUrlAt(int index, const Url& url)
350 result r = __pContactImpl->SetUrlAt(index, url);
351 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
357 Contact::SetAddressAt(int index, const Address& address)
359 result r = __pContactImpl->SetAddressAt(index, address);
360 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
366 Contact::SetImAddressAt(int index, const ImAddress& imAddress)
368 result r = __pContactImpl->SetImAddressAt(index, imAddress);
369 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
375 Contact::IsFavorite(void) const
377 return __pContactImpl->IsFavorite();
381 Contact::SetAsFavorite(bool isFavorite)
383 return __pContactImpl->SetAsFavorite(isFavorite);