Fix the boiler plate codes
[framework/osp/social.git] / src / inc / FScl_UserProfileImpl.h
1 //
2 // Copyright (c) 2013 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_UserProfileImpl.h
18  * @brief               This is the header file for the _UserProfileImpl class.
19  *
20  * This header file contains the declarations of the _UserProfileImpl class.
21  */
22 #ifndef _FSCL_INTERNAL_USER_PROFILE_H_
23 #define _FSCL_INTERNAL_USER_PROFILE_H_
24
25 #include <contacts.h>
26 #include <unique_ptr.h>
27 #include <FBaseResult.h>
28 #include <FBaseObject.h>
29 #include <FBaseString.h>
30 #include <FBaseColAllElementsDeleter.h>
31
32 namespace Tizen { namespace Base
33 {
34 class DateTime;
35
36 namespace Collection
37 {
38 class IList;
39 }
40
41 }}
42
43 namespace Tizen { namespace Social
44 {
45 class Contact;
46 class Address;
47 class PhoneNumber;
48 class Email;
49 class Url;
50 class ImAddress;
51 class Organization;
52 class ContactEvent;
53 class Relationship;
54 class UserProfile;
55
56 /**
57  * @class       _UserProfileImpl
58  * @brief       This class provides a contact.
59  * @since       2.1
60  * @see UserProfile
61  *
62  */
63 class _UserProfileImpl
64         : public Tizen::Base::Object
65 {
66 public:
67
68         /**
69          * This is the default constructor for this class.
70          *
71          * @since       2.1
72          */
73         _UserProfileImpl(void);
74
75         /**
76          * Copying of objects using this copy constructor is allowed.
77          *
78          * @since       2.1
79          *
80          * @param[in]   rhs             An instance of %UserProfile
81          */
82         _UserProfileImpl(const _UserProfileImpl& rhs);
83
84         /**
85          * This destructor overrides Tizen::Social::Object::~Object().
86          *
87          * @since       2.1
88          *
89          */
90         virtual ~_UserProfileImpl(void);
91
92         /**
93          * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
94          *
95          * @since       2.1
96          *
97          * @return      @c true if the value of the specified instance of Tizen::Base::Object is equal to the value of the current instance of %Tizen::Base::Object, @n
98          *              else @c false
99          * @param[in]   rhs             An instance of Tizen::Base::Object to compare
100          */
101         virtual bool Equals(const Tizen::Base::Object& rhs) const;
102
103         /**
104          * Gets the hash value of the current instance.
105          *
106          * @since       2.1
107          *
108          * @return      The hash value of the current instance
109          */
110         virtual int GetHashCode(void) const;
111
112         /**
113          * Gets the thumbnail path
114          *
115          * @since       2.1
116          *
117          * @return     The file path of the thumbnail
118          * @remarks    If the thumbnail has not been set, an empty string is returned.
119          */
120         Tizen::Base::String GetThumbnailPath(void) const;
121
122         /**
123          * Sets the thumbnail image. @n
124          * If the specified @c filePath is an empty string, the current thumbnail image is removed.
125          *
126          * @since       2.1
127          *
128          * @return      An error code
129          * @param[in]   filePath                The file path of the thumbnail image
130          * @exception   E_SUCCESS               The method is successful.
131          * @exception   E_INVALID_ARG           The length of the specified @c filePath exceeds system limitations.
132          * @exception   E_FILE_NOT_FOUND        The specified file cannot be found or accessed.
133          * @exception   E_SYSTEM                A system error has occurred.
134          * @see GetThumbnailPath()
135          */
136         result SetThumbnail(const Tizen::Base::String& filePath);
137
138         /**
139          * Sets the value of the property having the specified ID to the specified value.
140          *
141          *
142          * @return      An error code
143          * @param[in]   id                      The ID of the property whose value is to set
144          * @param[in]   value                   A new string value to set
145          * @exception   E_SUCCESS               The method is successful.
146          * @exception   E_INVALID_ARG           The specified property is read-only.
147          */
148
149         result SetValue(UserProfilePropertyId id, const Tizen::Base::String& value);
150
151         /**
152          * Gets the value of the specified property.
153          *
154          * @since       2.1
155          *
156          * @return      The property value
157          * @param[in]   id                              The property ID
158          */
159         Tizen::Base::String GetValue(UserProfilePropertyId id) const;
160
161         /**
162          * Sets the specified phone number at the specified index.
163          *
164          * @since       2.1
165          *
166          * @return     An error code
167          * @param[in]  index            An index to set the value
168          * @param[in]  phoneNumber      An instance of PhoneNumber to set.
169          * @exception  E_SUCCESS        The method is successful.
170          * @exception  E_INVALID_ARG    The specified @c phoneNumber is empty.
171          * @exception  E_OUT_OF_RANGE   The specified @c index is outside the bounds of the properties.
172          */
173         result SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber);
174
175         /**
176          * Sets the specified email corresponding to the specified index.
177          *
178          * @since       2.1
179          *
180          * @return      An error code
181          * @param[in]   index                   An index to set the value
182          * @param[in]   email                   An instance of Email
183          * @exception   E_SUCCESS               The method is successful.
184          * @exception   E_INVALID_ARG           The specified @c email is empty.
185          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
186          */
187         result SetEmailAt(int index, const Email& email);
188
189         /**
190          * Sets the specified URL corresponding to the specified index.
191          *
192          * @since       2.1
193          *
194          * @return      An error code
195          * @param[in]   index                   An index to set the value
196          * @param[in]   url                     An instance of Url
197          * @exception   E_SUCCESS               The method is successful.
198          * @exception   E_INVALID_ARG           The specified @c url is empty.
199          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
200          */
201         result SetUrlAt(int index, const Url& url);
202
203         /**
204          * Sets the specified address corresponding to the specified index.
205          *
206          * @since       2.1
207          *
208          * @return      An error code
209          * @param[in]   index                   An index to set the value
210          * @param[in]   address                 An instance of Address
211          * @exception   E_SUCCESS               The method is successful.
212          * @exception   E_INVALID_ARG           The specified @c address is empty.
213          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
214          */
215         result SetAddressAt(int index, const Address& address);
216
217         /**
218          * Sets the specified ImAddress corresponding to the specified index.
219          *
220          * @since       2.1
221          *
222          * @return      An error code
223          * @param[in]   index                   An index to set the value
224          * @param[in]   imAddress               An instance of ImAddress
225          * @exception   E_SUCCESS               The method is successful.
226          * @exception   E_INVALID_ARG           The specified @c imAddress is empty.
227          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
228          */
229         result SetImAddressAt(int index, const ImAddress& imAddress);
230
231         /**
232          * Sets the specified note corresponding to the specified index.
233          *
234          * @since       2.1
235          *
236          * @return      An error code
237          * @param[in]   index                   An index to set the value
238          * @param[in]   note                    The note to set
239          * @exception   E_SUCCESS               The method is successful.
240          * @exception   E_INVALID_ARG           The specified @c note is empty.
241          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
242          */
243         result SetNoteAt(int index, const Tizen::Base::String& note);
244
245         /**
246          * Sets the specified nick name corresponding to the specified index.
247          *
248          * @since       2.1
249          *
250          * @return      An error code
251          * @param[in]   index                   An index to set the value
252          * @param[in]   nickname                The nick name to set
253          * @exception   E_SUCCESS               The method is successful.
254          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
255          */
256         result SetNicknameAt(int index, const Tizen::Base::String& nickname);
257
258         /**
259          * Sets the specified event corresponding to the specified index.
260          *
261          * @since       2.1
262          *
263          * @return      An error code
264          * @param[in]   index                   An index to set the value
265          * @param[in]   event                   The event to set
266          * @exception   E_SUCCESS               The method is successful.
267          * @exception   E_INVALID_ARG           The specified @c event is empty.
268          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
269          */
270         result SetEventAt(int index, const ContactEvent& event);
271
272         /**
273          * Sets the specified organization corresponding to the specified index.
274          *
275          * @since       2.1
276          *
277          * @return      An error code
278          * @param[in]   index                   An index to set the value
279          * @param[in]   organization            The organization to set
280          * @exception   E_SUCCESS               The method is successful.
281          * @exception   E_INVALID_ARG           The specified @c organization is empty.
282          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
283          */
284         result SetOrganizationAt(int index, const Organization& organization);
285
286         /**
287          * Sets the specified relationship corresponding to the specified index.
288          *
289          * @since       2.1
290          *
291          * @return      An error code
292          * @param[in]   index                   An index to set the value
293          * @param[in]   relationship            The relationship to set
294          * @exception   E_SUCCESS               The method is successful.
295          * @exception   E_INVALID_ARG           The specified @c relationship is empty.
296          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
297          */
298         result SetRelationshipAt(int index, const Relationship& relationship);
299
300         /**
301          * Gets the addressbook ID.
302          *
303          * @since       2.1
304          *
305          * @return      The addressbook ID
306          */
307         AddressbookId GetAddressbookId(void) const;
308
309         /**
310          * Gets a list of the values belonging to the specific multi value property.
311          *
312          * @since       2.1
313          *
314          * @return      A list of the values belonging to the specific multi value property
315          * @param[in]   id                      A property ID
316          * @exception   E_SUCCESS               The method is successful.
317          * @exception   E_OUT_OF_MEMORY         The memory is insufficient.
318          * @remarks     The specific error code can be accessed using the GetLastResult() method.
319          */
320         Tizen::Base::Collection::IList* GetValuesN(UserProfileMultiPropertyId id) const;
321
322         /**
323          * Adds the specified phone number to the user profile..
324          *
325          * @since       2.1
326          *
327          * @return      An error code
328          * @param[in]   phoneNumber             The phone number to add
329          * @exception   E_SUCCESS               The method is successful.
330          * @exception   E_INVALID_ARG           The specified @c phoneNumber is empty.
331          */
332         result AddPhoneNumber(const PhoneNumber& phoneNumber);
333
334         /**
335          * Adds the specified email to the user profile..
336          *
337          * @since       2.1
338          *
339          * @return      An error code
340          * @param[in]   email           The mail address to add
341          * @exception   E_SUCCESS       The method is successful.
342          * @exception   E_INVALID_ARG   The specified @c email is empty.
343          */
344         result AddEmail(const Email& email);
345
346         /**
347          * Adds the specified URL to the user profile..
348          *
349          * @since       2.1
350          *
351          * @return      An error code
352          * @param[in]   url             The URL to add
353          * @exception   E_SUCCESS       The method is successful.
354          * @exception   E_INVALID_ARG   The specified @c url is empty.
355          */
356
357         result AddUrl(const Url& url);
358
359         /**
360          * Adds the specified address to the user profile..
361          *
362          * @since       2.1
363          *
364          * @return      An error code
365          * @param[in]   address         The address to add
366          * @exception   E_SUCCESS       The method is successful.
367          * @exception   E_INVALID_ARG   The specified @c address is empty.
368          */
369         result AddAddress(const Address& address);
370
371         /**
372          * Adds the specified instant message information to the user profile.
373          *
374          * @since       2.1
375          *
376          * @return      An error code
377          * @param[in]   imAddress       The IM address to add
378          * @exception   E_SUCCESS       The method is successful.
379          * @exception   E_INVALID_ARG   The specified @c imAddress is empty.
380          */
381         result AddImAddress(const ImAddress& imAddress);
382
383         /**
384          * Adds the specified note to the user profile..
385          *
386          * @since       2.1
387          *
388          * @return      An error code
389          * @param[in]   note                    The note to add
390          * @exception   E_SUCCESS               The method is successful.
391          * @exception   E_INVALID_ARG           The specified @c note is empty.
392          */
393         result AddNote(const Tizen::Base::String& note);
394
395         /**
396          * Adds the specified nick name to the user profile.
397          *
398          * @since       2.1
399          *
400          * @return      An error code
401          * @param[in]   nickname                The nick name to add
402          * @exception   E_SUCCESS               The method is successful.
403          * @exception   E_INVALID_ARG           The specified @c nickname is empty.
404          */
405         result AddNickname(const Tizen::Base::String& nickname);
406
407         /**
408          * Adds the specified event to the user profile..
409          *
410          * @since       2.1
411          *
412          * @return      An error code
413          * @param[in]   event                   The event to add
414          * @exception   E_SUCCESS               The method is successful.
415          * @exception   E_INVALID_ARG           The specified @c event is empty.
416          */
417         result AddEvent(const ContactEvent& event);
418
419         /**
420          * Adds the specified organization to the contact.
421          *
422          * @since       2.1
423          *
424          * @return      An error code
425          * @param[in]   organization            The organization to add
426          * @exception   E_SUCCESS               The method is successful.
427          * @exception   E_INVALID_ARG           The specified @c organization is empty.
428          */
429         result AddOrganization(const Organization& organization);
430
431         /**
432          * Adds the specified relationship to the user profile.
433          *
434          * @since       2.1
435          *
436          * @return      An error code
437          * @param[in]   relationship            The relationship to add
438          * @exception   E_SUCCESS               The method is successful.
439          * @exception   E_INVALID_ARG           The specified @c organization is empty.
440          */
441         result AddRelationship(const Relationship& relationship);
442
443         /**
444          * Removes the specific value at the specified index of the multi value property.
445          *
446          * @since       2.1
447          *
448          * @return      An error code
449          * @param[in]   id                      A property ID
450          * @param[in]   index                   The index of the value to remove
451          * @exception   E_SUCCESS               The method is successful.
452          * @exception   E_OUT_OF_RANGE          The specified @c index is outside the bounds of the properties.
453          */
454         result RemoveAt(UserProfileMultiPropertyId id, int index);
455
456         void SetUserProfileHandle(contacts_record_h profileHandle);
457
458         contacts_record_h GetUserProfileHandle(void) const;
459
460         bool IsEmpty(void) const;
461
462         static const _UserProfileImpl* GetInstance(const UserProfile& userProfile);
463         static _UserProfileImpl* GetInstance(UserProfile& userProfile);
464
465         /**
466          * Copying of objects using this copy assignment operator is allowed.
467          *
468          * @since       2.1
469          *
470          * @param[in]   rhs             An instance of %UserProfile
471          */
472         _UserProfileImpl& operator =(const _UserProfileImpl& rhs);
473
474 private:
475         bool IsEmptyName(contacts_record_h nameHandle);
476         bool IsEmptyCompany(contacts_record_h companyHandle);
477
478         Tizen::Base::Collection::IList* GetPhoneNumbersN(void) const;
479         Tizen::Base::Collection::IList* GetEmailsN(void) const;
480         Tizen::Base::Collection::IList* GetUrlsN(void) const;
481         Tizen::Base::Collection::IList* GetAddressesN(void) const;
482         Tizen::Base::Collection::IList* GetImAddressesN(void) const;
483         Tizen::Base::Collection::IList* GetOrganizationsN(void) const;
484         Tizen::Base::Collection::IList* GetRelationshipsN(void) const;
485         Tizen::Base::Collection::IList* GetEventsN(void) const;
486         Tizen::Base::Collection::IList* GetNotesN(void) const;
487         Tizen::Base::Collection::IList* GetNicknamesN(void) const;
488
489 private:
490         contacts_record_h __profileHandle;
491
492 }; // _UserProfileImpl
493
494 }} // Tizen::Social
495
496 #endif //_FSCL_INTERNAL_USER_PROFILE_H_