Modify the spec file for secure log
[framework/osp/social.git] / src / FSclAccount.cpp
1 //
2 // Copyright (c) 2013 Samsung Electronics Co., Ltd.
3 //
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
7 //
8 //     http://www.apache.org/licenses/LICENSE-2.0
9 //
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.
15 //
16 /**
17  * @file                FSclAccount.cpp
18  * @brief               This is the implementation for Account class.
19  *
20  * This file contains definitions of @e Account class.
21  */
22
23 #include <new>
24 #include <FBaseColIMap.h>
25 #include <FBaseResult.h>
26 #include <FBaseString.h>
27 #include <FBaseSysLog.h>
28 #include <FSclAccount.h>
29 #include "FScl_AccountImpl.h"
30
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33
34 namespace Tizen { namespace Social
35 {
36
37 Account::Account(const String& userName)
38 {
39         __pAccountImpl = new (std::nothrow) _AccountImpl(userName);
40         SysTryReturnVoidResult(NID_SCL, __pAccountImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
41 }
42
43 Account::Account(const Account& rhs)
44 {
45         __pAccountImpl = new (std::nothrow) _AccountImpl(*rhs.__pAccountImpl);
46         SysTryReturnVoidResult(NID_SCL, __pAccountImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
47 }
48
49 Account::~Account(void)
50 {
51         delete __pAccountImpl;
52 }
53
54 Account&
55 Account::operator =(const Account& rhs)
56 {
57         if (this == &rhs)
58         {
59                 return *this;
60         }
61
62         *__pAccountImpl = *rhs.__pAccountImpl;
63
64         return *this;
65 }
66
67 bool
68 Account::Equals(const Object& rhs) const
69 {
70         const Account* pAccount = dynamic_cast<const Account*> (&rhs);
71
72         if (pAccount == null)
73         {
74                 return false;
75         }
76
77         return __pAccountImpl->Equals(*pAccount->__pAccountImpl);
78 }
79
80 int
81 Account::GetHashCode(void) const
82 {
83         return __pAccountImpl->GetHashCode();
84 }
85
86 AccountId
87 Account::GetId(void) const
88 {
89         return __pAccountImpl->GetId();
90 }
91
92 AccountProvider
93 Account::GetAccountProvider(void) const
94 {
95         return __pAccountImpl->GetAccountProvider();
96 }
97
98 String
99 Account::GetUserName(void) const
100 {
101         return __pAccountImpl->GetUserName();
102 }
103
104 IMap*
105 Account::GetExtendedDataN(void) const
106 {
107         return __pAccountImpl->GetExtendedDataN();
108 }
109
110 result
111 Account::SetUserName(const String& userName)
112 {
113         result r = __pAccountImpl->SetUserName(userName);
114         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
115
116         return E_SUCCESS;
117 }
118
119 result
120 Account::SetExtendedData(const String& key, const String& value)
121 {
122         result r = __pAccountImpl->SetExtendedData(key, value);
123         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
124
125         return E_SUCCESS;
126 }
127
128 }} //Tizen::Social