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