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