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