Modify the spec file for secure log
[framework/osp/social.git] / src / FSclContact.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                FSclContact.cpp
18  * @brief               This is the implementation for Profile class.
19  *
20  * This file contains definitions of @e Contact class.
21  */
22
23 #include <FBaseSysLog.h>
24 #include <FSclAddress.h>
25 #include <FSclPhoneNumber.h>
26 #include <FSclEmail.h>
27 #include <FSclUrl.h>
28 #include <FSclImAddress.h>
29 #include <FSclOrganization.h>
30 #include <FSclContactEvent.h>
31 #include <FSclRelationship.h>
32 #include <FSclContactAppLaunchData.h>
33 #include <FSclContact.h>
34 #include "FScl_ContactImpl.h"
35
36 using namespace Tizen::Base;
37 using namespace Tizen::Base::Collection;
38 using namespace Tizen::Graphics;
39
40 namespace Tizen { namespace Social
41 {
42
43 Contact::Contact(void)
44         : Record(RECORD_TYPE_CONTACT)
45 {
46         __pContactImpl = new (std::nothrow) _ContactImpl();
47         SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
48 }
49
50 Contact::Contact(const Contact& rhs)
51         : Record(rhs)
52 {
53         __pContactImpl = new (std::nothrow) _ContactImpl(*rhs.__pContactImpl);
54         SysTryReturnVoidResult(NID_SCL, __pContactImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
55 }
56
57 Contact::~Contact(void)
58 {
59         delete __pContactImpl;
60 }
61
62 Contact&
63 Contact::operator =(const Contact& rhs)
64 {
65         if (this == &rhs)
66         {
67                 return *this;
68         }
69
70         Record::operator=(rhs);
71
72         *__pContactImpl = *rhs.__pContactImpl;
73
74         return *this;
75 }
76
77 bool
78 Contact::Equals(const Object& rhs) const
79 {
80         const Contact* pContact = dynamic_cast<const Contact*>(&rhs);
81         if (pContact == null)
82         {
83                 return false;
84         }
85
86         if (GetRecordId() == INVALID_RECORD_ID)
87         {
88                 return false;
89         }
90
91         if (GetRecordId() == pContact->GetRecordId())
92         {
93                 return true;
94         }
95
96         return false;
97 }
98
99 int
100 Contact::GetHashCode(void) const
101 {
102         return GetRecordId();
103 }
104
105 PersonId
106 Contact::GetPersonId(void) const
107 {
108         return __pContactImpl->GetPersonId();
109 }
110
111 AddressbookId
112 Contact::GetAddressbookId(void) const
113 {
114         return __pContactImpl->GetAddressbookId();
115 }
116
117 Bitmap*
118 Contact::GetThumbnailN(void) const
119 {
120         Bitmap* pBitmap = __pContactImpl->GetThumbnailN();
121         SysTryReturn(NID_SCL, GetLastResult() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
122
123         return pBitmap;
124 }
125
126 String
127 Contact::GetThumbnailPath(void) const
128 {
129         return  __pContactImpl->GetThumbnailPath();
130 }
131
132 result
133 Contact::SetThumbnail(const String& filePath)
134 {
135         result r = __pContactImpl->SetThumbnailPath(filePath);
136         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
137
138         return E_SUCCESS;
139 }
140
141 result
142 Contact::GetValue(ContactPropertyId id, String& value) const
143 {
144         result r = __pContactImpl->GetValue(id, value);
145         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
146
147         return E_SUCCESS;
148 }
149
150 result
151 Contact::GetValue(ContactPropertyId id, DateTime& value) const
152 {
153         result r = __pContactImpl->GetValue(id, value);
154         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
155
156         return E_SUCCESS;
157 }
158
159 result
160 Contact::SetValue(ContactPropertyId id, const String& value)
161 {
162         result r = __pContactImpl->SetValue(id, value);
163         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
164
165         return E_SUCCESS;
166 }
167
168 result
169 Contact::SetValue(ContactPropertyId id, const DateTime& value)
170 {
171         result r = __pContactImpl->SetValue(id, value);
172         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
173
174         return E_SUCCESS;
175 }
176
177 result
178 Contact::AddNote(const String& note)
179 {
180         result r = __pContactImpl->AddNote(note);
181         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
182
183         return E_SUCCESS;
184 }
185
186 result
187 Contact::AddNickname(const String& nickname)
188 {
189         result r = __pContactImpl->AddNickname(nickname);
190         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
191
192         return E_SUCCESS;
193 }
194
195 result
196 Contact::AddPhoneNumber(const PhoneNumber& phoneNumber)
197 {
198         result r = __pContactImpl->AddPhoneNumber(phoneNumber);
199         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
200
201         return E_SUCCESS;
202 }
203
204 result
205 Contact::AddEmail(const Email& email)
206 {
207         result r = __pContactImpl->AddEmail(email);
208         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
209
210         return E_SUCCESS;
211 }
212
213 result
214 Contact::AddUrl(const Url& url)
215 {
216         result r = __pContactImpl->AddUrl(url);
217         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
218
219         return E_SUCCESS;
220 }
221
222 result
223 Contact::AddAddress(const Address& address)
224 {
225         result r = __pContactImpl->AddAddress(address);
226         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
227
228         return E_SUCCESS;
229 }
230
231 result
232 Contact::AddImAddress(const ImAddress& imAddress)
233 {
234         result r = __pContactImpl->AddImAddress(imAddress);
235         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
236
237         return E_SUCCESS;
238 }
239
240 result
241 Contact::AddOrganization(const Organization& organization)
242 {
243         result r = __pContactImpl->AddOrganization(organization);
244         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
245
246         return E_SUCCESS;
247 }
248
249 result
250 Contact::AddEvent(const ContactEvent& event)
251 {
252         result r = __pContactImpl->AddEvent(event);
253         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
254
255         return E_SUCCESS;
256 }
257
258 result
259 Contact::AddRelationship(const Relationship& relationship)
260 {
261         result r = __pContactImpl->AddRelationship(relationship);
262         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
263
264         return E_SUCCESS;
265 }
266
267 result
268 Contact::AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData)
269 {
270         result r = __pContactImpl->AddContactAppLaunchData(appLaunchData);
271         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
272
273         return E_SUCCESS;
274 }
275
276 result
277 Contact::RemoveAt(ContactMultiPropertyId id, int index)
278 {
279         result r = __pContactImpl->RemoveAt(id, index);
280         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
281
282         return E_SUCCESS;
283 }
284
285 IList*
286 Contact::GetValuesN(ContactMultiPropertyId id) const
287 {
288         IList* pList = __pContactImpl->GetValuesN(id);
289         SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
290
291         return pList;
292 }
293
294 result
295 Contact::SetNoteAt(int index, const String& note)
296 {
297         result r = __pContactImpl->SetNoteAt(index, note);
298         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
299
300         return E_SUCCESS;
301 }
302
303 result
304 Contact::SetNicknameAt(int index, const String& nickname)
305 {
306         result r = __pContactImpl->SetNicknameAt(index, nickname);
307         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
308
309         return E_SUCCESS;
310 }
311
312 result
313 Contact::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
314 {
315         result r = __pContactImpl->SetPhoneNumberAt(index, phoneNumber);
316         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
317
318         return E_SUCCESS;
319 }
320
321 result
322 Contact::SetEmailAt(int index, const Email& email)
323 {
324         result r = __pContactImpl->SetEmailAt(index, email);
325         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
326
327         return E_SUCCESS;
328 }
329
330 result
331 Contact::SetEventAt(int index, const ContactEvent& event)
332 {
333         result r = __pContactImpl->SetEventAt(index, event);
334         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
335
336         return E_SUCCESS;
337 }
338
339 result
340 Contact::SetOrganizationAt(int index, const Organization& organization)
341 {
342         result r = __pContactImpl->SetOrganizationAt(index, organization);
343         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
344
345         return E_SUCCESS;
346 }
347
348 result
349 Contact::SetRelationshipAt(int index, const Relationship& relationship)
350 {
351         result r = __pContactImpl->SetRelationshipAt(index, relationship);
352         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
353
354         return E_SUCCESS;
355 }
356
357 result
358 Contact::SetUrlAt(int index, const Url& url)
359 {
360         result r = __pContactImpl->SetUrlAt(index, url);
361         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
362
363         return E_SUCCESS;
364 }
365
366 result
367 Contact::SetAddressAt(int index, const Address& address)
368 {
369         result r = __pContactImpl->SetAddressAt(index, address);
370         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
371
372         return E_SUCCESS;
373 }
374
375 result
376 Contact::SetImAddressAt(int index, const ImAddress& imAddress)
377 {
378         result r = __pContactImpl->SetImAddressAt(index, imAddress);
379         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
380
381         return E_SUCCESS;
382 }
383
384 result
385 Contact::SetContactAppLaunchDataAt(int index, const ContactAppLaunchData& appLaunchData)
386 {
387         result r = __pContactImpl->SetContactAppLaunchDataAt(index, appLaunchData);
388         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
389
390         return E_SUCCESS;
391 }
392
393 bool
394 Contact::IsFavorite(void) const
395 {
396         return __pContactImpl->IsFavorite();
397 }
398
399 void
400 Contact::SetAsFavorite(bool isFavorite)
401 {
402         __pContactImpl->SetAsFavorite(isFavorite);
403 }
404
405 }} // Tizen::Social