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