fix exception for CreateAddressbookN()
[framework/osp/social.git] / src / FScl_ContactChangeInfoImpl.cpp
1 //
2 // Open Service Platform
3 // Copyright (c) 2012 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                FScl_ContactChangeInfoImpl.cpp
19  * @brief               This is the implementation for _ContactChangeInfoImpl class.
20  *
21  * This file contains definitions of @e _ContactChangeInfoImpl class.
22  */
23
24 #include <new>
25 #include <FBaseResult.h>
26 #include <FSclContactChangeInfo.h>
27 #include <FBaseSysLog.h>
28 #include "FScl_RecordImpl.h"
29 #include "FScl_ContactChangeInfoImpl.h"
30
31 using namespace Tizen::Base;
32 using namespace Tizen::Base::Collection;
33
34 namespace Tizen { namespace Social
35 {
36
37 _ContactChangeInfoImpl::_ContactChangeInfoImpl(void)
38         : __contactId(INVALID_RECORD_ID)
39         , __addressbookId(INVALID_ADDRESSBOOK_ID)
40         , __version(0)
41         , __changeType(RECORD_CHANGE_TYPE_ADDED)
42         , __isThumbnailChanged(false)
43 {
44         // empty body
45 }
46
47 _ContactChangeInfoImpl::_ContactChangeInfoImpl(const _ContactChangeInfoImpl& rhs)
48 {
49         __contactId = rhs.__contactId;
50         __addressbookId = rhs.__addressbookId;
51         __version = rhs.__version;
52         __changeType = rhs.__changeType;
53         __isThumbnailChanged = rhs.__isThumbnailChanged;
54 }
55
56 _ContactChangeInfoImpl::~_ContactChangeInfoImpl(void)
57 {
58         // empty body
59 }
60
61 _ContactChangeInfoImpl&
62 _ContactChangeInfoImpl::operator =(const _ContactChangeInfoImpl& rhs)
63 {
64         if (this == &rhs)
65         {
66                 return *this;
67         }
68
69         __contactId = rhs.__contactId;
70         __addressbookId = rhs.__addressbookId;
71         __version = rhs.__version;
72         __changeType = rhs.__changeType;
73         __isThumbnailChanged = rhs.__isThumbnailChanged;
74
75         return *this;
76 }
77
78 bool
79 _ContactChangeInfoImpl::operator ==(const _ContactChangeInfoImpl& rhs) const
80 {
81         if (__contactId != rhs.__contactId)
82         {
83                 return false;
84         }
85
86         if (__addressbookId != rhs.__addressbookId)
87         {
88                 return false;
89         }
90
91         if (__version != rhs.__version)
92         {
93                 return false;
94         }
95
96         if (__changeType != rhs.__changeType)
97         {
98                 return false;
99         }
100
101         if (__isThumbnailChanged != rhs.__isThumbnailChanged)
102         {
103                 return false;
104         }
105
106
107         return true;
108 }
109
110
111 bool
112 _ContactChangeInfoImpl::Equals(const Object& rhs) const
113 {
114         const _ContactChangeInfoImpl* pContactChangeInfoImpl = dynamic_cast<const _ContactChangeInfoImpl*>(&rhs);
115
116         if (pContactChangeInfoImpl == null)
117         {
118                 return false;
119         }
120
121         return *this == *pContactChangeInfoImpl;
122 }
123
124 int
125 _ContactChangeInfoImpl::GetHashCode(void) const
126 {
127         int hashCode = 0;
128
129         hashCode = __contactId;
130         hashCode += __addressbookId;
131         hashCode += __version;
132         hashCode += __changeType;
133         hashCode += __isThumbnailChanged;
134
135         return hashCode;
136 }
137
138 AddressbookId
139 _ContactChangeInfoImpl::GetAddressbookId(void) const
140 {
141         return __addressbookId;
142 }
143
144 void
145 _ContactChangeInfoImpl::SetAddressbookId(AddressbookId addressbookId)
146 {
147         __addressbookId = addressbookId;
148 }
149
150 RecordId
151 _ContactChangeInfoImpl::GetContactId(void) const
152 {
153         return __contactId;
154 }
155
156 int
157 _ContactChangeInfoImpl::GetVersion(void) const
158 {
159         return __version;
160 }
161
162 RecordChangeType
163 _ContactChangeInfoImpl::GetChangeType(void) const
164 {
165         return __changeType;
166 }
167
168 void
169 _ContactChangeInfoImpl::SetContactId(RecordId contactId)
170 {
171         __contactId = contactId;
172 }
173
174 void
175 _ContactChangeInfoImpl::SetVersion(int version)
176 {
177         __version = version;
178 }
179
180 void
181 _ContactChangeInfoImpl::SetChangeType(RecordChangeType changeType)
182 {
183         __changeType = changeType;
184 }
185
186 bool
187 _ContactChangeInfoImpl::IsThumbnailChanged(void) const
188 {
189         return __isThumbnailChanged;
190 }
191
192 void
193 _ContactChangeInfoImpl::SetThumbnailChangeStatus(bool isChanged)
194 {
195         __isThumbnailChanged = isChanged;
196 }
197
198 _ContactChangeInfoImpl*
199 _ContactChangeInfoImpl::GetInstance(ContactChangeInfo& contactChangeInfo)
200 {
201         return contactChangeInfo.__pContactChangeInfoImpl;
202 }
203
204 const _ContactChangeInfoImpl*
205 _ContactChangeInfoImpl::GetInstance(const ContactChangeInfo& contactChangeInfo)
206 {
207         return contactChangeInfo.__pContactChangeInfoImpl;
208 }
209
210 }} // Tizen::Social