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