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 FSclPerson.cpp
18 * @brief This is the implementation for Profile class.
20 * This file contains definitions of @e Person class.
23 #include <FBaseSysLog.h>
24 #include <FSclPerson.h>
25 #include <FSclPhoneNumber.h>
26 #include <FSclEmail.h>
27 #include <FSec_AccessController.h>
28 #include "FScl_PersonImpl.h"
30 using namespace Tizen::Base;
31 using namespace Tizen::Base::Collection;
32 using namespace Tizen::Security;
34 namespace Tizen { namespace Social
39 _PersonImpl* pPersonImpl = new (std::nothrow) _PersonImpl();
40 SysTryReturnVoidResult(NID_SCL, pPersonImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(GetLastResult()));
42 __pPersonImpl = pPersonImpl;
51 Person::Equals(const Object& rhs) const
53 const Person* pPerson = dynamic_cast<const Person*>(&rhs);
59 return __pPersonImpl->Equals(*pPerson->__pPersonImpl);;
63 Person::GetHashCode(void) const
65 return __pPersonImpl->GetHashCode();
69 Person::GetDisplayName(void) const
71 return __pPersonImpl->GetDisplayName();
75 Person::GetId(void) const
77 return __pPersonImpl->GetId();
81 Person::SetAsFavorite(bool isFavorite)
83 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
84 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
85 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
87 return __pPersonImpl->SetAsFavorite(isFavorite);
91 Person::IsFavorite(void) const
93 return __pPersonImpl->IsFavorite();
97 Person::GetThumbnailPath(void) const
99 return __pPersonImpl->GetThumbnailPath();
103 Person::GetRingtonePath(void) const
105 return __pPersonImpl->GetRingtonePath();
109 Person::HasPhoneNumber(void) const
111 return __pPersonImpl->HasPhoneNumber();
115 Person::HasEmail(void) const
117 return __pPersonImpl->HasEmail();
121 Person::GetAccountIdsN(void) const
123 return __pPersonImpl->GetAccountIdsN();
127 Person::SetAsPrimaryPhoneNumber(const PhoneNumber& phoneNumber)
129 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
130 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
131 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
133 return __pPersonImpl->SetAsPrimaryPhoneNumber(phoneNumber);
137 Person::SetAsPrimaryEmail(const Email& email)
139 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
140 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
141 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
143 return __pPersonImpl->SetAsPrimaryEmail(email);
147 Person::GetPrimaryPhoneNumber(void) const
149 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
150 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
151 SysTryReturn(NID_SCL, r == E_SUCCESS, PhoneNumber(), r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
153 return __pPersonImpl->GetPrimaryPhoneNumber();
157 Person::GetPrimaryEmail(void) const
159 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ);
160 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
161 SysTryReturn(NID_SCL, r == E_SUCCESS, Email(), r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
163 return __pPersonImpl->GetPrimaryEmail();