diff options
author | hs321.lee <hs321.lee@samsung.com> | 2013-03-18 11:22:33 +0900 |
---|---|---|
committer | hs321.lee <hs321.lee@samsung.com> | 2013-03-18 11:22:33 +0900 |
commit | ca32e33cd472d0a120894085ceac56397e24c9ce (patch) | |
tree | 71f79b38cecc4d59d515ff9562dcb0da2f41a69f | |
parent | 5e755d91d8b859a71c012556f497f1b4a9d7b08b (diff) | |
download | social-ca32e33cd472d0a120894085ceac56397e24c9ce.tar.gz social-ca32e33cd472d0a120894085ceac56397e24c9ce.tar.bz2 social-ca32e33cd472d0a120894085ceac56397e24c9ce.zip |
Master to tizen_2.1
Change-Id: I4288529d24e61cc4088f0537c664f8377cb48b96
Signed-off-by: hs321.lee <hs321.lee@samsung.com>
30 files changed, 1441 insertions, 303 deletions
diff --git a/inc/FSclAddressbook.h b/inc/FSclAddressbook.h index 3e7a9bf..90b0de5 100644 --- a/inc/FSclAddressbook.h +++ b/inc/FSclAddressbook.h @@ -46,6 +46,7 @@ class Contact; class UserProfile; class IRecordEventListener; class IAddressbookEventListener; +class IAddressbookChangeEventListener; class IRecordEventListener; /** @@ -61,11 +62,6 @@ class IRecordEventListener; * * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/addressbook_namespace.htm">Address Book</a>. * - * The following diagram illustrates the relationships between %Addressbook and related classes. - * - * @image html social_addressbook_classdiagram.png - * - * * The following example demonstrates how to use the %Addressbook class to create the categories and add contacts to them. * * @code @@ -316,6 +312,10 @@ public: * The listener is called when a contact or a category has been changed. * To reset the event listener, @c null must be passed. * + * @brief <i> [Deprecated] </i> + * @deprecated This method and IAddressbookEventListener are deprecated. Instead of using this method, use SetAddressbookChangeEventListener() + * and IAddressbookChangeEventListener. + * * @since 2.0 * @privlevel public * @privilege http://tizen.org/privilege/contact.read @@ -328,6 +328,22 @@ public: */ result SetEventListener(IAddressbookEventListener* pListener); + /** + * Sets addressbook change event listener. @n + * The listener is called when a contact or a category has been changed. + * To reset the event listener, @c null must be passed. + * + * @since 2.1 + * @privlevel public + * @privilege http://tizen.org/privilege/contact.read + * + * @return An error code + * @param[in] pListener The event listener + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error + */ + result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener); /** * Adds a contact to the address book. @n @@ -861,6 +877,9 @@ public: /** * Gets the change information of the contacts that have been changed after the specified change version. @n * + * @brief <i> [Deprecated] </i> + * @deprecated This method is deprecated. Instead of using this method, use GetChangedContactInfoListAfterN(). + * * @since 2.0 * @privlevel public * @privilege http://tizen.org/privilege/contact.read @@ -899,30 +918,114 @@ public: Tizen::Base::Collection::IList* GetChangedContactsAfterN(int version, int& latestVersion) const; /** + * Gets the change information of the contacts that have been changed after the specified change version. @n + * + * @since 2.1 + * @privlevel public + * @privilege http://tizen.org/privilege/contact.read + * + * @return A list of contact change information, @n + * else an empty list if there is no changed contact or @c null if an exception occurs (@ref ContactChangeInfo list) + * @param[in] version The change version + * @param[out] latestVersion The latest change version among the changed contacts + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_INVALID_ARG The specified @c version is invalid. + * @exception E_SYSTEM The method cannot proceed due to a severe system error + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see GetLatestVersion() + * + * The following example demonstrates how to use the %GetChangedContactInfoListAfterN() method. + * @code + * void + * MyApplication::GetChangedContacts(void) + * { + * IList* pChangedContacts = __pAddressbook->GetChangedContactInfoListAfterN (__version, __version); + * + * IEnumerator* pEnum = pChangedContacts->GetEnumeratorN(); + * while (pEnum->MoveNext() == E_SUCCESS) + * { + * ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent(); + * + * AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContctId(), pInfo->GetVersion()); + * } + * delete pEnum; + * pChangedContacts->RemoveAll(true); + * delete pChangedContacts; + * } + * @endcode + */ + Tizen::Base::Collection::IList* GetChangedContactInfoListN(int version, int& latestVersion) const; + + /** + * Gets the change information of the categories that have been changed after the specified version. + * + * @brief <i> [Deprecated] </i> + * @deprecated This method is deprecated. Instead of using this method, use GetChangedCategoryInfoListAfterN(). + * + * @since 2.0 + * @privlevel public + * @privilege http://tizen.org/privilege/contact.read + * + * @return A list of category change information, @n + * else an empty list if there is no changed category or @c null if an exception occurs (@ref CategoryChangeInfo list) + * + * @param[in] version The change version + * @param[out] latestVersion The latest change version among the changed categories + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_INVALID_ARG The specified @c version is invalid. + * @exception E_SYSTEM A system error has occurred. + * @remarks The specific error code can be accessed using the GetLastResult() method. + * @see GetLatestVersion() + * + * The following example demonstrates how to use the %GetChangedCategoriesAfterN() method. + * @code + * void + * MyApplication::GetChangedCategories(void) + * { + * IList* pChangedCategories = __pAddressbook->GetChangedCategoriesAfterN(__version, __version); + * + * IEnumerator* pEnum = pChangedCategories->GetEnumeratorN(); + * while (pEnum->MoveNext() == E_SUCCESS) + * { + * CategoryChangeInfo* pInfo = (CategoryChangeInfo*) pEnum->GetCurrent(); + * + * AppLog("Category changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetCategoryId(), pInfo->GetVersion()); + * } + * delete pEnum; + * pChangedCategories->RemoveAll(true); + * delete pChangedCategories; + * } + * @endcode + */ + Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const; + + /** * Gets the change information of the categories that have been changed after the specified version. * - * @since 2.0 - * @privlevel public - * @privilege http://tizen.org/privilege/contact.read + * @since 2.1 + * @privlevel public + * @privilege http://tizen.org/privilege/contact.read * - * @return A list of category change information, @n - * else an empty list if there is no changed category or @c null if an exception occurs (@ref CategoryChangeInfo list) - * - * @param[in] version The change version - * @param[out] latestVersion The latest change version among the changed categories - * @exception E_SUCCESS The method is successful. - * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. - * @exception E_INVALID_ARG The specified @c version is invalid. - * @exception E_SYSTEM A system error has occurred. - * @remarks The specific error code can be accessed using the GetLastResult() method. + * @return A list of category change information, @n + * else an empty list if there is no changed category or @c null if an exception occurs (@ref CategoryChangeInfo list) + * + * @param[in] version The change version + * @param[out] latestVersion The latest change version among the changed categories + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_INVALID_ARG The specified @c version is invalid. + * @exception E_SYSTEM The method cannot proceed due to a severe system error + * @remarks The specific error code can be accessed using the GetLastResult() method. * @see GetLatestVersion() * - * The following example demonstrates how to use the %GetChangedCategoriesAfterN() method. + * The following example demonstrates how to use the %GetChangedCategoryInfoListAfterN() method. * @code * void * MyApplication::GetChangedCategories(void) * { - * IList* pChangedCategories = __pAddressbook->GetChangedCategoriesAfterN(__version, __version); + * IList* pChangedCategories = __pAddressbook->GetChangedCategoryInfoAfterN(__version, __version); * * IEnumerator* pEnum = pChangedCategories->GetEnumeratorN(); * while (pEnum->MoveNext() == E_SUCCESS) @@ -937,7 +1040,7 @@ public: * } * @endcode */ - Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const; + Tizen::Base::Collection::IList* GetChangedCategoryInfoListN(int version, int& latestVersion) const; /** * Sets the user profile of this addressbook. To remove the user profile, @c null must be passed. diff --git a/inc/FSclAddressbookManager.h b/inc/FSclAddressbookManager.h index a78280d..a3e62f7 100644 --- a/inc/FSclAddressbookManager.h +++ b/inc/FSclAddressbookManager.h @@ -48,6 +48,7 @@ class UserProfile; class Addressbook; class AddressbookFilter; class IAddressbookEventListener; +class IAddressbookChangeEventListener; /** * @class AddressbookManager @@ -158,6 +159,10 @@ public: * The listener is called when a contact or a category has been changed. * To reset the event listener, @c null must be passed. * + * @brief <i> [Deprecated] </i> + * @deprecated This method and IAddressbookEventListener are deprecated. Instead of using this method, use SetAddressbookChangeEventListener() + * and IAddressbookChangeEventListener. + * * @since 2.0 * @privlevel public * @privilege http://tizen.org/privilege/contact.read @@ -171,6 +176,23 @@ public: result SetEventListener(IAddressbookEventListener* pListener); /** + * Sets addressbook change event listener. @n + * The listener is called when a contact or a category has been changed. + * To reset the event listener, @c null must be passed. + * + * @since 2.1 + * @privlevel public + * @privilege http://tizen.org/privilege/contact.read + * + * @return An error code + * @param[in] pListener The event listener + * @exception E_SUCCESS The method is successful. + * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method. + * @exception E_SYSTEM The method cannot proceed due to a severe system error + */ + result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener); + + /** * Adds a contact to the specified addressbook. @n * At least one property of the contact must have been set. @n * If the contact has been added successfully, a contact ID is assigned to it. @@ -618,6 +640,9 @@ public: /** * Gets the change information of the contacts that have been changed after the specified change version. * + * @brief <i> [Deprecated] </i> + * @deprecated This method is deprecated. + * * @since 2.0 * @privlevel public * @privilege http://tizen.org/privilege/contact.read @@ -659,6 +684,9 @@ public: /** * Gets the change information of the categories that have been changed after the specified change version. * + * @brief <i> [Deprecated] </i> + * @deprecated This method is deprecated. + * * @since 2.0 * @privlevel public * @privilege http://tizen.org/privilege/contact.read diff --git a/inc/FSclCalEvent.h b/inc/FSclCalEvent.h index 5c84992..aedd8e4 100644 --- a/inc/FSclCalEvent.h +++ b/inc/FSclCalEvent.h @@ -866,6 +866,17 @@ public: RecordId GetCalendarId(void) const; /** + * Gets the base event ID. + * This method return the id of the base recurring event for which this event is a recurrence exception. + * + * @since 2.1 + * + * @return The base event ID, if this event is an exception + * else #INVALID_RECORD_ID + */ + RecordId GetBaseEventId(void) const; + + /** * Copying of objects using this copy assignment operator is allowed. * * @since 2.0 diff --git a/inc/FSclCalendarbook.h b/inc/FSclCalendarbook.h index a195dc3..5c653c4 100644 --- a/inc/FSclCalendarbook.h +++ b/inc/FSclCalendarbook.h @@ -70,9 +70,6 @@ class CalendarbookFilter; *
* For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/calendarbook_namespace.htm">Calendar book</a>.
*
- * The following diagram illustrates the relationships between %Calendarbook and related classes.
- * @image html social_calendarbook_using_the_apis_classdiagram.png
- *
* The following example demonstrates how to use the %Calendarbook class to add calendarbook event.
* @code
@@ -467,6 +464,8 @@ public: * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
* @exception E_INVALID_ARG The specified @c recordId is #INVALID_RECORD_ID.
* @exception E_OBJ_NOT_FOUND The specified record is not found.
+ * @exception E_INVALID_OPERATION This method cannot be used for the recurrence exception of the recurring event. @n
+ * RemoveEventInstance() should be used instead of this method. @b Since: @b 2.1
* @exception E_SYSTEM A system error has occurred.
*/
result RemoveEvent(CalEvent& event);
@@ -484,6 +483,8 @@ public: * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
* @exception E_INVALID_ARG The specified @c eventId is #INVALID_RECORD_ID.
* @exception E_OBJ_NOT_FOUND The specified record is not found.
+ * @exception E_INVALID_OPERATION This method cannot be used for the recurrence exception of the recurring event. @n
+ * RemoveEventInstance() should be used instead of this method. @b Since: @b 2.1
* @exception E_SYSTEM A system error has occurred.
*/
result RemoveEvent(RecordId eventId);
@@ -539,8 +540,10 @@ public: * - The specified @c event is not #RECORD_TYPE_EVENT. @n
* - The specified @c event is not an entry type instance. @n
* - The date of the event is invalid. @n
- * The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
+ * The valid range of the date can be referenced from GetMaxDateTime() and GetMinDateTime().
* @exception E_OBJ_NOT_FOUND The specified record is not found.
+ * @exception E_INVALID_OPERATION This method cannot be used for the recurrence exception of the recurring event. @n
+ * UpdateEventInstance() should be used instead of this method. @b Since: @b 2.1
* @exception E_SYSTEM A system error has occurred.
*/
result UpdateEvent(const CalEvent& event);
@@ -916,7 +919,7 @@ public: */
result AddCalendar(Calendar& calendar);
- /*
+ /**
* Adds a calendar that is associated with the specified account. @n
* After adding the calendar to the database successfully, the calendar has a valid calendar ID.
*
@@ -925,13 +928,13 @@ public: * @privilege http://tizen.org/privilege/calendar.write
*
* @return An error code
- * @param[in,out] calendar The calendar to add
+ * @param[in,out] calendar The calendar to add
* @param[in] accountId The account Id
* @exception E_SUCCESS The method is successful.
* @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
- * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
- * - The record ID of the calendar is not #INVALID_RECORD_ID. @n
- * - The specified @c accountId is invalid.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The record ID of the calendar is not #INVALID_RECORD_ID. @n
+ * - The specified @c accountId is invalid.
* @exception E_OBJ_NOT_FOUND The specified account is not found.
* @exception E_STORAGE_FULL The storage is insufficient.
* @exception E_SYSTEM A system error has occurred.
@@ -1002,18 +1005,76 @@ public: * @privilege http://tizen.org/privilege/calendar.write
*
* @return An error code
- * @param[in] eventInstance The event instance to remove @n
- * The @c eventInstance must be an instance of the recurring event.
+ * @param[in] eventInstance The event instance to remove @n
+ * The @c eventInstance must be an instance of the recurring event.
* @exception E_SUCCESS The method is successful.
* @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
- * @exception E_INVALID_ARG The instance is invalid.
- * @exception E_OBJ_NOT_FOUND The instance is not found.
+ * @exception E_INVALID_ARG The instance is invalid.
+ * @exception E_OBJ_NOT_FOUND The original event of the @eventInstance is not found.
* @exception E_SYSTEM A system error has occurred.
* @remarks The instance's start time is added to the recurrence of original event as exception date.
*/
result RemoveEventInstance(const CalEventInstance& eventInstance);
/**
+ * Update the specified recurring event instance(@ref CalEventInstance). This method can be used for defining exception of the recurring event. @n
+ * In order to update an event instance, you should use copy of its original event(@ref CalEventInstance::GetOriginalEventId()). @n
+ * You can modify the properties of copy of the original event and use it as the second parameter of this method. @n
+ * (The start/end time of the original event should be set with the start/end time of the event instance.) @n
+ * This method adds the modified copy of the original event as a new event. Therefore the new event id will be assigned to it through @c event's record id @n
+ * and its existing event id inside the modified copy of the original event will become the base event id of the new event. @n
+ * However this method only updates the properties of the event, not add a new event, once added.
+ *
+ * @code
+
+ void UpdateRecurringEventInstance(const CalEventInstance& eventInstance)
+ {
+ CalEvent* pEvent = pCalendarbook->GetEventN(eventInstance.GetOriginalEventId());
+ if (pEvent == null)
+ {
+ AppLogException("GetEventN() has failed");
+ return;
+ }
+
+ // Sets the start time and end time
+ pEvent->SetStartAndEndTime(eventInstance.GetStartTime(), eventInstance.GetEndTime());
+
+ // Modifies the properties
+ pEvent->SetLocation(L"Meeting room on 11th floor");
+
+ // Updates the instance
+ result r = pCalendarbook->UpdateEventInstance(eventInstance, *pEvent);
+ if (IsFailed(r))
+ {
+ AppLogException("UpdateEventInstance() has failed");
+ delete pEvent;
+ return;
+ }
+
+ delete pEvent;
+ }
+
+ * @endcode
+ *
+ * @since 2.1
+ * @privlevel public
+ * @privilege http://tizen.org/privilege/calendar.write
+ *
+ * @return An error code
+ * @param[in] eventInstance The event instance to update @n
+ * The @c eventInstance must be an instance of the recurring event.
+ * @param[in,out] event The modified copy of the original event @n
+ * @exception E_SUCCESS The method is successful.
+ * @exception E_PRIVILEGE_DENIED The application does not have the privilege to call this method.
+ * @exception E_INVALID_ARG Either of the following conditions has occurred: @n
+ * - The instance is invalid. @n
+ * - @c event is not referring to the original event.
+ * @exception E_OBJ_NOT_FOUND The original event of the @c eventInstance is not found.
+ * @exception E_SYSTEM The method cannot proceed due to a severe system error.
+ */
+ result UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event);
+
+ /**
* Gets the latest version of calendarbook.
*
* @since 2.0
diff --git a/inc/FSclContact.h b/inc/FSclContact.h index 4dcdc29..0b2bf73 100644 --- a/inc/FSclContact.h +++ b/inc/FSclContact.h @@ -222,12 +222,14 @@ public: * @return An error code * @param[in] id The ID of the property whose value is to set * @param[in] value A new string value to set - * @exception E_SUCCESS The method is successful. - * @exception E_INVALID_ARG The @c id is #CONTACT_PROPERTY_ID_DISPLAY_NAME or #CONTACT_PROPERTY_ID_THUMBNAIL, or + * @exception E_SUCCESS The method is successful. + * @exception E_INVALID_ARG The @c id is #CONTACT_PROPERTY_ID_DISPLAY_NAME or @if OSPDEPREC #CONTACT_PROPERTY_ID_THUMBNAIL, or @endif * the ringtone file path (value) is invalid if @c id is #CONTACT_PROPERTY_ID_RINGTONE. * @remarks - * - The #CONTACT_PROPERTY_ID_DISPLAY_NAME and #CONTACT_PROPERTY_ID_THUMBNAIL properties cannot be set. @n + * - The #CONTACT_PROPERTY_ID_DISPLAY_NAME property cannot be set. @n * - The #CONTACT_PROPERTY_ID_RINGTONE can be set to the path string of the ringtone file. @n + * @if OSPDEPREC + * - The The #CONTACT_PROPERTY_ID_THUMBNAIL property cannot be set. @n * - In case @c id is set to #CONTACT_PROPERTY_ID_NICK_NAME, @n * - If this contact has nicknames, the first nickname among them is set to the @c value. @n * - If not, a new nickname is added to this contact. @n @@ -240,6 +242,7 @@ public: * - In case @c id is set to #CONTACT_PROPERTY_ID_JOB_TITLE, @n * - If this contact has organizations, the job title value of the first organization among them is set to the @c value. @n * - If not, a new organization is added to this contact. @n + * @endif */ result SetValue(ContactPropertyId id, const Tizen::Base::String& value); @@ -279,6 +282,7 @@ public: * @exception E_SUCCESS The method is successful. * @exception E_INVALID_ARG The property with the specified contact property ID is not of Tizen::Base::DateTime type, or * the property is read-only. + * @if OSPDEPREC * @remarks * - In case @c id is set to #CONTACT_PROPERTY_ID_BIRTHDAY, @n * - 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. @n @@ -286,6 +290,7 @@ public: * - In case @c id is set to #CONTACT_PROPERTY_ID_ANNIVERSARY, @n * - 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. @n * - If not, a new event whose type is #CONTACT_EVENT_TYPE_ANNIVERSARY is added to this contact. @n + * @endif */ result SetValue(ContactPropertyId id, const Tizen::Base::DateTime& value); diff --git a/inc/FSclIAddressbookChangeEventListener.h b/inc/FSclIAddressbookChangeEventListener.h new file mode 100644 index 0000000..97ab761 --- /dev/null +++ b/inc/FSclIAddressbookChangeEventListener.h @@ -0,0 +1,149 @@ +// +// Open Service Platform +// Copyright (c) 2012 Samsung Electronics Co., Ltd. +// +// Licensed under the Apache License, Version 2.0 (the License); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. +// +/** +* @file FSclIAddressbookChangeEventListener.h +* @brief This is the header file for the %IAddressbookChangeEventListener interface. +* +* This header file contains the declarations of the %IAddressbookChangeEventListener interface. +*/ + +#ifndef _FSCL_IADDRESSBOOK_CHANGE_EVENT_LISTENER_H_ +#define _FSCL_IADDRESSBOOK_CHANGE_EVENT_LISTENER_H_ + +#include <FBaseRtIEventListener.h> + +namespace Tizen { namespace Base { namespace Collection { +class IList; +}}} + +namespace Tizen { namespace Social +{ + +/** + * @interface IAddressbookChangeEventListener + * @brief This interface provides a listener that receives the events associated with contact and category changes. + * + * @since 2.1 + * + * The %IAddressbookChangeEventListener interface provides a listener that receives the events associated with contact and category changes. + * + */ + +class _OSP_EXPORT_ IAddressbookChangeEventListener + : virtual public Tizen::Base::Runtime::IEventListener +{ +public: + /** + * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n + * are called when the destructor of this interface is called. + * + * @since 2.1 + */ + virtual ~IAddressbookChangeEventListener(void) {} + + /** + * Called to notify when contacts are changed. @n + * A list of ContactChangeInfo instances is passed. + * + * @since 2.1 + * + * @param[in] contactChangeInfoList The list of contact change information (@ref ContactChangeInfo list) + * @remarks This listener method is called when the following changes have occurred: @n + + * - Contacts are added, updated, or removed + * - Contacts are added/removed to/from categories + * + * The following example demonstrates how to use the %OnContactsChanged() method. + * @code + * void + * MyApplication::OnContactsChangedN(const IList& contactChangeInfoList) + * { + * IEnumerator* pEnum = contactChangeInfoList.GetEnumeratorN(); + * while (pEnum->MoveNext() == E_SUCCESS) + * { + * ContactChangeInfo* pInfo = (ContactChangeInfo*) pEnum->GetCurrent(); + * + * AppLog("Contact changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetContctId(), pInfo->GetVersion()); + * } + * delete pEnum; + * } + * @endcode + * + */ + virtual void OnContactsChanged(const Tizen::Base::Collection::IList& contactChangeInfoList) = 0; + + /** + * Called to notify when categories are changed. @n + * A list of CategoryChangeInfo instances are passed. + * + * @since 2.1 + * + * @param[in] categoryChangeInfoList The list of category change information (@ref CategoryChangeInfo list) + * @remarks This listener method is called when the following changes have occurred: @n + * - Categories are added, updated, or removed + * + * The following example demonstrates how to use the %OnCategoriesChanged() method. + * @code + * void + * MyApplication::OnCategoriesChangedN(const IList& categoryChangeInfoList) + * { + * IEnumerator* pEnum = categoryChangeInfoList.GetEnumeratorN(); + * while (pEnum->MoveNext() == E_SUCCESS) + * { + * CategoryChangeInfo* pInfo = (CategoryChangeInfo*) pEnum->GetCurrent(); + * + * AppLog("Category changed: type(%d), id(%d), version(%d)", pInfo->GetChangeType(), pInfo->GetCategoryId(), pInfo->GetVersion()); + * } + * delete pEnum; + * } + * @endcode + * + */ + virtual void OnCategoriesChanged(const Tizen::Base::Collection::IList& categoryChangeInfoList) = 0; + +protected: + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IAddressbookChangeEventListener_Reserved1(void){ } + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IAddressbookChangeEventListener_Reserved2(void){ } + + // + // This method is for internal use only. Using this method can cause behavioral, security-related, + // and consistency-related issues in the application. + // This method is reserved and may change its name at any time without prior notice. + // + // @since 2.1 + // + virtual void IAddressbookChangeEventListener_Reserved3(void){ } +}; // IAddressbookChangeEventListener + +}} // Tizen::Social + +#endif // _FSCL_IADDRESSBOOK_CHANGE_EVENT_LISTENER_H_ diff --git a/inc/FSclIAddressbookEventListener.h b/inc/FSclIAddressbookEventListener.h index ad6a7cb..4715316 100644 --- a/inc/FSclIAddressbookEventListener.h +++ b/inc/FSclIAddressbookEventListener.h @@ -23,7 +23,6 @@ #ifndef _FSCL_IADDRESSBOOK_EVENT_LISTENER_H_ #define _FSCL_IADDRESSBOOK_EVENT_LISTENER_H_ -#include <FSclRecord.h> #include <FBaseRtIEventListener.h> namespace Tizen { namespace Base { namespace Collection { @@ -37,6 +36,8 @@ namespace Tizen { namespace Social * @interface IAddressbookEventListener * @brief This interface provides a listener that receives the events associated with contact and category changes. * + * @brief <i> [Deprecated] </i> + * @deprecated This interface is deprecated. Instead of using this listener, use IAddressbookChangeEventListener. * @since 2.0 * * The %IAddressbookEventListener interface provides a listener that receives the events associated with contact and category changes. diff --git a/inc/FSclIRecordListener.h b/inc/FSclIRecordListener.h index 5401546..2e2c8da 100644 --- a/inc/FSclIRecordListener.h +++ b/inc/FSclIRecordListener.h @@ -35,14 +35,18 @@ namespace Tizen { namespace Social { /** + * @if OSPDEPREC * @interface IRecordListener - * @brief This interface represents a listener to asynchronously retrieve the records from the Calendarbook or Addressbook. + * @brief <i> [Deprecated] </i> This interface represents a listener to asynchronously retrieve the records from the Calendarbook or Addressbook. + * + * @deprecated This interface is deprecated because the @ref Calendarbook::GetEventInstances method is deprecated. * * @since 2.0 * * The %IRecordListener interface represents a listener to asynchronously retrieve the records from the Calendarbook or Addressbook. * * For more information on the class features, see <a href="../org.tizen.native.appprogramming/html/guide/social/social_records.htm">Social Records</a>. + * @endif */ class _OSP_EXPORT_ IRecordListener : virtual public Tizen::Base::Runtime::IEventListener @@ -50,16 +54,25 @@ class _OSP_EXPORT_ IRecordListener public: /** + * @if OSPDEPREC * This polymorphic destructor should be overridden if required. This way, the destructors of the derived classes @n * are called when the destructor of this interface is called. * + * @brief <i> [Deprecated] </i> + * @deprecated This method is deprecated because the %IRecordListener interface is deprecated. + * * @since 2.0 + * @endif */ virtual ~IRecordListener(void) {} /** + * @if OSPDEPREC * Called when the requested records are retrieved. * + * @brief <i> [Deprecated] </i> + * @deprecated This method is deprecated because the %IRecordListener interface is deprecated. + * * @since 2.0 * * @param[in] reqId The request ID @@ -71,6 +84,7 @@ public: * @exception E_SYSTEM An error has occurred on the local storage side. * @remarks After using @c pRecords, the application must delete it. * @see Calendarbook::GetEventInstances() + * @endif */ virtual void OnRecordsReceivedN(RequestId reqId, Tizen::Base::Collection::IList* pRecords, result r) = 0; diff --git a/inc/FSclRecurrence.h b/inc/FSclRecurrence.h index 0dad068..1f263e9 100644 --- a/inc/FSclRecurrence.h +++ b/inc/FSclRecurrence.h @@ -442,11 +442,10 @@ public: /** * Sets the day of the week that represents the days when the event should recur. @n - * The valid values range between #CAL_SUNDAY and #CAL_SATURDAY. @n - * Any values other than #CAL_SUNDAY ~ #CAL_SATURDAY are ignored. @n - * The Frequency property must be set before setting this property. - * This property is valid for the following #RecurFrequency enumeration types: #FREQ_WEEKLY, #FREQ_MONTHLY, and #FREQ_YEARLY. - * If the frequency is #FREQ_WEEKLY, the value of the day may be a combination of days, such as #CAL_MONDAY|#CAL_FRIDAY. + * The Frequency property must be set before setting this property. @n + * This property is valid for the following #RecurFrequency enumeration types: #FREQ_WEEKLY, #FREQ_MONTHLY, and #FREQ_YEARLY. @n + * The value of the @c day may be a combination of several day of week. @n + * In other words, the @c day should be an item or a combination of #CalDayOfWeek, such as #CAL_SUNDAY or #CAL_MONDAY|#CAL_FRIDAY. * * @since 2.0 * diff --git a/inc/FSocial.h b/inc/FSocial.h index 353f418..e01c260 100644 --- a/inc/FSocial.h +++ b/inc/FSocial.h @@ -44,6 +44,7 @@ #include <FSclEmail.h> #include <FSclEmailContact.h> #include <FSclIAddressbookEventListener.h> +#include <FSclIAddressbookChangeEventListener.h> #include <FSclICalendarbookEventListener.h> #include <FSclIRecordEventListener.h> #include <FSclIRecordListener.h> @@ -80,6 +81,16 @@ * * For more information on the %Social namespace features, see <a href="../org.tizen.native.appprogramming/html/guide/social/social_namespace.htm">Social Guide</a>. * + * The following diagrams illustrate the relationships between the classes belonging to the Social namespace. + * + * [Account] + * @image html social_account_classdiagram.png + * + * [Addressbook] + * @image html social_addressbook_classdiagram.png + * + * [Calendarbook] + * @image html social_calendarbook_using_the_apis_classdiagram.png * */ namespace Tizen { namespace Social diff --git a/packaging/osp-social.spec b/packaging/osp-social.spec index a71cefd..4056d33 100755 --- a/packaging/osp-social.spec +++ b/packaging/osp-social.spec @@ -4,7 +4,7 @@ Name: osp-social Summary: osp social library Version: 1.2.1.7 -Release: 2 +Release: 4 Group: System/Libraries License: Apache License, Version 2.0 Source0: %{name}-%{version}.tar.gz diff --git a/src/FSclAddressbook.cpp b/src/FSclAddressbook.cpp index 8596df2..8c6832c 100644 --- a/src/FSclAddressbook.cpp +++ b/src/FSclAddressbook.cpp @@ -97,6 +97,20 @@ Addressbook::SetEventListener(IAddressbookEventListener* pListener) return E_SUCCESS; } +result +Addressbook::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener) +{ + SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + SysAssertf(__pAddressbookImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = __pAddressbookImpl->SetAddressbookChangeEventListener(pListener); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + String Addressbook::GetName(void) const { @@ -491,6 +505,34 @@ Addressbook::GetChangedCategoriesAfterN(int version, int& latestVersion) const return pList; } +IList* +Addressbook::GetChangedContactInfoListN(int version, int& latestVersion) const +{ + SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + SysAssertf(__pAddressbookImpl != null, + "Not yet constructed. Construct() should be called before use."); + + IList* pList = __pAddressbookImpl->GetChangedContactInfoListN(version, latestVersion); + SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pList; +} + +IList* +Addressbook::GetChangedCategoryInfoListN(int version, int& latestVersion) const +{ + SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, null, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + SysAssertf(__pAddressbookImpl != null, + "Not yet constructed. Construct() should be called before use."); + + IList* pList = __pAddressbookImpl->GetChangedCategoryInfoListN(version, latestVersion); + SysTryReturn(NID_SCL, pList != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pList; +} + result Addressbook::AddContacts(const IList& contactList, IListT<RecordId>* pContactIdList) { diff --git a/src/FSclAddressbookManager.cpp b/src/FSclAddressbookManager.cpp index f7a4f64..6898c65 100644 --- a/src/FSclAddressbookManager.cpp +++ b/src/FSclAddressbookManager.cpp @@ -92,6 +92,20 @@ AddressbookManager::SetEventListener(IAddressbookEventListener* pListener) return E_SUCCESS; } +result +AddressbookManager::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener) +{ + SysTryReturn(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CONTACT_READ) == E_SUCCESS, E_PRIVILEGE_DENIED, E_PRIVILEGE_DENIED, + "[%s] The application does not have the privilege to call this method.", GetErrorMessage(E_PRIVILEGE_DENIED)); + SysAssertf(__pAddressbookManagerImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = __pAddressbookManagerImpl->SetAddressbookChangeEventListener(pListener); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + Addressbook* AddressbookManager::CreateAddressbookN(AccountId accountId, const String& name) { diff --git a/src/FSclCalEvent.cpp b/src/FSclCalEvent.cpp index 7281433..3ea358c 100644 --- a/src/FSclCalEvent.cpp +++ b/src/FSclCalEvent.cpp @@ -413,4 +413,10 @@ CalEvent::GetCalendarId(void) const return __pCalEventImpl->GetCalendarId(); } +RecordId +CalEvent::GetBaseEventId(void) const +{ + return __pCalEventImpl->GetBaseEventId(); +} + }} // Tizen::Social diff --git a/src/FSclCalendarbook.cpp b/src/FSclCalendarbook.cpp index d9c3425..84dd6fe 100644 --- a/src/FSclCalendarbook.cpp +++ b/src/FSclCalendarbook.cpp @@ -515,6 +515,20 @@ Calendarbook::RemoveEventInstance(const CalEventInstance& eventInstance) return E_SUCCESS; } +result +Calendarbook::UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event) +{ + SysTryReturnResult(NID_SCL, _AccessController::CheckUserPrivilege(_PRV_CALENDAR_WRITE) == E_SUCCESS, + E_PRIVILEGE_DENIED, "The application does not have the privilege to call this method."); + SysAssertf(__pCalendarbookImpl != null, + "Not yet constructed. Construct() should be called before use."); + + result r = __pCalendarbookImpl->UpdateEventInstance(eventInstance, event); + SysTryReturn(NID_SCL, r == E_SUCCESS, r, r, "[%s] Propagating.", GetErrorMessage(r)); + + return E_SUCCESS; +} + int Calendarbook::GetLatestVersion(void) const { diff --git a/src/FScl_AccountManagerImpl.cpp b/src/FScl_AccountManagerImpl.cpp index aeecc48..603a4be 100644 --- a/src/FScl_AccountManagerImpl.cpp +++ b/src/FScl_AccountManagerImpl.cpp @@ -74,6 +74,7 @@ _AccountManagerImpl::AddAccount(Account& account) int accountDbId = 0; int ret = account_insert_to_db(accountHandle, &accountDbId); SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The application does not register the account provider.", GetErrorMessage(E_INVALID_OPERATION)); + SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_NOT_ALLOW_MULTIPLE, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The multiple accounts are not supported.", GetErrorMessage(E_INVALID_OPERATION)); SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM)); { @@ -130,6 +131,7 @@ _AccountManagerImpl::RemoveAccount(AccountId accountId) int ret = account_delete_from_db_by_id(accountId); SysTryReturnResult(NID_SCL, ret != ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER, E_INVALID_OPERATION, "The application does not register the account provider."); + SysTryReturnResult(NID_SCL, ret != ACCOUNT_ERROR_PERMISSION_DENIED, E_INVALID_OPERATION, "The application has no permission to remove this account."); SysTryReturnResult(NID_SCL, ret != ACCOUNT_ERROR_RECORD_NOT_FOUND, E_OBJ_NOT_FOUND, "The specified account is not found."); SysTryReturnResult(NID_SCL, ret == ACCOUNT_ERROR_NONE, E_SYSTEM, "The method cannot proceed due to a severe system error."); @@ -149,6 +151,7 @@ _AccountManagerImpl::UpdateAccount(const Account& account) int ret = account_update_to_db_by_id(accountHandle, account.GetId()); SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_NOT_REGISTERED_PROVIDER, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The application does not register the account provider.", GetErrorMessage(E_INVALID_OPERATION)); + SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_PERMISSION_DENIED, r = E_INVALID_OPERATION, E_INVALID_OPERATION, "[%s] The application has no permission to update this account.", GetErrorMessage(E_INVALID_OPERATION)); SysTryCatch(NID_SCL, ret != ACCOUNT_ERROR_RECORD_NOT_FOUND, r = E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[%s] The specified @c account does not exist.", GetErrorMessage(E_OBJ_NOT_FOUND)); SysTryCatch(NID_SCL, ret == ACCOUNT_ERROR_NONE, r = E_SYSTEM, E_SYSTEM, "[%s] The method cannot proceed due to a severe system error.", GetErrorMessage(E_SYSTEM)); diff --git a/src/FScl_AddressbookImpl.cpp b/src/FScl_AddressbookImpl.cpp index d1a486a..3a60adc 100644 --- a/src/FScl_AddressbookImpl.cpp +++ b/src/FScl_AddressbookImpl.cpp @@ -33,6 +33,7 @@ #include <FSclCategoryChangeInfo.h> #include <FSclAddressbook.h> #include <FSclIAddressbookEventListener.h> +#include <FSclIAddressbookChangeEventListener.h> #include <FSclIRecordEventListener.h> #include <FApp_AppInfo.h> #include <FBaseSysLog.h> @@ -59,6 +60,7 @@ namespace Tizen { namespace Social _AddressbookImpl::_AddressbookImpl(void) : __pIRecordEventListener(null) , __pIAddressbookEventListener(null) + , __pIAddressbookChangeEventListener(null) , __dbVersionForContact(0) , __dbVersionForGroup(0) , __dbVersionForRelation(0) @@ -70,7 +72,7 @@ _AddressbookImpl::_AddressbookImpl(void) _AddressbookImpl::~_AddressbookImpl(void) { - if (__pIAddressbookEventListener != null || __pIRecordEventListener != null) + if (__pIAddressbookEventListener != null || __pIRecordEventListener != null || __pIAddressbookChangeEventListener != null) { _ContactDbMonitor* pDbMonitor = _ContactDbMonitor::GetInstance(); if (pDbMonitor != null) @@ -120,14 +122,8 @@ _AddressbookImpl::SetRecordEventListener(IRecordEventListener* pListener) if (pListener != null) { - if (__pIAddressbookEventListener == null && __pIRecordEventListener == null) + if (__pIAddressbookEventListener == null && __pIRecordEventListener == null && __pIAddressbookChangeEventListener == null) { - __dbVersionForContact = GetLatestVersion(); - SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - - __dbVersionForGroup = __dbVersionForContact; - __dbVersionForRelation = __dbVersionForContact; - _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -135,12 +131,19 @@ _AddressbookImpl::SetRecordEventListener(IRecordEventListener* pListener) SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); } + __dbVersionForContact = GetLatestVersion(); + SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __dbVersionForGroup = __dbVersionForContact; + __dbVersionForRelation = __dbVersionForContact; + __pIAddressbookEventListener = null; - __pIRecordEventListener = const_cast<IRecordEventListener*>(pListener); + __pIAddressbookChangeEventListener = null; + __pIRecordEventListener = pListener; } else { - if (__pIAddressbookEventListener != null || __pIRecordEventListener != null) + if (__pIAddressbookEventListener != null || __pIRecordEventListener != null || __pIAddressbookChangeEventListener != null) { _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())) @@ -148,6 +151,7 @@ _AddressbookImpl::SetRecordEventListener(IRecordEventListener* pListener) } __pIAddressbookEventListener = null; + __pIAddressbookChangeEventListener = null; __pIRecordEventListener = null; } @@ -163,14 +167,54 @@ _AddressbookImpl::SetAddressbookEventListener(IAddressbookEventListener* pListen if (pListener != null) { - if (__pIAddressbookEventListener == null && __pIRecordEventListener == null) + if (__pIAddressbookEventListener == null && __pIRecordEventListener == null && __pIAddressbookChangeEventListener == null) { - __dbVersionForContact = GetLatestVersion(); - SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); + SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = pContactDbMonitor->AddListener(*this); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } - __dbVersionForGroup = __dbVersionForContact; - __dbVersionForRelation = __dbVersionForContact; + __dbVersionForContact = GetLatestVersion(); + SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + __dbVersionForGroup = __dbVersionForContact; + __dbVersionForRelation = __dbVersionForContact; + + __pIRecordEventListener = null; + __pIAddressbookChangeEventListener = null; + __pIAddressbookEventListener = pListener; + } + else + { + if (__pIAddressbookEventListener != null || __pIRecordEventListener != null || __pIAddressbookChangeEventListener != null) + { + _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); + SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pContactDbMonitor->RemoveListener(*this); + } + + __pIAddressbookEventListener = null; + __pIAddressbookChangeEventListener = null; + __pIRecordEventListener = null; + } + + return E_SUCCESS; +} + +result +_AddressbookImpl::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener) +{ + SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + result r = E_SUCCESS; + + if (pListener != null) + { + if (__pIAddressbookEventListener == null && __pIAddressbookChangeEventListener == null && __pIRecordEventListener == null) + { _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -178,12 +222,19 @@ _AddressbookImpl::SetAddressbookEventListener(IAddressbookEventListener* pListen SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); } + __dbVersionForContact = GetLatestVersion(); + SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __dbVersionForGroup = __dbVersionForContact; + __dbVersionForRelation = __dbVersionForContact; + __pIRecordEventListener = null; - __pIAddressbookEventListener = pListener; + __pIAddressbookEventListener = null; + __pIAddressbookChangeEventListener = pListener; } else { - if (__pIAddressbookEventListener != null || __pIRecordEventListener != null) + if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null || __pIRecordEventListener != null) { _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -192,6 +243,7 @@ _AddressbookImpl::SetAddressbookEventListener(IAddressbookEventListener* pListen } __pIAddressbookEventListener = null; + __pIAddressbookChangeEventListener = null; __pIRecordEventListener = null; } @@ -1056,15 +1108,33 @@ _AddressbookImpl::GetChangedCategoriesAfterN(int version, int& latestVersion) co } IList* +_AddressbookImpl::GetChangedContactInfoListN(int version, int& latestVersion) const +{ + SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version); + SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + IList* pChangedContacts = _AddressbookUtil::SearchWithVersionN<__ContactsContactUpdatedInfo, ContactChangeInfo>(__addressbookId, version, latestVersion); + SysTryReturn(NID_SCL, pChangedContacts != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + return pChangedContacts; +} + +IList* +_AddressbookImpl::GetChangedCategoryInfoListN(int version, int& latestVersion) const +{ + return GetChangedGroupsAfterN(version, latestVersion); +} + +IList* _AddressbookImpl::GetChangedGroupsAfterN(int version, int& latestVersion) const { SysTryReturn(NID_SCL, version >= 0, null, E_INVALID_ARG, "[%s] Invalid argument is used. version %d must be greater that or equal 0.", GetErrorMessage(E_INVALID_ARG), version); SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - IList* pChangedRelations = _AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(__addressbookId, version, latestVersion); - SysTryReturn(NID_SCL, pChangedRelations != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + IList* pChangedGroups = _AddressbookUtil::SearchWithVersionN<__ContactsGroupUpdatedInfo, CategoryChangeInfo>(__addressbookId, version, latestVersion); + SysTryReturn(NID_SCL, pChangedGroups != null, null, GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - return pChangedRelations; + return pChangedGroups; } IList* @@ -1233,43 +1303,110 @@ _AddressbookImpl::SetUserProfile(const UserProfile* pUserProfile) SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); int recordId = 0; + int existingRecordId = 0; int ret = CONTACTS_ERROR_NONE; + result r = E_SUCCESS; contacts_record_h recordHandle = null; std::unique_ptr<UserProfile> pExistingProfile(GetUserProfileN()); - if (pExistingProfile.get() != null) - { - int intValue = 0; - recordHandle = _UserProfileImpl::GetInstance(*(pExistingProfile.get()))->GetUserProfileHandle(); - contacts_record_get_int(recordHandle, _contacts_my_profile.id, &intValue); + SysTryReturn(NID_SCL, pExistingProfile != null || GetLastResult() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); - ret = contacts_db_delete_record(_contacts_my_profile._uri, intValue); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + if (pExistingProfile != null) + { + recordHandle = _UserProfileImpl::GetInstance(*pExistingProfile)->GetUserProfileHandle(); + contacts_record_get_int(recordHandle, _contacts_my_profile.id, &existingRecordId); } if (pUserProfile != null) { SysTryReturn(NID_SCL, !((_UserProfileImpl::GetInstance(*pUserProfile))->IsEmpty()), E_SYSTEM, E_SYSTEM, "[%s] UserProfile is Empty.", GetErrorMessage(E_SYSTEM)); - UserProfile* pProfile = const_cast<UserProfile*>(pUserProfile); - SysTryReturn(NID_SCL, pProfile != null, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + recordHandle = _UserProfileImpl::GetInstance(*pUserProfile)->GetUserProfileHandle(); + contacts_record_get_int(recordHandle, _contacts_my_profile.id, &recordId); + if (recordId == 0) + { + if (pExistingProfile != null) + { + ret = contacts_db_delete_record(_contacts_my_profile._uri, existingRecordId); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + } - recordHandle = _UserProfileImpl::GetInstance(*pProfile)->GetUserProfileHandle(); + contacts_record_h newRecordHandle = null; + ret = contacts_record_clone(recordHandle, &newRecordHandle); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - ret = contacts_record_set_int(recordHandle, _contacts_my_profile.address_book_id, __addressbookId); - SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + ret = contacts_record_set_int(newRecordHandle, _contacts_my_profile.address_book_id, __addressbookId); + if (ret != CONTACTS_ERROR_NONE) + { + contacts_record_destroy(newRecordHandle, true); + SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + return E_SYSTEM; + } - ret = contacts_db_insert_record(recordHandle, &recordId); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + ret = contacts_db_insert_record(newRecordHandle, &recordId); + contacts_record_destroy(newRecordHandle, true); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + } + else if (recordId > 0) + { + if (recordId == existingRecordId) + { + contacts_record_h newRecordHandle = null; + ret = contacts_record_clone(recordHandle, &newRecordHandle); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + ret = contacts_db_update_record(newRecordHandle); + contacts_record_destroy(newRecordHandle, true); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + } + else + { + if (pExistingProfile != null) + { + ret = contacts_db_delete_record(_contacts_my_profile._uri, existingRecordId); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + } - ret = contacts_db_get_record(_contacts_my_profile._uri, recordId, &recordHandle); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_NO_DATA, E_OBJ_NOT_FOUND, E_OBJ_NOT_FOUND, "[E_OBJ_NOT_FOUND] The contact is not found."); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OBJ_NOT_FOUND, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + contacts_record_h newRecordHandle = null; + ret = contacts_record_create(_contacts_my_profile._uri, &newRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - _UserProfileImpl::GetInstance(*pProfile)->SetUserProfileHandle(recordHandle); + r = CopyMyProfileContents(recordHandle, newRecordHandle); + if (r != E_SUCCESS) + { + contacts_record_destroy(newRecordHandle, true); + SysLogException(NID_SCL, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + return E_OUT_OF_MEMORY; + + } + + ret = contacts_record_set_int(newRecordHandle, _contacts_my_profile.address_book_id, __addressbookId); + if (ret != CONTACTS_ERROR_NONE) + { + contacts_record_destroy(newRecordHandle, true); + SysLogException(NID_SCL, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + return E_SYSTEM; + } + + ret = contacts_db_insert_record(newRecordHandle, &recordId); + contacts_record_destroy(newRecordHandle, true); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + } + } + } + else + { + if (pExistingProfile != null) + { + ret = contacts_db_delete_record(_contacts_my_profile._uri, existingRecordId); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); + } } return E_SUCCESS; @@ -1321,10 +1458,367 @@ _AddressbookImpl::IsUserProfileChangedAfter(int version) const return false; } +result +_AddressbookImpl::CopyMyProfileContents(contacts_record_h srcHandle, contacts_record_h dstHandle) +{ + result r = E_SUCCESS; + int ret = CONTACTS_ERROR_NONE; + int intValue = 0; + unsigned int count = 0; + unsigned int i = 0; + char* pCharValue = null; + + contacts_record_h srcRecordHandle = null; + contacts_record_h dstRecordHandle = null; + + // name + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.name, &count); + if (count > 0) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.name, 0, &srcRecordHandle); + + ret = contacts_record_create(_contacts_name._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle nameHandle(dstRecordHandle); + + contacts_record_get_str(srcRecordHandle, _contacts_name.first, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.first, pCharValue); + + contacts_record_get_str(srcRecordHandle, _contacts_name.last, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.last, pCharValue); + + contacts_record_get_str(srcRecordHandle, _contacts_name.addition, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.addition, pCharValue); + + contacts_record_get_str(srcRecordHandle, _contacts_name.suffix, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.suffix, pCharValue); + + contacts_record_get_str(srcRecordHandle, _contacts_name.prefix, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.prefix, pCharValue); + + contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_first, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_first, pCharValue); + + contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_middle, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_middle, pCharValue); + + contacts_record_get_str(srcRecordHandle, _contacts_name.phonetic_last, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_name.phonetic_last, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.name, dstRecordHandle); + + nameHandle.Release(); + } + + // company + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.company, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.company, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_company._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle companyHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_company.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_company.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.name, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.name, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.department, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.department, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.job_title, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.job_title, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.assistant_name, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.assistant_name, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.role, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.role, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.logo, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.logo, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.location, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.location, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.description, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.description, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_company.phonetic_name, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_company.phonetic_name, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.company, dstRecordHandle); + + companyHandle.Release(); + } + + // note + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.note, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.note, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_note._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle noteHandle(dstRecordHandle); + + contacts_record_get_str_p(srcRecordHandle, _contacts_note.note, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_note.note, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.note, dstRecordHandle); + + noteHandle.Release(); + } + + // number + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.number, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.number, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_number._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle numberHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_number.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_number.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_number.label, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_number.label, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_number.number, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_number.number, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.number, dstRecordHandle); + + numberHandle.Release(); + } + + // email + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.email, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.email, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_email._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle emailHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_email.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_email.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_email.label, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_email.label, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_email.email, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_email.email, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.email, dstRecordHandle); + + emailHandle.Release(); + + } + + // event + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.event, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.event, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_event._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle eventHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_event.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_event.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_event.label, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_event.label, pCharValue); + + contacts_record_get_int(srcRecordHandle, _contacts_event.date, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_event.date, intValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.event, dstRecordHandle); + + eventHandle.Release(); + } + + // im address + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.messenger, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.messenger, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_messenger._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle imAddressHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_messenger.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_messenger.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_messenger.label, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_messenger.label, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_messenger.im_id, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_messenger.im_id, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.messenger, dstRecordHandle); + + imAddressHandle.Release(); + } + + // address + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.address, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.address, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_address._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle addressHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_address.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_address.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.label, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.label, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.postbox, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.postbox, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.extended, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.extended, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.street, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.street, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.locality, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.locality, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.region, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.region, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.postal_code, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.postal_code, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_address.country, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_address.country, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.address, dstRecordHandle); + + addressHandle.Release(); + } + + // url + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.url, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.url, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_url._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle urlHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_url.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_url.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_url.label, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_url.label, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_url.url, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_url.url, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.url, dstRecordHandle); + + urlHandle.Release(); + } + + // nickname + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.nickname, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.nickname, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_nickname._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle nicknameHandle(dstRecordHandle); + + contacts_record_get_str_p(srcRecordHandle, _contacts_nickname.name, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_nickname.name, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.nickname, dstRecordHandle); + + nicknameHandle.Release(); + } + + // relationship + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.relationship, &count); + for (i = 0; i < count; i++) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.relationship, i, &srcRecordHandle); + + ret = contacts_record_create(_contacts_relationship._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle relationshipHandle(dstRecordHandle); + + contacts_record_get_str_p(srcRecordHandle, _contacts_relationship.name, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_relationship.name, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_my_profile.relationship, dstRecordHandle); + + relationshipHandle.Release(); + } + + // image + contacts_record_get_child_record_count(srcHandle, _contacts_my_profile.image, &count); + + int recordId = 0; + contacts_record_get_int(srcHandle, _contacts_my_profile.id, &recordId); + + if (count > 0 && recordId == 0) + { + contacts_record_get_child_record_at_p(srcHandle, _contacts_my_profile.image, 0, &srcRecordHandle); + + ret = contacts_record_create(_contacts_image._uri, &dstRecordHandle); + SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); + + __ContactsRecordHandle imageHandle(dstRecordHandle); + + contacts_record_get_int(srcRecordHandle, _contacts_image.type, &intValue); + contacts_record_set_int(dstRecordHandle, _contacts_image.type, intValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_image.label, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_image.label, pCharValue); + + contacts_record_get_str_p(srcRecordHandle, _contacts_image.path, &pCharValue); + contacts_record_set_str(dstRecordHandle, _contacts_image.path, pCharValue); + + contacts_record_add_child_record(dstHandle, _contacts_contact.image, dstRecordHandle); + + imageHandle.Release(); + } + + return E_SUCCESS; +} + void _AddressbookImpl::OnContactChanged(void) { - if (__pIAddressbookEventListener == null && __pIRecordEventListener == null) + if (__pIRecordEventListener == null && __pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null) { return; } @@ -1338,6 +1832,10 @@ _AddressbookImpl::OnContactChanged(void) { __pIAddressbookEventListener->OnContactsChanged(*pChangedContactList); } + else if (__pIAddressbookChangeEventListener != null) + { + __pIAddressbookChangeEventListener->OnContactsChanged(*pChangedContactList); + } else { RecordEventType recordEventType = RECORD_ADDED; @@ -1403,7 +1901,7 @@ _AddressbookImpl::OnContactChanged(void) void _AddressbookImpl::OnCategoryChanged(void) { - if (__pIAddressbookEventListener == null && __pIRecordEventListener == null) + if (__pIRecordEventListener == null && __pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null) { return; } @@ -1417,6 +1915,10 @@ _AddressbookImpl::OnCategoryChanged(void) { __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList); } + else if (__pIAddressbookChangeEventListener != null) + { + __pIAddressbookChangeEventListener->OnCategoriesChanged(*pChangedCategoryList); + } else { RecordEventType recordEventType = RECORD_ADDED; diff --git a/src/FScl_AddressbookManagerImpl.cpp b/src/FScl_AddressbookManagerImpl.cpp index c9d935e..de2b5f1 100644 --- a/src/FScl_AddressbookManagerImpl.cpp +++ b/src/FScl_AddressbookManagerImpl.cpp @@ -31,6 +31,7 @@ #include <FIoFile.h> #include <FSclAddressbook.h> #include <FSclAddressbookManager.h> +#include <FSclIAddressbookChangeEventListener.h> #include <FSclContact.h> #include <FSclCategory.h> #include <FSclUserProfile.h> @@ -73,6 +74,7 @@ namespace Tizen { namespace Social _AddressbookManagerImpl::_AddressbookManagerImpl(void) : __pIAddressbookEventListener(null) + , __pIAddressbookChangeEventListener(null) , __dbVersionForContact(0) , __dbVersionForGroup(0) , __dbVersionForRelation(0) @@ -82,7 +84,7 @@ _AddressbookManagerImpl::_AddressbookManagerImpl(void) _AddressbookManagerImpl::~_AddressbookManagerImpl(void) { - if (__pIAddressbookEventListener != null) + if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null) { _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); if (pContactDbMonitor != null) @@ -102,7 +104,7 @@ _AddressbookManagerImpl::Construct(void) } result -_AddressbookManagerImpl::SetEventListener(const IAddressbookEventListener* pListener) +_AddressbookManagerImpl::SetEventListener(IAddressbookEventListener* pListener) { SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -110,15 +112,53 @@ _AddressbookManagerImpl::SetEventListener(const IAddressbookEventListener* pList if (pListener != null) { - if (__pIAddressbookEventListener == null) + if (__pIAddressbookEventListener == null && __pIAddressbookChangeEventListener == null) { - __dbVersionForContact = GetLatestVersion(); - SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); + SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + r = pContactDbMonitor->AddListener(*this); + SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); + } + + __dbVersionForContact = GetLatestVersion(); + SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __dbVersionForGroup = __dbVersionForContact; + __dbVersionForRelation = __dbVersionForContact; + + __pIAddressbookChangeEventListener = null; + __pIAddressbookEventListener = pListener; + } + else + { + if (__pIAddressbookEventListener != null || __pIAddressbookChangeEventListener != null) + { + + _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); + SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + pContactDbMonitor->RemoveListener(*this); + } + + __pIAddressbookEventListener = null; + __pIAddressbookChangeEventListener = null; + } - __dbVersionForGroup = __dbVersionForContact; - __dbVersionForRelation = __dbVersionForContact; + return E_SUCCESS; +} +result +_AddressbookManagerImpl::SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener) +{ + SysTryReturn(NID_SCL, _ContactDbConnector::EnsureDbConnection() == E_SUCCESS, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + result r = E_SUCCESS; + + if (pListener != null) + { + if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null) + { _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); SysTryReturn(NID_SCL, pContactDbMonitor != null, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); @@ -126,11 +166,18 @@ _AddressbookManagerImpl::SetEventListener(const IAddressbookEventListener* pList SysTryReturn(NID_SCL, !IsFailed(r), r, r, "[%s] Propagating.", GetErrorMessage(r)); } - __pIAddressbookEventListener = const_cast<IAddressbookEventListener*>(pListener); + __dbVersionForContact = GetLatestVersion(); + SysTryReturn(NID_SCL, __dbVersionForContact != -1, GetLastResult(), GetLastResult(), "[%s] Propagating.", GetErrorMessage(GetLastResult())); + + __dbVersionForGroup = __dbVersionForContact; + __dbVersionForRelation = __dbVersionForContact; + + __pIAddressbookEventListener = null; + __pIAddressbookChangeEventListener = pListener; } else { - if (__pIAddressbookEventListener != null) + if (__pIAddressbookChangeEventListener != null || __pIAddressbookEventListener != null) { _ContactDbMonitor* pContactDbMonitor = _ContactDbMonitor::GetInstance(); @@ -139,6 +186,7 @@ _AddressbookManagerImpl::SetEventListener(const IAddressbookEventListener* pList pContactDbMonitor->RemoveListener(*this); } + __pIAddressbookChangeEventListener = null; __pIAddressbookEventListener = null; } @@ -1010,7 +1058,7 @@ _AddressbookManagerImpl::GetChangedRelationsAfterN(int version, int& latestVersi void _AddressbookManagerImpl::OnContactChanged(void) { - if (__pIAddressbookEventListener == null) + if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null) { return; } @@ -1020,7 +1068,11 @@ _AddressbookManagerImpl::OnContactChanged(void) if (pChangedContactList->GetCount() > 0) { - if (__pIAddressbookEventListener != null) + if (__pIAddressbookChangeEventListener != null) + { + __pIAddressbookChangeEventListener->OnContactsChanged(*pChangedContactList); + } + else { __pIAddressbookEventListener->OnContactsChanged(*pChangedContactList); } @@ -1033,7 +1085,7 @@ _AddressbookManagerImpl::OnContactChanged(void) void _AddressbookManagerImpl::OnCategoryChanged(void) { - if (__pIAddressbookEventListener == null) + if (__pIAddressbookChangeEventListener == null && __pIAddressbookEventListener == null) { return; } @@ -1043,7 +1095,11 @@ _AddressbookManagerImpl::OnCategoryChanged(void) if (pChangedCategoryList->GetCount() > 0) { - if (__pIAddressbookEventListener != null) + if (__pIAddressbookChangeEventListener != null) + { + __pIAddressbookChangeEventListener->OnCategoriesChanged(*pChangedCategoryList); + } + else { __pIAddressbookEventListener->OnCategoriesChanged(*pChangedCategoryList); } diff --git a/src/FScl_CalEventImpl.cpp b/src/FScl_CalEventImpl.cpp index e2c6c73..47a9284 100644 --- a/src/FScl_CalEventImpl.cpp +++ b/src/FScl_CalEventImpl.cpp @@ -80,28 +80,11 @@ static const int _RECURRENCE_BY_DAY_SECOND_INDEX = 1; static const int _MAX_WEEK_OF_RECURRENCE_BY_DAY = 5; static const int _RECURRENCE_NUMBER_OF_WEEK_DAY = 7; -static const wchar_t _CALENDARBOOK_UTC_SUFFIX = L'Z'; -static const wchar_t _CALENDARBOOK_TIME_PREFIX = L'T'; -static const wchar_t* _CALENDARBOOK_UTC_TZID = L"TZID="; -static const wchar_t _CALENDARBOOK_DATE_TIME_DELIMITER = L':'; -static const int _CALENDARBOOK_TZID_INDEX = 5; -static const int _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH = 16; // ex :20120629T193000Z -static const int _CALENDARBOOK_DATE_VALUE_STRING_LENGTH = 8; // ex :20120629 -static const int _CALENDARBOOK_TIME_VALUE_STRING_LENGTH = 6; // ex :193000 -static const int _CALENDARBOOK_DATE_YEAR_STRING_LENGTH = 4; -static const int _CALENDARBOOK_DATE_MONTH_STRING_LENGTH = 2; -static const int _CALENDARBOOK_DATE_DAY_STRING_LENGTH = 2; -static const int _CALENDARBOOK_TIME_HOUR_STRING_LENGTH = 2; -static const int _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH = 2; -static const int _CALENDARBOOK_TIME_SECOND_STRING_LENGTH = 2; - static const double _MIN_LATITUDE = -90.0; static const double _MAX_LATITUDE = 90.0; static const double _MIN_LONGITUDE = -180.0; static const double _MAX_LONGITUDE = 180.0; -static const wchar_t* _CALENDARBOOK_ZERO_STRING = L"0"; - _CalEventImpl::_CalEventImpl(void) : __originalEventId(INVALID_RECORD_ID) , __isInstance(false) @@ -1652,6 +1635,17 @@ _CalEventImpl::GetCalendarId(void) const return srcCalendarbookId; } +RecordId +_CalEventImpl::GetBaseEventId(void) const +{ + int errorCode = CALENDAR_ERROR_NONE; + int srcBaseEventId = INVALID_RECORD_ID; + + errorCode = calendar_record_get_int(__eventRecord.GetHandle(), _calendar_event.original_event_id, &srcBaseEventId); + + return srcBaseEventId; +} + void _CalEventImpl::SetOriginalCalEventId(RecordId originalEventId) { @@ -2143,7 +2137,7 @@ _CalEventImpl::ConvertRRuleExDateStringToRecurrence(const String& exdate, Recurr r = strTok.GetNextToken(token); SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_OUT_OF_MEMORY, "Memory allocation failed."); - r = ConvertRRuleDateTimeStringToDateTime(token, tmpDateTime, tmpTimeZone, isDate); + r = _CalendarbookUtil::ConvertRRuleDateTimeStringToDateTime(token, tmpDateTime, tmpTimeZone, isDate); SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. exdate = %S", exdate.GetPointer()); if (!isDate && tmpTimeZone != utcTimeZone) @@ -2158,174 +2152,6 @@ _CalEventImpl::ConvertRRuleExDateStringToRecurrence(const String& exdate, Recurr return E_SUCCESS; } -result -_CalEventImpl::ConvertRRuleDateTimeStringToDateTime(const String& dateTimeString, DateTime& dateTime, TimeZone& timeZone, bool& isDate) const -{ - result r = E_SUCCESS; - String dateValue; - String timeValue; - - // Split the dateTimeString into date value, time value and time zone - if (dateTimeString.GetLength() == _CALENDARBOOK_DATE_VALUE_STRING_LENGTH) - { - dateValue = dateTimeString; - isDate = true; - } - else if (dateTimeString.GetLength() == _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH) - { - int timeValueIndex = 0; - int suffixIndex = 0; - r = dateTimeString.LastIndexOf(_CALENDARBOOK_TIME_PREFIX, _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1, timeValueIndex); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no T prefix - SysTryReturnResult(NID_SCL, timeValueIndex == _CALENDARBOOK_DATE_VALUE_STRING_LENGTH - , E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of T is wrong - - r = dateTimeString.LastIndexOf(_CALENDARBOOK_UTC_SUFFIX, _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1, suffixIndex); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no Z suffix - SysTryReturnResult(NID_SCL, suffixIndex == _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1 - , E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of Z is wrong - - r = dateTimeString.SubString(0, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue); - r = dateTimeString.SubString(_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1 - , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue); - isDate = false; - } - else if (dateTimeString.GetLength() > _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH) // including timezone ID - { - String timeZoneId; - int dateValueIndex = 0; - - r = dateTimeString.LastIndexOf(_CALENDARBOOK_UTC_TZID, dateTimeString.GetLength() - 1, dateValueIndex); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no TZID - SysTryReturnResult(NID_SCL, dateValueIndex == 0, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of TZID is wrong - - r = dateTimeString.LastIndexOf(_CALENDARBOOK_DATE_TIME_DELIMITER, dateTimeString.GetLength() - 1, dateValueIndex); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no TZID - - r = dateTimeString.SubString(_CALENDARBOOK_TZID_INDEX, dateValueIndex - _CALENDARBOOK_TZID_INDEX, timeZoneId); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - - dateValueIndex += 1; - - r = dateTimeString.SubString(dateValueIndex, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue); - r = dateTimeString.SubString(dateValueIndex +_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1 - , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue); - - r = TimeZone::GetTimeZone(timeZoneId, timeZone); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // not supported timezone ID - isDate = false; - } - else - { - SysLogException(NID_SCL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. date time string = %S", dateTimeString.GetPointer()); - return E_INVALID_ARG; - } - - int tmpIndex = 0; - String tmpString; - int yearValue = 0; - int monthValue = 0; - int dayValue = 0; - int hourValue = 0; - int minuteValue = 0; - int secondValue = 0; - - // Parse date value - r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_YEAR_STRING_LENGTH, tmpString); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - r = Integer::Parse(tmpString, yearValue); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - tmpIndex += _CALENDARBOOK_DATE_YEAR_STRING_LENGTH; - - r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_MONTH_STRING_LENGTH, tmpString); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - r = Integer::Parse(tmpString, monthValue); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - tmpIndex += _CALENDARBOOK_DATE_MONTH_STRING_LENGTH; - - r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_DAY_STRING_LENGTH, tmpString); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - r = Integer::Parse(tmpString, dayValue); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - tmpIndex += _CALENDARBOOK_DATE_DAY_STRING_LENGTH; - - if (!isDate) - { - // Parse time value - tmpIndex = 0; - r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_HOUR_STRING_LENGTH, tmpString); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - r = Integer::Parse(tmpString, hourValue); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - tmpIndex += _CALENDARBOOK_TIME_HOUR_STRING_LENGTH; - - r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH, tmpString); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - r = Integer::Parse(tmpString, minuteValue); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - tmpIndex += _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH; - - r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_SECOND_STRING_LENGTH, tmpString); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - r = Integer::Parse(tmpString, secondValue); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - tmpIndex += _CALENDARBOOK_TIME_SECOND_STRING_LENGTH; - } - - r = dateTime.SetValue(yearValue, monthValue, dayValue, hourValue, minuteValue, secondValue); - SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); - - return E_SUCCESS; -} - -String -_CalEventImpl::ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate) -{ - result r = E_SUCCESS; - String exdateString; - - r = exdateString.Append(dateTime.GetYear()); - - if (dateTime.GetMonth() < 10) - { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); - } - r = exdateString.Append(dateTime.GetMonth()); - - if (dateTime.GetDay() < 10) - { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); - } - r = exdateString.Append(dateTime.GetDay()); - - if (!isDate) - { - r = exdateString.Append(_CALENDARBOOK_TIME_PREFIX); - - if (dateTime.GetHour() < 10) - { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); - } - r = exdateString.Append(dateTime.GetHour()); - - if (dateTime.GetMinute() < 10) - { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); - } - r = exdateString.Append(dateTime.GetMinute()); - - if (dateTime.GetSecond() < 10) - { - r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); - } - r = exdateString.Append(dateTime.GetSecond()); - - r = exdateString.Append(_CALENDARBOOK_UTC_SUFFIX); - } - - return exdateString; -} - String _CalEventImpl::ConvertRecurrenceToRRuleExDateString(const Recurrence& recurrence, bool isDate) const { @@ -2346,7 +2172,7 @@ _CalEventImpl::ConvertRecurrenceToRRuleExDateString(const Recurrence& recurrence r = exdateString.Append(_RECURRENCE_DELIMITER); } - r = exdateString.Append(ConvertDateTimeToRRuleDateTimeString(*pDateTime, isDate)); + r = exdateString.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(*pDateTime, isDate)); isNotFirst = true; } diff --git a/src/FScl_CalendarbookImpl.cpp b/src/FScl_CalendarbookImpl.cpp index 301c9c0..b101452 100644 --- a/src/FScl_CalendarbookImpl.cpp +++ b/src/FScl_CalendarbookImpl.cpp @@ -75,7 +75,7 @@ static const int _NUMBER_OF_TODO_PRIORITY = 3; static const int _NUMBER_OF_EVENT_CATEGORY_MAP_PROJECTION = 2; static const int _INVALID_CALENDARBOOK_DB_ID = -1; // TODO : This value should be checked. -static const int _INVALID_EVENT_DB_ID = 0; +static const int _INVALID_EVENT_DB_ID = -1; class _CalendarList { @@ -485,12 +485,26 @@ _CalendarbookImpl::AddCalendar(Calendar& calendar, AccountId accountId) result _CalendarbookImpl::RemoveEvent(CalEvent& event) { - _RecordImpl* pRecordImpl = _RecordImpl::GetInstance(event); + int errorCode = CALENDAR_ERROR_NONE; + + SysTryReturnResult(NID_SCL, event.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG + , "Invalid argument is used. The specified eventId is INVALID_RECORD_ID."); + + calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle(); - result r = RemoveEvent(event.GetRecordId()); + int baseEventId = _INVALID_EVENT_DB_ID; + errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + SysTryReturnResult(NID_SCL, baseEventId == _INVALID_EVENT_DB_ID, E_INVALID_OPERATION + , "Invalid argument is used. The event has the base event id."); + + errorCode = calendar_db_delete_record(_calendar_event._uri, event.GetRecordId()); + SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_RECORD_NOT_FOUND, E_OBJ_NOT_FOUND, "The specified record is not found."); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); + + _RecordImpl* pRecordImpl = _RecordImpl::GetInstance(event); pRecordImpl->SetRecordId(INVALID_RECORD_ID); - return r; + return E_SUCCESS; } result @@ -500,7 +514,19 @@ _CalendarbookImpl::RemoveEvent(RecordId eventId) SysTryReturnResult(NID_SCL, eventId != INVALID_RECORD_ID, E_INVALID_ARG , "Invalid argument is used. The specified eventId is INVALID_RECORD_ID."); - SysTryReturnResult(NID_SCL, CheckEventExistance(eventId), E_OBJ_NOT_FOUND, "The specified record is not found."); + + calendar_record_h eventHandle = null; + + errorCode = calendar_db_get_record(_calendar_event._uri, eventId, &eventHandle); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The specified record is not found."); + + int baseEventId = _INVALID_EVENT_DB_ID; + errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + + calendar_record_destroy(eventHandle, true); + + SysTryReturnResult(NID_SCL, baseEventId == _INVALID_EVENT_DB_ID, E_INVALID_OPERATION + , "Invalid argument is used. The event of eventId has the base event id."); errorCode = calendar_db_delete_record(_calendar_event._uri, eventId); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); @@ -526,9 +552,9 @@ _CalendarbookImpl::RemoveTodo(RecordId todoId) SysTryReturnResult(NID_SCL, todoId != INVALID_RECORD_ID, E_INVALID_ARG , "Invalid argument is used. The specified todoId is INVALID_RECORD_ID."); - SysTryReturnResult(NID_SCL, CheckTodoExistance(todoId), E_OBJ_NOT_FOUND, "The specified record is not found."); errorCode = calendar_db_delete_record(_calendar_todo._uri, todoId); + SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_RECORD_NOT_FOUND, E_OBJ_NOT_FOUND, "The specified record is not found."); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); return E_SUCCESS; @@ -562,10 +588,16 @@ _CalendarbookImpl::UpdateEvent(const CalEvent& event) , "Invalid argument is used. The specified recordId is INVALID_RECORD_ID."); SysTryReturnResult(NID_SCL, !event.IsInstance(), E_INVALID_ARG , "Invalid argument is used. The event is not an entry type instance."); - SysTryReturnResult(NID_SCL, CheckEventExistance(event.GetRecordId()), E_OBJ_NOT_FOUND, "The specified record is not found."); calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle(); + int baseEventId = _INVALID_EVENT_DB_ID; + errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + SysTryReturnResult(NID_SCL, baseEventId == _INVALID_EVENT_DB_ID, E_INVALID_OPERATION + , "Invalid argument is used. The event has the base event id."); + + SysTryReturnResult(NID_SCL, CheckEventExistance(event.GetRecordId()), E_OBJ_NOT_FOUND, "The specified record is not found."); + errorCode = calendar_db_update_record(eventHandle); SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, E_SYSTEM, "A system error has been occurred."); SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The specified record is not found."); @@ -1259,6 +1291,19 @@ _CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance) SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The specified record is not found."); _CalendarRecord eventRecord(eventHandle); + int baseEventId = _INVALID_EVENT_DB_ID; + errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + + if (baseEventId != _INVALID_EVENT_DB_ID) + { + errorCode = calendar_db_delete_record(_calendar_event._uri, eventInstance.GetOriginalEventId()); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "[E_SYSTEM] A system error has been occurred."); + + errorCode = calendar_db_get_record(_calendar_event._uri, baseEventId, &eventHandle); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred."); + eventRecord.ResetHandle(eventHandle); + } + // Append exdate errorCode = calendar_record_get_str_p(eventHandle, _calendar_event.exdate, &pExdate); @@ -1269,7 +1314,7 @@ _CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance) r = exdate.Append(_RECURRENCE_DELIMITER); } - r = exdate.Append(_CalEventImpl::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent())); + r = exdate.Append(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent())); std::unique_ptr<char[]> pAppendedExdate(_StringConverter::CopyToCharArrayN(exdate)); SysTryReturnResult(NID_SCL, pAppendedExdate != null, E_OUT_OF_MEMORY, "Memory allocation failed."); @@ -1282,6 +1327,49 @@ _CalendarbookImpl::RemoveEventInstance(const CalEventInstance& eventInstance) return E_SUCCESS; } +result +_CalendarbookImpl::UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event) +{ + result r = E_SUCCESS; + int errorCode = CALENDAR_ERROR_NONE; + + SysTryReturnResult(NID_SCL, event.GetRecordId() != INVALID_RECORD_ID, E_INVALID_ARG + , "Invalid argument is used. The event's recordId is INVALID_RECORD_ID."); + SysTryReturnResult(NID_SCL, eventInstance.GetOriginalEventId() == event.GetRecordId(), E_INVALID_ARG + , "Invalid argument is used. The event's recordId is not equal to eventInstance's original event ID."); + SysTryReturnResult(NID_SCL, CheckEventExistance(event.GetRecordId()), E_OBJ_NOT_FOUND, "The specified event is not found."); + + calendar_record_h eventHandle = _CalEventImpl::GetInstance(event)->GetRecordHandle(); + + int baseEventId = _INVALID_EVENT_DB_ID; + errorCode = calendar_record_get_int(eventHandle, _calendar_event.original_event_id, &baseEventId); + + if (baseEventId == _INVALID_EVENT_DB_ID) + { + errorCode = calendar_record_set_int(eventHandle, _calendar_event.original_event_id, eventInstance.GetOriginalEventId()); + std::unique_ptr<char[]> pConvertedRecurrenceId(_StringConverter::CopyToCharArrayN(_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(eventInstance.GetStartTime(), eventInstance.IsAllDayEvent()))); + errorCode = calendar_record_set_str(eventHandle, _calendar_event.recurrence_id, pConvertedRecurrenceId.get()); + + int dbIndex = -1; + errorCode = calendar_db_insert_record(eventHandle, &dbIndex); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred."); + _RecordImpl::GetInstance(event)->SetRecordId(dbIndex); + + calendar_record_h tmpEventHandle = null; + errorCode = calendar_db_get_record(_calendar_event._uri, dbIndex, &tmpEventHandle); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_SYSTEM, "A system error has been occurred."); + _CalEventImpl::GetInstance(event)->SetRecordHandle(tmpEventHandle); + } + else + { + errorCode = calendar_db_update_record(eventHandle); + SysTryReturnResult(NID_SCL, errorCode != CALENDAR_ERROR_DB_FAILED, E_SYSTEM, "A system error has been occurred."); + SysTryReturnResult(NID_SCL, errorCode == CALENDAR_ERROR_NONE, E_OBJ_NOT_FOUND, "The base event of the event is not found."); + } + + return E_SUCCESS; +} + int _CalendarbookImpl::GetLatestVersion(void) const { diff --git a/src/FScl_CalendarbookUtil.cpp b/src/FScl_CalendarbookUtil.cpp index 69976f1..8f9d61a 100644 --- a/src/FScl_CalendarbookUtil.cpp +++ b/src/FScl_CalendarbookUtil.cpp @@ -55,6 +55,22 @@ static const wchar_t* _EVENT_CATEGORY_DELIMITER = L","; static const wchar_t* _EVENT_CATEGORY_APPOINTMENT_STRING = L"Appointment"; static const wchar_t* _EVENT_CATEGORY_ANNIVERSARY_STRING = L"Anniversary"; +static const wchar_t _CALENDARBOOK_UTC_SUFFIX = L'Z'; +static const wchar_t _CALENDARBOOK_TIME_PREFIX = L'T'; +static const wchar_t* _CALENDARBOOK_UTC_TZID = L"TZID="; +static const wchar_t _CALENDARBOOK_DATE_TIME_DELIMITER = L':'; +static const int _CALENDARBOOK_TZID_INDEX = 5; +static const int _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH = 16; // ex :20120629T193000Z +static const int _CALENDARBOOK_DATE_VALUE_STRING_LENGTH = 8; // ex :20120629 +static const int _CALENDARBOOK_TIME_VALUE_STRING_LENGTH = 6; // ex :193000 +static const int _CALENDARBOOK_DATE_YEAR_STRING_LENGTH = 4; +static const int _CALENDARBOOK_DATE_MONTH_STRING_LENGTH = 2; +static const int _CALENDARBOOK_DATE_DAY_STRING_LENGTH = 2; +static const int _CALENDARBOOK_TIME_HOUR_STRING_LENGTH = 2; +static const int _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH = 2; +static const int _CALENDARBOOK_TIME_SECOND_STRING_LENGTH = 2; +static const wchar_t* _CALENDARBOOK_ZERO_STRING = L"0"; + long long int _CalendarbookUtil::ConvertDateTimeToEpochTime(const DateTime& dateTime) { @@ -348,6 +364,174 @@ _CalendarbookUtil::ConvertDateToCalTime(const DateTime& dateTime, calendar_time_ convertedCalTime.time.date.mday = dateTime.GetDay(); } +result +_CalendarbookUtil::ConvertRRuleDateTimeStringToDateTime(const String& dateTimeString, DateTime& dateTime, Tizen::Locales::TimeZone& timeZone, bool& isDate) +{ + result r = E_SUCCESS; + String dateValue; + String timeValue; + + // Split the dateTimeString into date value, time value and time zone + if (dateTimeString.GetLength() == _CALENDARBOOK_DATE_VALUE_STRING_LENGTH) + { + dateValue = dateTimeString; + isDate = true; + } + else if (dateTimeString.GetLength() == _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH) + { + int timeValueIndex = 0; + int suffixIndex = 0; + r = dateTimeString.LastIndexOf(_CALENDARBOOK_TIME_PREFIX, _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1, timeValueIndex); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no T prefix + SysTryReturnResult(NID_SCL, timeValueIndex == _CALENDARBOOK_DATE_VALUE_STRING_LENGTH + , E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of T is wrong + + r = dateTimeString.LastIndexOf(_CALENDARBOOK_UTC_SUFFIX, _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1, suffixIndex); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no Z suffix + SysTryReturnResult(NID_SCL, suffixIndex == _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH - 1 + , E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of Z is wrong + + r = dateTimeString.SubString(0, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue); + r = dateTimeString.SubString(_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1 + , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue); + isDate = false; + } + else if (dateTimeString.GetLength() > _CALENDARBOOK_UTC_DATE_TIME_VALUE_STRING_LENGTH) // including timezone ID + { + String timeZoneId; + int dateValueIndex = 0; + + r = dateTimeString.LastIndexOf(_CALENDARBOOK_UTC_TZID, dateTimeString.GetLength() - 1, dateValueIndex); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no TZID + SysTryReturnResult(NID_SCL, dateValueIndex == 0, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); //The position of TZID is wrong + + r = dateTimeString.LastIndexOf(_CALENDARBOOK_DATE_TIME_DELIMITER, dateTimeString.GetLength() - 1, dateValueIndex); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // There is no TZID + + r = dateTimeString.SubString(_CALENDARBOOK_TZID_INDEX, dateValueIndex - _CALENDARBOOK_TZID_INDEX, timeZoneId); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + + dateValueIndex += 1; + + r = dateTimeString.SubString(dateValueIndex, _CALENDARBOOK_DATE_VALUE_STRING_LENGTH, dateValue); + r = dateTimeString.SubString(dateValueIndex +_CALENDARBOOK_DATE_VALUE_STRING_LENGTH + 1 + , _CALENDARBOOK_TIME_VALUE_STRING_LENGTH, timeValue); + + r = Tizen::Locales::TimeZone::GetTimeZone(timeZoneId, timeZone); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); // not supported timezone ID + isDate = false; + } + else + { + SysLogException(NID_SCL, E_INVALID_ARG, "[E_INVALID_ARG] Invalid argument is used. date time string = %S", dateTimeString.GetPointer()); + return E_INVALID_ARG; + } + + int tmpIndex = 0; + String tmpString; + int yearValue = 0; + int monthValue = 0; + int dayValue = 0; + int hourValue = 0; + int minuteValue = 0; + int secondValue = 0; + + // Parse date value + r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_YEAR_STRING_LENGTH, tmpString); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + r = Integer::Parse(tmpString, yearValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + tmpIndex += _CALENDARBOOK_DATE_YEAR_STRING_LENGTH; + + r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_MONTH_STRING_LENGTH, tmpString); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + r = Integer::Parse(tmpString, monthValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + tmpIndex += _CALENDARBOOK_DATE_MONTH_STRING_LENGTH; + + r = dateValue.SubString(tmpIndex, _CALENDARBOOK_DATE_DAY_STRING_LENGTH, tmpString); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + r = Integer::Parse(tmpString, dayValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + tmpIndex += _CALENDARBOOK_DATE_DAY_STRING_LENGTH; + + if (!isDate) + { + // Parse time value + tmpIndex = 0; + r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_HOUR_STRING_LENGTH, tmpString); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + r = Integer::Parse(tmpString, hourValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + tmpIndex += _CALENDARBOOK_TIME_HOUR_STRING_LENGTH; + + r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH, tmpString); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + r = Integer::Parse(tmpString, minuteValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + tmpIndex += _CALENDARBOOK_TIME_MINUTE_STRING_LENGTH; + + r = timeValue.SubString(tmpIndex, _CALENDARBOOK_TIME_SECOND_STRING_LENGTH, tmpString); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + r = Integer::Parse(tmpString, secondValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + tmpIndex += _CALENDARBOOK_TIME_SECOND_STRING_LENGTH; + } + + r = dateTime.SetValue(yearValue, monthValue, dayValue, hourValue, minuteValue, secondValue); + SysTryReturnResult(NID_SCL, r == E_SUCCESS, E_INVALID_ARG, "Invalid argument is passed. date time string = %S", dateTimeString.GetPointer()); + + return E_SUCCESS; +} + +String +_CalendarbookUtil::ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate) +{ + result r = E_SUCCESS; + String exdateString; + + r = exdateString.Append(dateTime.GetYear()); + + if (dateTime.GetMonth() < 10) + { + r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + } + r = exdateString.Append(dateTime.GetMonth()); + + if (dateTime.GetDay() < 10) + { + r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + } + r = exdateString.Append(dateTime.GetDay()); + + if (!isDate) + { + r = exdateString.Append(_CALENDARBOOK_TIME_PREFIX); + + if (dateTime.GetHour() < 10) + { + r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + } + r = exdateString.Append(dateTime.GetHour()); + + if (dateTime.GetMinute() < 10) + { + r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + } + r = exdateString.Append(dateTime.GetMinute()); + + if (dateTime.GetSecond() < 10) + { + r = exdateString.Append(_CALENDARBOOK_ZERO_STRING); + } + r = exdateString.Append(dateTime.GetSecond()); + + r = exdateString.Append(_CALENDARBOOK_UTC_SUFFIX); + } + + return exdateString; +} + calendar_event_status_e _CalendarbookUtil::ConvertEventStatusToCSEventStatus(int status) { diff --git a/src/FScl_CalendarbookUtil.h b/src/FScl_CalendarbookUtil.h index f8386e0..4919edf 100644 --- a/src/FScl_CalendarbookUtil.h +++ b/src/FScl_CalendarbookUtil.h @@ -116,6 +116,9 @@ public: static void ConvertDateTimeToCalTime(const Tizen::Base::DateTime& dateTime, calendar_time_s& convertedCalTime); static void ConvertDateToCalTime(const Tizen::Base::DateTime& dateTime, calendar_time_s& convertedCalTime); + static Tizen::Base::String ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate); + static result ConvertRRuleDateTimeStringToDateTime(const Tizen::Base::String& dateTimeString, Tizen::Base::DateTime& dateTime, Tizen::Locales::TimeZone& timeZone, bool& isDate); + static calendar_event_status_e ConvertEventStatusToCSEventStatus(int status); static calendar_event_busy_status_e ConvertBusyStatusToCSEventBusyStatus(int busyStatus); static calendar_event_priority_e ConvertEventPriorityToCSEventPriority(int priority); diff --git a/src/FScl_ContactDbConnector.cpp b/src/FScl_ContactDbConnector.cpp index 7c67c44..e5978a9 100644 --- a/src/FScl_ContactDbConnector.cpp +++ b/src/FScl_ContactDbConnector.cpp @@ -66,10 +66,9 @@ _ContactDbConnector::Connect(void) int ret = contacts_connect_with_flags(CONTACTS_CONNECT_FLAG_RETRY); System::SystemTime::GetTicks(endTicks); - SysLog(NID_SCL, "Elapsed time for connecting to the contact service : %lld, result: %d", endTicks - startTicks, ret); SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_OUT_OF_MEMORY, E_OUT_OF_MEMORY, E_OUT_OF_MEMORY, "[%s] Memory allocation failed.", GetErrorMessage(E_OUT_OF_MEMORY)); - SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_IPC_NOT_AVALIABLE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Contact server is not available", GetErrorMessage(E_SYSTEM)); + SysTryReturn(NID_SCL, ret != CONTACTS_ERROR_IPC_NOT_AVALIABLE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred. Contact server is not available. Elapsed time : %lld", GetErrorMessage(E_SYSTEM), endTicks - startTicks); SysTryReturn(NID_SCL, ret == CONTACTS_ERROR_NONE, E_SYSTEM, E_SYSTEM, "[%s] A system error has been occurred.", GetErrorMessage(E_SYSTEM)); pthread_setspecific(tlsKey, this); diff --git a/src/FScl_ContactEventImpl.cpp b/src/FScl_ContactEventImpl.cpp index 7951584..047b025 100644 --- a/src/FScl_ContactEventImpl.cpp +++ b/src/FScl_ContactEventImpl.cpp @@ -31,6 +31,7 @@ namespace Tizen { namespace Social { _ContactEventImpl::_ContactEventImpl(void) +: __type(CONTACT_EVENT_TYPE_BIRTHDAY) { } diff --git a/src/FScl_OrganizationImpl.cpp b/src/FScl_OrganizationImpl.cpp index 49da551..d70b634 100644 --- a/src/FScl_OrganizationImpl.cpp +++ b/src/FScl_OrganizationImpl.cpp @@ -33,8 +33,10 @@ namespace Tizen { namespace Social { _OrganizationImpl::_OrganizationImpl(void) - :__isLogoPathChanged(false) +: __type(ORGANIZATION_TYPE_WORK) +, __isLogoPathChanged(false) { + } _OrganizationImpl::_OrganizationImpl(const _OrganizationImpl& rhs) diff --git a/src/FScl_RelationshipImpl.cpp b/src/FScl_RelationshipImpl.cpp index d10d32f..c83a38d 100644 --- a/src/FScl_RelationshipImpl.cpp +++ b/src/FScl_RelationshipImpl.cpp @@ -31,6 +31,7 @@ namespace Tizen { namespace Social { _RelationshipImpl::_RelationshipImpl(void) +: __type(CONTACT_RELATIONSHIP_TYPE_ASSISTANT) { } diff --git a/src/inc/FScl_AddressbookImpl.h b/src/inc/FScl_AddressbookImpl.h index 99cf174..c9ca361 100644 --- a/src/inc/FScl_AddressbookImpl.h +++ b/src/inc/FScl_AddressbookImpl.h @@ -46,6 +46,7 @@ class Category; class UserProfile; class IRecordEventListener; class IAddressbookEventListener; +class IAddressbookChangeEventListener; /** * @class _AddressbookImpl @@ -79,6 +80,8 @@ public: result SetAddressbookEventListener(IAddressbookEventListener* pListener); + result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener); + void SetId(AddressbookId addressbookId); void SetAccountId(AccountId accountId); @@ -143,6 +146,10 @@ public: Tizen::Base::Collection::IList* GetChangedCategoriesAfterN(int version, int& latestVersion) const; + Tizen::Base::Collection::IList* GetChangedContactInfoListN(int version, int& latestVersion) const; + + Tizen::Base::Collection::IList* GetChangedCategoryInfoListN(int version, int& latestVersion) const; + result AddContacts(const Tizen::Base::Collection::IList& contactList, Tizen::Base::Collection::IListT<RecordId>* pContactIdList); result UpdateContacts(const Tizen::Base::Collection::IList& contactList); @@ -155,6 +162,8 @@ public: bool IsUserProfileChangedAfter(int version) const; + result CopyMyProfileContents(contacts_record_h srcHandle, contacts_record_h dstHandle); + virtual void OnContactChanged(void); virtual void OnCategoryChanged(void); @@ -187,6 +196,7 @@ private: private: IRecordEventListener* __pIRecordEventListener; IAddressbookEventListener* __pIAddressbookEventListener; + IAddressbookChangeEventListener* __pIAddressbookChangeEventListener; int __dbVersionForContact; int __dbVersionForGroup; int __dbVersionForRelation; diff --git a/src/inc/FScl_AddressbookManagerImpl.h b/src/inc/FScl_AddressbookManagerImpl.h index 4533858..9c9eadd 100644 --- a/src/inc/FScl_AddressbookManagerImpl.h +++ b/src/inc/FScl_AddressbookManagerImpl.h @@ -48,6 +48,7 @@ class Contact; class Category; class IRecordEventListener; class IAddressbookEventListener; +class IAddressbookChangeEventListener; /** * @class _AddressbookManagerImpl @@ -76,7 +77,9 @@ public: result Construct(void); - result SetEventListener(const IAddressbookEventListener* pListener); + result SetEventListener(IAddressbookEventListener* pListener); + + result SetAddressbookChangeEventListener(IAddressbookChangeEventListener* pListener); Addressbook* CreateAddressbookN(AccountId accountId, const Tizen::Base::String& name); @@ -220,6 +223,7 @@ private: private: IAddressbookEventListener* __pIAddressbookEventListener; + IAddressbookChangeEventListener* __pIAddressbookChangeEventListener; int __dbVersionForContact; int __dbVersionForGroup; int __dbVersionForRelation; diff --git a/src/inc/FScl_CalEventImpl.h b/src/inc/FScl_CalEventImpl.h index a6b2e55..6dd5458 100644 --- a/src/inc/FScl_CalEventImpl.h +++ b/src/inc/FScl_CalEventImpl.h @@ -528,6 +528,8 @@ public: */ RecordId GetCalendarId(void) const; + RecordId GetBaseEventId(void) const; + /** * Sets the original event ID * @@ -570,8 +572,6 @@ public: */ _CalEventImpl& operator =(const _CalEventImpl& rhs); - static Tizen::Base::String ConvertDateTimeToRRuleDateTimeString(const Tizen::Base::DateTime& dateTime, bool isDate); - private: result SetStartAndEndTimeCommon(const Tizen::Base::DateTime& start, const Tizen::Base::DateTime& end); result ConvertRecurrenceToEventHandle(const Recurrence& recurrence, calendar_record_h eventHandle) const; @@ -581,7 +581,6 @@ private: result ConvertRRuleByDayStringToDayOfWeekAndWeekOfMonth(const Tizen::Base::String& byDay, int& weekOfMonth, int& dayOfWeek) const; result ConvertRRuleExDateStringToRecurrence(const Tizen::Base::String& exdate, Recurrence& recurrence) const; result ConvertDayOfWeekToRRuleByDayString(int dayOfWeek, int weekOfMonth, Tizen::Base::String& byDayString) const; - result ConvertRRuleDateTimeStringToDateTime(const Tizen::Base::String& dateTimeString, Tizen::Base::DateTime& dateTime, Tizen::Locales::TimeZone& timeZone, bool& isDate) const; Tizen::Base::String ConvertRecurrenceToRRuleExDateString(const Recurrence& recurrence, bool isDate) const; int GetAttendeeIndex(const char* pAttendeeEmail); diff --git a/src/inc/FScl_CalendarbookImpl.h b/src/inc/FScl_CalendarbookImpl.h index 4a0418b..b6701ed 100644 --- a/src/inc/FScl_CalendarbookImpl.h +++ b/src/inc/FScl_CalendarbookImpl.h @@ -623,6 +623,8 @@ public: */ result RemoveEventInstance(const CalEventInstance& eventInstance); + result UpdateEventInstance(const CalEventInstance& eventInstance, CalEvent& event); + /** * Gets the latest version of calendarbook storage. * |