2 // Copyright (c) 2012 Samsung Electronics Co., Ltd.
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
8 // http://www.apache.org/licenses/LICENSE-2.0
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.
18 * @brief This is the header file for the %Contact class.
20 * This header file contains the declarations of the %Contact class.
22 #ifndef _FSCL_CONTACT_H_
23 #define _FSCL_CONTACT_H_
25 #include <FBaseTypes.h>
26 #include <FBaseString.h>
27 #include <FBaseDateTime.h>
28 #include <FBaseColIList.h>
29 #include <FGrpBitmap.h>
30 #include <FSclTypes.h>
31 #include <FSclRecord.h>
33 namespace Tizen { namespace Social
44 class ContactAppLaunchData;
48 * @brief This class provides a contact.
52 * @final This class is not intended for extension.
54 * The %Contact class provides a contact, a record that represents the contact information of a person. It provides the properties declared in
55 * the #ContactPropertyId and #ContactMultiPropertyId enumerators. Check the descriptions for each property ID carefully to know the exact type
56 * of the property and its value. @n
58 * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/contact.htm">Contact</a>.
60 * The following example demonstrates how to use the %Contact class.
66 using namespace Tizen::Base;
67 using namespace Tizen::Base::Collection;
68 using namespace Tizen::Social;
76 // Sets the contact's properties
77 contact.SetValue(CONTACT_PROPERTY_ID_FIRST_NAME, L"Thomas");
78 contact.SetValue(CONTACT_PROPERTY_ID_LAST_NAME, L"A Anderson");
80 PhoneNumber phoneNumber(PHONENUMBER_TYPE_MOBILE, L"820223459876");
81 contact.AddPhoneNumber(phoneNumber);
83 // Gets the contact's properties
84 String firstName, lastName;
85 contact.GetValue(CONTACT_PROPERTY_ID_FIRST_NAME, firstName);
86 contact.GetValue(CONTACT_PROPERTY_ID_LAST_NAME, lastName);
88 IList* pPhoneNumberList = contact.GetValuesN(CONTACT_MPROPERTY_ID_PHONE_NUMBERS);
89 if (pPhoneNumberList != null)
91 PhoneNumber* pPhoneNumber = null;
93 IEnumerator* pEnum = pPhoneNumberList->GetEnumeratorN();
94 while (pEnum->MoveNext() == E_SUCCESS)
96 pPhoneNumber = (PhoneNumber*) pEnum->GetCurrent();
97 number = pPhoneNumber->GetPhoneNumber();
98 // Uses the phone number
103 pPhoneNumberList->RemoveAll(true);
104 delete pPhoneNumberList;
111 class _OSP_EXPORT_ Contact
116 * This is the default constructor for this class.
123 * Copying of objects using this copy constructor is allowed.
127 * @param[in] rhs An instance of %Contact to copy
129 Contact(const Contact& rhs);
132 * This destructor overrides Tizen::Social::Record::~Record().
137 virtual ~Contact(void);
140 * Checks whether the value of the specified instance is equal to the value of the current instance of Tizen::Base::Object.
144 * @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
146 * @param[in] rhs An instance of Tizen::Base::Object to compare
148 virtual bool Equals(const Tizen::Base::Object& rhs) const;
151 * Gets the hash value of the current instance.
155 * @return The hash value of the current instance
157 virtual int GetHashCode(void) const;
161 * Gets the Tizen::Graphics::Bitmap object of the thumbnail image. @n
162 * If the thumbnail is not set, @c null is returned.
164 * @brief <i> [Deprecated] </i>
165 * @deprecated This method is deprecated. Instead of using this method, use GetThumbnailPath()
168 * @return The Tizen::Graphics::Bitmap object of the thumbnail image
169 * @exception E_SUCCESS The method is successful.
170 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
171 * @remarks The specific error code can be accessed using the GetLastResult() method.
172 * @see SetThumbnail()
175 Tizen::Graphics::Bitmap* GetThumbnailN(void) const;
178 * Gets the thumbnail path.
182 * @return The file path of the thumbnail
183 * @remarks If the thumbnail has not been set, an empty string is returned.
185 Tizen::Base::String GetThumbnailPath(void) const;
188 * Sets the thumbnail image. @n
189 * If the specified @c filePath is an empty string, the current thumbnail image is removed.
192 * @brief <i> [Compatibility] </i>
196 * @compatibility This method has compatibility issues with OSP compatible applications. @n
197 * For more information, see @ref CompIoPathPage "here".
200 * @return An error code
201 * @param[in] filePath The file path of the thumbnail image
202 * @exception E_SUCCESS The method is successful.
203 * @exception E_INVALID_ARG The length of the specified @c filePath exceeds system limitations.
204 * @exception E_FILE_NOT_FOUND The specified file cannot be found or accessed.
205 * @exception E_SYSTEM The method cannot proceed due to a severe system error.
206 * @see GetThumbnailPath()
208 result SetThumbnail(const Tizen::Base::String& filePath);
211 * Sets the value of the property having the specified ID, to the specified value.
214 * @brief <i> [Compatibility] </i>
218 * @compatibility This method has compatibility issues with OSP compatible applications. @n
219 * For more information, see @ref CompContactSetValuePage "here".
222 * @return An error code
223 * @param[in] id The ID of the property whose value is set
224 * @param[in] value The new string value to set
225 * @exception E_SUCCESS The method is successful.
226 * @exception E_INVALID_ARG The specified @c id is #CONTACT_PROPERTY_ID_DISPLAY_NAME, @if OSPDEPREC #CONTACT_PROPERTY_ID_THUMBNAIL, or @endif
227 * the ringtone file path (value) is invalid if @c id is #CONTACT_PROPERTY_ID_RINGTONE.
229 * - The #CONTACT_PROPERTY_ID_DISPLAY_NAME property cannot be set. @n
230 * - The #CONTACT_PROPERTY_ID_RINGTONE can be set to the path string of the ringtone file. @n
232 * - The #CONTACT_PROPERTY_ID_THUMBNAIL property cannot be set. @n
233 * - In case @c id is set to #CONTACT_PROPERTY_ID_NICK_NAME, @n
234 * - If this contact has nicknames, the first nickname among them is set to the @c value. @n
235 * - If not, a new nickname is added to this contact. @n
236 * - In case @c id is set to #CONTACT_PROPERTY_ID_NOTE, @n
237 * - If this contact has notes, the first note among them is set to the @c value. @n
238 * - If not, a new note is added to this contact. @n
239 * - In case @c id is set to #CONTACT_PROPERTY_ID_COMPANY, @n
240 * - If this contact has organizations, the name value of the first organization among them is set to the @c value. @n
241 * - If not, a new organization is added to this contact. @n
242 * - In case @c id is set to #CONTACT_PROPERTY_ID_JOB_TITLE, @n
243 * - If this contact has organizations, the job title value of the first organization among them is set to the @c value. @n
244 * - If not, a new organization is added to this contact. @n
247 result SetValue(ContactPropertyId id, const Tizen::Base::String& value);
251 * @page CompContactSetValuePage Compatibility for SetValue()
252 * @section CompContactSetValuePageIssueSection Issues
253 * Implementing this method in OSP compatible applications has the following issues: @n
254 * -# If the length of the value is greater than the maximum length of the specified property, @c E_INVALID_ARG is returned.
255 * -# The path should begin with an allowed path prefix such as @b '/Home', @b '/Home/Share', @b '/Res', @b '/Share/[@e appid]',
256 * @b '/Media', and @b '/Storagecard/Media'.
258 * @section CompContactSetValuePageSolutionSection Resolutions
259 * -# The first issue mentioned above has been resolved in Tizen.
260 * -# There are no specific allowed path prefixes. Applications can obtain an accessible directory path using the following methods. @n
261 * - For accessing its own data directory, use Tizen::App::App::GetInstance()->GetAppRootPath() + L"data" @n
262 * or Tizen::App::App::GetInstance()->GetAppDataPath().
263 * - For accessing its own resource directory, use Tizen::App::App::GetInstance()->GetAppRootPath() + L"res". @n
264 * or Tizen::App::App::GetInstance()->GetAppResourcePath().
265 * - For accessing its own share directory, use Tizen::App::App::GetInstance()->GetAppRootPath() + L"share".
266 * - For accessing the media directory, use Tizen::System::Environment::GetMediaPath().
267 * - For accessing the external storage, use Tizen::System::Environment::GetExternalStoragePath().
269 * For more information on the path,
270 * see <a href="../org.tizen.native.appprogramming/html/basics_tizen_programming/io_overview.htm">I/O Overview</a>.
275 * Sets the specified value for the property having the specified ID.
279 * @return An error code
280 * @param[in] id The ID of the property whose value is set
281 * @param[in] value An instance of Tizen::Base::DateTime value to set
282 * @exception E_SUCCESS The method is successful.
283 * @exception E_INVALID_ARG Either of the following conditions has occurred:
284 * - The property with the specified contact property ID is not of Tizen::Base::DateTime type.
285 * - The property is read-only.
288 * - In case @c id is set to #CONTACT_PROPERTY_ID_BIRTHDAY,
289 * - If this contact has events whose types are #CONTACT_EVENT_TYPE_BIRTHDAY, the date value of the first event among them is set to the @c value.
290 * - If not, a new event whose type is #CONTACT_EVENT_TYPE_BIRTHDAY is added to this contact.
291 * - In case @c id is set to #CONTACT_PROPERTY_ID_ANNIVERSARY,
292 * - If this contact has events whose types are #CONTACT_EVENT_TYPE_ANNIVERSARY, the date value of the first event among them is set to the @c value.
293 * - If not, a new event whose type is #CONTACT_EVENT_TYPE_ANNIVERSARY is added to this contact.
296 result SetValue(ContactPropertyId id, const Tizen::Base::DateTime& value);
299 * Gets the value of the specified property.
303 * @return An error code
304 * @param[in] id The property ID
305 * @param[out] value The property value
306 * @exception E_SUCCESS The method is successful.
307 * @exception E_INVALID_ARG The specified contact property ID is not supported.
309 result GetValue(ContactPropertyId id, Tizen::Base::String& value) const;
312 * Gets the value of the specified Tizen::Base::DateTime property such as birthday. @n
313 * If the %Tizen::Base::DateTime value has not been set for the specified property, the property has a value, '1899, 12, 31, 00:00:00'.
317 * @return An error code
318 * @param[in] id The property ID
319 * @param[out] value The property value
320 * @exception E_SUCCESS The method is successful.
321 * @exception E_INVALID_ARG The specified contact property ID is not supported.
323 result GetValue(ContactPropertyId id, Tizen::Base::DateTime& value) const;
326 * Sets the specified phone number at the specified index.
330 * @return An error code
331 * @param[in] index The index at which to set the value
332 * @param[in] phoneNumber An instance of PhoneNumber to set, @n
334 * @exception E_SUCCESS The method is successful.
335 * @exception E_INVALID_ARG The specified @c phoneNumber is empty.
336 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
338 result SetPhoneNumberAt(int index, const PhoneNumber& phoneNumber);
341 * Sets the specified email corresponding to the specified index.
345 * @return An error code
346 * @param[in] index The index at which to set the value
347 * @param[in] email An instance of Email
348 * @exception E_SUCCESS The method is successful.
349 * @exception E_INVALID_ARG The specified @c email is empty.
350 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
352 result SetEmailAt(int index, const Email& email);
355 * Sets the specified URL corresponding to the specified index.
359 * @return An error code
360 * @param[in] index The index at which to set the value
361 * @param[in] url An instance of Url
362 * @exception E_SUCCESS The method is successful.
363 * @exception E_INVALID_ARG The specified @c url is empty.
364 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
366 result SetUrlAt(int index, const Url& url);
369 * Sets the specified address corresponding to the specified index.
373 * @return An error code
374 * @param[in] index The index at which to set the value
375 * @param[in] address An instance of Address
376 * @exception E_SUCCESS The method is successful.
377 * @exception E_INVALID_ARG The specified @c address is empty.
378 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
380 result SetAddressAt(int index, const Address& address);
383 * Sets the specified ImAddress corresponding to the specified index.
387 * @return An error code
388 * @param[in] index The index at which to set the value
389 * @param[in] imAddress An instance of ImAddress
390 * @exception E_SUCCESS The method is successful.
391 * @exception E_INVALID_ARG The specified @c imAddress is empty.
392 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
394 result SetImAddressAt(int index, const ImAddress& imAddress);
397 * Sets the specified note corresponding to the specified index.
401 * @return An error code
402 * @param[in] index The index at which to set the value
403 * @param[in] note The note to set
404 * @exception E_SUCCESS The method is successful.
405 * @exception E_INVALID_ARG The specified @c note is empty.
406 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
408 result SetNoteAt(int index, const Tizen::Base::String& note);
411 * Sets the specified nick name corresponding to the specified index.
415 * @return An error code
416 * @param[in] index The index at which to set the value
417 * @param[in] nickname The nick name to set
418 * @exception E_SUCCESS The method is successful.
419 * @exception E_INVALID_ARG The specified @c nickname is empty.
420 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
422 result SetNicknameAt(int index, const Tizen::Base::String& nickname);
425 * Sets the specified event corresponding to the specified index.
429 * @return An error code
430 * @param[in] index The index at which to set the value
431 * @param[in] event The event to set
432 * @exception E_SUCCESS The method is successful.
433 * @exception E_INVALID_ARG The date of the specified @c event has not been set.
434 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
436 result SetEventAt(int index, const ContactEvent& event);
439 * Sets the specified organization corresponding to the specified index.
443 * @return An error code
444 * @param[in] index The index at which to set the value
445 * @param[in] organization The organization to set
446 * @exception E_SUCCESS The method is successful.
447 * @exception E_INVALID_ARG The specified @c organization is empty.
448 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
450 result SetOrganizationAt(int index, const Organization& organization);
453 * Sets the specified @c relationship corresponding to the specified @c index.
457 * @return An error code
458 * @param[in] index The index at which to set the value
459 * @param[in] relationship The relationship to set
460 * @exception E_SUCCESS The method is successful.
461 * @exception E_INVALID_ARG The specified @c relationship is empty.
462 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
464 result SetRelationshipAt(int index, const Relationship& relationship);
467 * Sets the app launch data at the specified index.
472 * @return An error code
473 * @param[in] index The index at which to set the contact app launch data
474 * @param[in] appLaunchData The app launch data to set
475 * @exception E_SUCCESS The method is successful.
476 * @exception E_INVALID_ARG The specified @c appLaunchData has no relevant information.
477 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the app launch data.
479 result SetContactAppLaunchDataAt(int index, const ContactAppLaunchData& appLaunchData);
482 * Gets the addressbook ID.
486 * @return The addressbook ID
488 AddressbookId GetAddressbookId(void) const;
491 * Gets the person ID to which this contact is linked.
495 * @return The person ID
497 PersonId GetPersonId(void) const;
500 * Gets the list of values belonging to the specific multi value property.
504 * @return The list of values belonging to the specific multi value property
505 * @param[in] id The property ID
506 * @exception E_SUCCESS The method is successful.
507 * @remarks The specific error code can be accessed using the GetLastResult() method.
509 Tizen::Base::Collection::IList* GetValuesN(ContactMultiPropertyId id) const;
512 * Adds the specified phone number to the contact.
516 * @return An error code
517 * @param[in] phoneNumber The phone number to add
518 * @exception E_SUCCESS The method is successful.
519 * @exception E_INVALID_ARG The specified @c phoneNumber is empty.
521 result AddPhoneNumber(const PhoneNumber& phoneNumber);
524 * Adds the specified email to the contact.
528 * @return An error code
529 * @param[in] email The email address to add
530 * @exception E_SUCCESS The method is successful.
531 * @exception E_INVALID_ARG The specified @c email is empty.
533 result AddEmail(const Email& email);
536 * Adds the specified URL to the contact.
540 * @return An error code
541 * @param[in] url The URL to add
542 * @exception E_SUCCESS The method is successful.
543 * @exception E_INVALID_ARG The specified @c url is empty.
545 result AddUrl(const Url& url);
548 * Adds the specified address to the contact.
552 * @return An error code
553 * @param[in] address The address to add
554 * @exception E_SUCCESS The method is successful.
555 * @exception E_INVALID_ARG The specified @c address is empty.
557 result AddAddress(const Address& address);
560 * Adds the specified instant message information to the contact.
564 * @return An error code
565 * @param[in] imAddress The IM address to add
566 * @exception E_SUCCESS The method is successful.
567 * @exception E_INVALID_ARG The specified @c imAddress is empty.
569 result AddImAddress(const ImAddress& imAddress);
572 * Adds the specified note to the contact.
576 * @return An error code
577 * @param[in] note The note to add
578 * @exception E_SUCCESS The method is successful.
579 * @exception E_INVALID_ARG The specified @c note is empty.
581 result AddNote(const Tizen::Base::String& note);
584 * Adds the specified nick name to the contact.
588 * @return An error code
589 * @param[in] nickname The nick name to add
590 * @exception E_SUCCESS The method is successful.
591 * @exception E_INVALID_ARG The specified @c nickname is empty.
593 result AddNickname(const Tizen::Base::String& nickname);
596 * Adds the specified event to the contact.
600 * @return An error code
601 * @param[in] event The event to add
602 * @exception E_SUCCESS The method is successful.
603 * @exception E_INVALID_ARG The date of the specified @c event has not been set.
605 result AddEvent(const ContactEvent& event);
608 * Adds the specified organization to the contact.
612 * @return An error code
613 * @param[in] organization The organization to add
614 * @exception E_SUCCESS The method is successful.
615 * @exception E_INVALID_ARG The specified @c organization is empty.
617 result AddOrganization(const Organization& organization);
620 * Adds the specified relationship to the contact.
624 * @return An error code
625 * @param[in] relationship The relationship to add
626 * @exception E_SUCCESS The method is successful.
627 * @exception E_INVALID_ARG The specified @c organization is empty.
629 result AddRelationship(const Relationship& relationship);
632 * Adds the specified app launch data to the contact.
636 * @return An error code
637 * @param[in] appLaunchData The app launch data to add
638 * @exception E_SUCCESS The method is successful.
639 * @exception E_INVALID_ARG The specified @c appLaunchData has no relevant information.
641 result AddContactAppLaunchData(const ContactAppLaunchData& appLaunchData);
644 * Removes the value at the specified index of the multi value property.
648 * @return An error code
649 * @param[in] id The property ID
650 * @param[in] index The index of the value to remove
651 * @exception E_SUCCESS The method is successful.
652 * @exception E_OUT_OF_RANGE The specified @c index is outside the bounds of the properties.
654 result RemoveAt(ContactMultiPropertyId id, int index);
657 * Checks whether this contact is a favorite.
661 * @return @c true if this contact is a favorite, @n
663 * @see SetAsFavorite()
665 bool IsFavorite(void) const;
668 * Sets or unsets a contact as a favorite.
673 void SetAsFavorite(bool isFavorite = true);
676 * Copying of objects using this copy assignment operator is allowed.
680 * @param[in] rhs An instance of %Contact to copy
682 Contact& operator =(const Contact& rhs);
685 friend class _ContactImpl;
686 class _ContactImpl* __pContactImpl;
692 #endif // _FSCL_CONTACT_H_