Fix for CompatTC Fail
[framework/osp/social.git] / src / FScl_PhoneNumberContactImpl.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_PhoneNumberContactImpl.cpp
18  * @brief               This is the implementation for _PhoneNumberContactImpl class.
19  *
20  * This file contains definitions of @e _PhoneNumberContactImpl class.
21  */
22
23 #include <new>
24 #include <unique_ptr.h>
25 #include <FBaseResult.h>
26 #include <FBaseString.h>
27 #include <FBaseSysLog.h>
28 #include <FSclPhoneNumberContact.h>
29 #include <FSclPhoneNumber.h>
30 #include "FScl_RecordImpl.h"
31 #include "FScl_PhoneNumberImpl.h"
32 #include "FScl_PhoneNumberContactImpl.h"
33
34 using namespace Tizen::Base;
35 using namespace Tizen::Base::Collection;
36
37 namespace Tizen { namespace Social
38 {
39
40 _PhoneNumberContactImpl::_PhoneNumberContactImpl(void)
41 : __addressbookId(INVALID_ADDRESSBOOK_ID)
42 , __contactId(INVALID_RECORD_ID)
43 {
44         //empty body
45 }
46
47 _PhoneNumberContactImpl::_PhoneNumberContactImpl(const _PhoneNumberContactImpl& rhs)
48 {
49         __addressbookId = rhs.__addressbookId;
50         __contactId = rhs.__contactId;
51         __personId = rhs.__personId;
52         __displayName = rhs.__displayName;
53         __thumbnail = rhs.__thumbnail;
54         __ringtone = rhs.__ringtone;
55         __phoneNumber = rhs.__phoneNumber;
56 }
57
58 _PhoneNumberContactImpl::~_PhoneNumberContactImpl(void)
59 {
60         //empty body
61 }
62
63 _PhoneNumberContactImpl&
64 _PhoneNumberContactImpl::operator =(const _PhoneNumberContactImpl& rhs)
65 {
66         if (this == &rhs)
67         {
68                 return *this;
69         }
70         __addressbookId = rhs.__addressbookId;
71         __contactId = rhs.__contactId;
72         __personId = rhs.__personId;
73         __displayName = rhs.__displayName;
74         __thumbnail = rhs.__thumbnail;
75         __ringtone = rhs.__ringtone;
76         __phoneNumber = rhs.__phoneNumber;
77
78         return *this;
79 }
80
81 bool
82 _PhoneNumberContactImpl::operator ==(const _PhoneNumberContactImpl& rhs) const
83 {
84         if (__addressbookId != rhs.__addressbookId)
85         {
86                 return false;
87         }
88
89         if (__contactId != rhs.__contactId)
90         {
91                 return false;
92         }
93
94         if (__personId != rhs.__personId)
95         {
96                 return false;
97         }
98
99         if (__displayName != rhs.__displayName)
100         {
101                 return false;
102         }
103
104
105         if (__thumbnail != rhs.__thumbnail)
106         {
107                 return false;
108         }
109
110
111         if (__ringtone != rhs.__ringtone)
112         {
113                 return false;
114         }
115
116         if (__phoneNumber != rhs.__phoneNumber)
117         {
118                 return false;
119         }
120
121         return true;
122 }
123
124 bool
125 _PhoneNumberContactImpl::Equals(const Object& rhs) const
126 {
127         const _PhoneNumberContactImpl* pPhoneNumberContactImpl = dynamic_cast<const _PhoneNumberContactImpl*>(&rhs);
128         if (pPhoneNumberContactImpl == null)
129         {
130                 return false;
131         }
132
133         return *this == *pPhoneNumberContactImpl;
134 }
135
136 int
137 _PhoneNumberContactImpl::GetHashCode(void) const
138 {
139         int hashCode = 0;
140
141         hashCode = 0xffffffff & __contactId;
142         hashCode += __addressbookId;
143         hashCode += __personId;
144         hashCode += __displayName.GetHashCode();
145         hashCode += __thumbnail.GetHashCode();
146         hashCode += __ringtone.GetHashCode();
147         hashCode += __phoneNumber.GetHashCode();
148
149         return hashCode;
150 }
151
152 PersonId
153 _PhoneNumberContactImpl::GetPersonId(void) const
154 {
155         return __personId;
156 }
157
158 void
159 _PhoneNumberContactImpl::SetPersonId(PersonId personId)
160 {
161         __personId = personId;
162 }
163
164
165 void
166 _PhoneNumberContactImpl::SetAddressbookId(AddressbookId addressbookId)
167 {
168         __addressbookId = addressbookId;
169 }
170
171 AddressbookId
172 _PhoneNumberContactImpl::GetAddressbookId(void) const
173 {
174         return __addressbookId;
175 }
176
177
178 RecordId
179 _PhoneNumberContactImpl::GetContactId(void) const
180 {
181         return __contactId;
182 }
183
184 String
185 _PhoneNumberContactImpl::GetDisplayName(void) const
186 {
187         return __displayName;
188 }
189
190 String
191 _PhoneNumberContactImpl::GetThumbnailPath(void) const
192 {
193         return __thumbnail;
194 }
195
196 String
197 _PhoneNumberContactImpl::GetRingtonePath(void) const
198 {
199         return __ringtone;
200 }
201
202
203 PhoneNumber
204 _PhoneNumberContactImpl::GetPhoneNumber(void) const
205 {
206         return __phoneNumber;
207 }
208
209 void
210 _PhoneNumberContactImpl::SetContactId(RecordId contactId)
211 {
212         __contactId = contactId;
213 }
214
215 void
216 _PhoneNumberContactImpl::SetDisplayName(const String& displayName)
217 {
218         __displayName = displayName;
219 }
220
221 void
222 _PhoneNumberContactImpl::SetThumbnailPath(const String& thumbnail)
223 {
224         __thumbnail = thumbnail;
225 }
226
227 void
228 _PhoneNumberContactImpl::SetRingtonePath(const String& ringtone)
229 {
230         __ringtone = ringtone;
231 }
232
233 void
234 _PhoneNumberContactImpl::SetPhoneNumberData(int recordId, PhoneNumberType type, const Tizen::Base::String& label, const Tizen::Base::String& number)
235 {
236         _PhoneNumberImpl::GetInstance(__phoneNumber)->SetRecordId(recordId);
237         _PhoneNumberImpl::GetInstance(__phoneNumber)->SetType(type);
238         _PhoneNumberImpl::GetInstance(__phoneNumber)->SetLabel(label);
239         _PhoneNumberImpl::GetInstance(__phoneNumber)->SetPhoneNumber(number);
240 }
241
242 _PhoneNumberContactImpl*
243 _PhoneNumberContactImpl::GetInstance(PhoneNumberContact& simpleContact)
244 {
245         return simpleContact.__pPhoneNumberContactImpl;
246 }
247
248 const _PhoneNumberContactImpl*
249 _PhoneNumberContactImpl::GetInstance(const PhoneNumberContact& simpleContact)
250 {
251         return simpleContact.__pPhoneNumberContactImpl;
252 }
253
254
255 }}  // Tizen::Social