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