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 <FSclContactAppLaunchData.h>
33 #include <FSclContact.h>
34 #include "FScl_ContactImpl.h"
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Graphics;
40 namespace Tizen { namespace Social
43 Contact::Contact(void)
44 : Record(RECORD_TYPE_CONTACT)
46 __pContactImpl = new (std::nothrow) _ContactImpl();
47 SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
50 Contact::Contact(const Contact& rhs)
53 __pContactImpl = new (std::nothrow) _ContactImpl(*rhs.__pContactImpl);
54 SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
57 Contact::~Contact(void)
59 delete __pContactImpl;
63 Contact::operator =(const Contact& rhs)
70 Record::operator=(rhs);
72 *__pContactImpl = *rhs.__pContactImpl;
78 Contact::Equals(const Object& rhs) const
80 const Contact* pContact = dynamic_cast<const Contact*>(&rhs);
86 if (GetRecordId() == INVALID_RECORD_ID)
91 if (GetRecordId() == pContact->GetRecordId())
100 Contact::GetHashCode(void) const
102 return GetRecordId();
106 Contact::GetPersonId(void) const
108 return __pContactImpl->GetPersonId();
112 Contact::GetAddressbookId(void) const
114 return __pContactImpl->GetAddressbookId();
118 Contact::GetThumbnailN(void) const
120 Bitmap* pBitmap = __pContactImpl->GetThumbnailN();
121 SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
127 Contact::GetThumbnailPath(void) const
129 return __pContactImpl->GetThumbnailPath();
133 Contact::SetThumbnail(const String& filePath)
135 result r = __pContactImpl->SetThumbnailPath(filePath);
136 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
142 Contact::GetValue(ContactPropertyId id, String& value) const
144 result r = __pContactImpl->GetValue(id, value);
145 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
151 Contact::GetValue(ContactPropertyId id, DateTime& value) const
153 result r = __pContactImpl->GetValue(id, value);
154 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
160 Contact::SetValue(ContactPropertyId id, const String& value)
162 result r = __pContactImpl->SetValue(id, value);
163 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
169 Contact::SetValue(ContactPropertyId id, const DateTime& value)
171 result r = __pContactImpl->SetValue(id, value);
172 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
178 Contact::AddNote(const String& note)
180 result r = __pContactImpl->AddNote(note);
181 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
187 Contact::AddNickname(const String& nickname)
189 result r = __pContactImpl->AddNickname(nickname);
190 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
196 Contact::AddPhoneNumber(const PhoneNumber& phoneNumber)
198 result r = __pContactImpl->AddPhoneNumber(phoneNumber);
199 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
205 Contact::AddEmail(const Email& email)
207 result r = __pContactImpl->AddEmail(email);
208 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
214 Contact::AddUrl(const Url& url)
216 result r = __pContactImpl->AddUrl(url);
217 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
223 Contact::AddAddress(const Address& address)
225 result r = __pContactImpl->AddAddress(address);
226 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
232 Contact::AddImAddress(const ImAddress& imAddress)
234 result r = __pContactImpl->AddImAddress(imAddress);
235 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
241 Contact::AddOrganization(const Organization& organization)
243 result r = __pContactImpl->AddOrganization(organization);
244 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
250 Contact::AddEvent(const ContactEvent& event)
252 result r = __pContactImpl->AddEvent(event);
253 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
259 Contact::AddRelationship(const Relationship& relationship)
261 result r = __pContactImpl->AddRelationship(relationship);
262 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
268 Contact::AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData)
270 result r = __pContactImpl->AddContactAppLaunchData(appLaunchData);
271 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
277 Contact::RemoveAt(ContactMultiPropertyId id, int index)
279 result r = __pContactImpl->RemoveAt(id, index);
280 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
286 Contact::GetValuesN(ContactMultiPropertyId id) const
288 IList* pList = __pContactImpl->GetValuesN(id);
289 SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
295 Contact::SetNoteAt(int index, const String& note)
297 result r = __pContactImpl->SetNoteAt(index, note);
298 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
304 Contact::SetNicknameAt(int index, const String& nickname)
306 result r = __pContactImpl->SetNicknameAt(index, nickname);
307 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
313 Contact::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
315 result r = __pContactImpl->SetPhoneNumberAt(index, phoneNumber);
316 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
322 Contact::SetEmailAt(int index, const Email& email)
324 result r = __pContactImpl->SetEmailAt(index, email);
325 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
331 Contact::SetEventAt(int index, const ContactEvent& event)
333 result r = __pContactImpl->SetEventAt(index, event);
334 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
340 Contact::SetOrganizationAt(int index, const Organization& organization)
342 result r = __pContactImpl->SetOrganizationAt(index, organization);
343 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
349 Contact::SetRelationshipAt(int index, const Relationship& relationship)
351 result r = __pContactImpl->SetRelationshipAt(index, relationship);
352 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
358 Contact::SetUrlAt(int index, const Url& url)
360 result r = __pContactImpl->SetUrlAt(index, url);
361 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
367 Contact::SetAddressAt(int index, const Address& address)
369 result r = __pContactImpl->SetAddressAt(index, address);
370 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
376 Contact::SetImAddressAt(int index, const ImAddress& imAddress)
378 result r = __pContactImpl->SetImAddressAt(index, imAddress);
379 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
385 Contact::SetContactAppLaunchDataAt(int index, const ContactAppLaunchData& appLaunchData)
387 result r = __pContactImpl->SetContactAppLaunchDataAt(index, appLaunchData);
388 SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
394 Contact::IsFavorite(void) const
396 return __pContactImpl->IsFavorite();
400 Contact::SetAsFavorite(bool isFavorite)
402 return __pContactImpl->SetAsFavorite(isFavorite);