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 FSclPerson.cpp
19 * @brief This is the implementation for Profile class.
21 * This file contains definitions of @e Person class.
24 #include <FBaseSysLog.h>
25 #include <FSclPerson.h>
26 #include <FSclPhoneNumber.h>
27 #include <FSclEmail.h>
28 #include <FSec_AccessController.h>
29 #include "FScl_PersonImpl.h"
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33 using namespace Tizen::Security;
35 namespace Tizen { namespace Social
40 _PersonImpl* pPersonImpl = new (std::nothrow) _PersonImpl();
41 SysTryReturnVoidResult(NID_SCL, pPersonImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(GetLastResult()));
43 __pPersonImpl = pPersonImpl;
52 Person::Equals(const Object& rhs) const
54 const Person* pPerson = dynamic_cast<const Person*>(&rhs);
60 return __pPersonImpl->Equals(*pPerson->__pPersonImpl);;
64 Person::GetHashCode(void) const
66 return __pPersonImpl->GetHashCode();
70 Person::GetDisplayName(void) const
72 return __pPersonImpl->GetDisplayName();
76 Person::GetId(void) const
78 return __pPersonImpl->GetId();
82 Person::SetAsFavorite(bool isFavorite)
84 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
85 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
86 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
88 return __pPersonImpl->SetAsFavorite(isFavorite);
92 Person::IsFavorite(void) const
94 return __pPersonImpl->IsFavorite();
98 Person::GetThumbnailPath(void) const
100 return __pPersonImpl->GetThumbnailPath();
104 Person::GetRingtonePath(void) const
106 return __pPersonImpl->GetRingtonePath();
110 Person::HasPhoneNumber(void) const
112 return __pPersonImpl->HasPhoneNumber();
116 Person::HasEmail(void) const
118 return __pPersonImpl->HasEmail();
122 Person::GetAccountIdsN(void) const
124 return __pPersonImpl->GetAccountIdsN();
128 Person::SetAsPrimaryPhoneNumber(const PhoneNumber& phoneNumber)
130 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
131 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
132 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
134 return __pPersonImpl->SetAsPrimaryPhoneNumber(phoneNumber);
138 Person::SetAsPrimaryEmail(const Email& email)
140 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
141 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
142 SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
144 return __pPersonImpl->SetAsPrimaryEmail(email);
148 Person::GetPrimaryPhoneNumber(void) const
150 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
151 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
152 SysTryReturn(NID_SCL, r == E_SUCCESS, PhoneNumber(), r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
154 return __pPersonImpl->GetPrimaryPhoneNumber();
158 Person::GetPrimaryEmail(void) const
160 result r = _AccessController::CheckUserPrivilege(_PRV_CONTACT_WRITE);
161 r = TransExceptionsExclusive(r, E_PRIVILEGE_DENIED, E_USER_NOT_CONSENTED);
162 SysTryReturn(NID_SCL, r == E_SUCCESS, Email(), r, "[%s] The application is not permitted to call this method.", GetErrorMessage(r));
164 return __pPersonImpl->GetPrimaryEmail();