[N_SE-32914, 33582] Fixed priority converting codes
[framework/osp/social.git] / src / FSclUserProfile.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                FSclUserProfile.cpp
19  * @brief               This is the implementation for Profile class.
20  *
21  * This file contains definitions of @e UserProfile class.
22  */
23
24 #include <FBaseSysLog.h>
25 #include <FSclAddress.h>
26 #include <FSclPhoneNumber.h>
27 #include <FSclEmail.h>
28 #include <FSclUrl.h>
29 #include <FSclImAddress.h>
30 #include <FSclOrganization.h>
31 #include <FSclContactEvent.h>
32 #include <FSclRelationship.h>
33 #include <FSclUserProfile.h>
34 #include "FScl_UserProfileImpl.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 UserProfile::UserProfile(void)
44 {
45         __pUserProfileImpl = new (std::nothrow) _UserProfileImpl();
46         SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
47 }
48
49 UserProfile::UserProfile(const UserProfile& rhs)
50 {
51         __pUserProfileImpl = new (std::nothrow) _UserProfileImpl(*rhs.__pUserProfileImpl);
52         SysTryReturnVoidResult(NID_SCL, __pUserProfileImpl != null, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY));
53 }
54
55 UserProfile::~UserProfile(void)
56 {
57         delete __pUserProfileImpl;
58 }
59
60 UserProfile&
61 UserProfile::operator =(const UserProfile& rhs)
62 {
63         if (this == &rhs)
64         {
65                 return *this;
66         }
67
68         *__pUserProfileImpl = *rhs.__pUserProfileImpl;
69
70         return *this;
71 }
72
73 bool
74 UserProfile::Equals(const Object& rhs) const
75 {
76         const UserProfile* pUserProfile = dynamic_cast<const UserProfile*>(&rhs);
77         if (pUserProfile == null)
78         {
79                 return false;
80         }
81
82         return __pUserProfileImpl->Equals(*_UserProfileImpl::GetInstance(*pUserProfile));
83 }
84
85 int
86 UserProfile::GetHashCode(void) const
87 {
88         return __pUserProfileImpl->GetHashCode();
89 }
90
91 AddressbookId
92 UserProfile::GetAddressbookId(void) const
93 {
94         return __pUserProfileImpl->GetAddressbookId();
95 }
96
97 String
98 UserProfile::GetThumbnailPath(void) const
99 {
100         return  __pUserProfileImpl->GetThumbnailPath();
101 }
102
103 result
104 UserProfile::SetThumbnail(const String& filePath)
105 {
106         result r = __pUserProfileImpl->SetThumbnail(filePath);
107         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
108
109         return E_SUCCESS;
110 }
111
112 String
113 UserProfile::GetValue(UserProfilePropertyId id) const
114 {
115         return __pUserProfileImpl->GetValue(id);
116 }
117
118 result
119 UserProfile::SetValue(UserProfilePropertyId id, const String& value)
120 {
121         result r = __pUserProfileImpl->SetValue(id, value);
122         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
123
124         return E_SUCCESS;
125 }
126
127 result
128 UserProfile::AddNote(const String& note)
129 {
130         result r = __pUserProfileImpl->AddNote(note);
131         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
132
133         return E_SUCCESS;
134 }
135
136 result
137 UserProfile::AddNickname(const String& nickname)
138 {
139         result r = __pUserProfileImpl->AddNickname(nickname);
140         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
141
142         return E_SUCCESS;
143 }
144
145 result
146 UserProfile::AddPhoneNumber(const PhoneNumber& phoneNumber)
147 {
148         result r = __pUserProfileImpl->AddPhoneNumber(phoneNumber);
149         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
150
151         return E_SUCCESS;
152 }
153
154 result
155 UserProfile::AddEmail(const Email& email)
156 {
157         result r = __pUserProfileImpl->AddEmail(email);
158         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
159
160         return E_SUCCESS;
161 }
162
163 result
164 UserProfile::AddUrl(const Url& url)
165 {
166         result r = __pUserProfileImpl->AddUrl(url);
167         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
168
169         return E_SUCCESS;
170 }
171
172 result
173 UserProfile::AddAddress(const Address& address)
174 {
175         result r = __pUserProfileImpl->AddAddress(address);
176         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
177
178         return E_SUCCESS;
179 }
180
181 result
182 UserProfile::AddImAddress(const ImAddress& imAddress)
183 {
184         result r = __pUserProfileImpl->AddImAddress(imAddress);
185         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
186
187         return E_SUCCESS;
188 }
189
190 result
191 UserProfile::AddOrganization(const Organization& organization)
192 {
193         result r = __pUserProfileImpl->AddOrganization(organization);
194         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
195
196         return E_SUCCESS;
197 }
198
199 result
200 UserProfile::AddEvent(const ContactEvent& event)
201 {
202         result r = __pUserProfileImpl->AddEvent(event);
203         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
204
205         return E_SUCCESS;
206 }
207
208 result
209 UserProfile::AddRelationship(const Relationship& relationship)
210 {
211         result r = __pUserProfileImpl->AddRelationship(relationship);
212         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
213
214         return E_SUCCESS;
215 }
216
217 result
218 UserProfile::RemoveAt(UserProfileMultiPropertyId id, int index)
219 {
220         result r = __pUserProfileImpl->RemoveAt(id, index);
221         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
222
223         return E_SUCCESS;
224 }
225
226 IList*
227 UserProfile::GetValuesN(UserProfileMultiPropertyId id) const
228 {
229         IList* pList = __pUserProfileImpl->GetValuesN(id);
230         SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult()));
231
232         return pList;
233 }
234
235 result
236 UserProfile::SetNoteAt(int index, const String& note)
237 {
238         result r = __pUserProfileImpl->SetNoteAt(index, note);
239         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
240
241         return E_SUCCESS;
242 }
243
244 result
245 UserProfile::SetNicknameAt(int index, const String& nickname)
246 {
247         result r = __pUserProfileImpl->SetNicknameAt(index, nickname);
248         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
249
250         return E_SUCCESS;
251 }
252
253 result
254 UserProfile::SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber)
255 {
256         result r = __pUserProfileImpl->SetPhoneNumberAt(index, phoneNumber);
257         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
258
259         return E_SUCCESS;
260 }
261
262 result
263 UserProfile::SetEmailAt(int index, const Email& email)
264 {
265         result r = __pUserProfileImpl->SetEmailAt(index, email);
266         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
267
268         return E_SUCCESS;
269 }
270
271 result
272 UserProfile::SetEventAt(int index, const ContactEvent& event)
273 {
274         result r = __pUserProfileImpl->SetEventAt(index, event);
275         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
276
277         return E_SUCCESS;
278 }
279
280 result
281 UserProfile::SetOrganizationAt(int index, const Organization& organization)
282 {
283         result r = __pUserProfileImpl->SetOrganizationAt(index, organization);
284         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
285
286         return E_SUCCESS;
287 }
288
289 result
290 UserProfile::SetUrlAt(int index, const Url& url)
291 {
292         result r = __pUserProfileImpl->SetUrlAt(index, url);
293         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
294
295         return E_SUCCESS;
296 }
297
298 result
299 UserProfile::SetAddressAt(int index, const Address& address)
300 {
301         result r = __pUserProfileImpl->SetAddressAt(index, address);
302         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
303
304         return E_SUCCESS;
305 }
306
307 result
308 UserProfile::SetImAddressAt(int index, const ImAddress& imAddress)
309 {
310         result r = __pUserProfileImpl->SetImAddressAt(index, imAddress);
311         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
312
313         return E_SUCCESS;
314 }
315
316 result
317 UserProfile::SetRelationshipAt(int index, const Relationship& relationship)
318 {
319         result r = __pUserProfileImpl->SetRelationshipAt(index, relationship);
320         SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r));
321
322         return E_SUCCESS;
323 }
324
325 }} // Tizen::Social