Try
{
if (events->getEvents()->empty()) {
- ThrowMsg(NullPointerException, "event vector parameter is empty");
+ ThrowMsg(NullPointerException, "Items array is empty.");
+ }
+
+ int returnValue = calendar_svc_begin_trans();
+ if(CAL_SUCCESS!=returnValue) {
+ ThrowMsg(PlatformException, "Begin transaction failed with error code: "<<returnValue);
+ } else {
+ LogInfo("Begin transaction succeeded.");
}
- // Save the vector of events iteratively
bool failedAdding = false;
for(unsigned int i=0; i<events->getEvents()->size(); i++)
{
- if (events->checkCancelled()) {
- events->setCancelAllowed(true);
- events->setResult(true);
- return;
- }
-
if (events->getEvents()->at(i)->getIdIsSet()) {
- LogWarning("adding event that is already added: index " << i);
+ LogWarning("Item has index: " << i << ". Resetting it.");
events->getEvents()->at(i)->resetId();
}
DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(events->getEvents()->at(i), getType()));
eventWrapper->convertAbstractEventToPlatformEvent();
Try {
- // Set the account and calendar id before saving the item.
eventWrapper->setCalendarId(getId());
eventWrapper->setCalendarAccountId(getAccountId());
eventWrapper->saveEvent();
LogWarning("Exception: "<<_rethrown_exception.GetMessage());
failedAdding = true;
}
- //getAddEmitter()->emit(eventPtr);
}
if( false==failedAdding ) {
events->setResult(true);
+
+ returnValue = calendar_svc_end_trans(true);
+ LogInfo("End transaction return value with true flag: "<<returnValue);
} else {
events->setResult(false);
+
+ returnValue = calendar_svc_end_trans(false);
+ LogInfo("End transaction return value with false flag: "<<returnValue);
}
}
Catch (Exception)
events->setResult(false);
events->setExceptionCode(ExceptionCodes::UnknownException);
}
- events->setCancelAllowed(false);
}
void Calendar::OnRequestReceived(const IEventUpdateEventPtr &event)
}
int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
- std::time_t detachedStartTime = calendar_svc_struct_get_time(platformEvent,
- CAL_VALUE_GMT_START_DATE_TIME,
- CAL_TZ_FLAG_GMT);
- std::time_t detachedEndTime = calendar_svc_struct_get_time(platformEvent,
- CAL_VALUE_GMT_END_DATE_TIME,
- CAL_TZ_FLAG_GMT);
+ long long int detachedStartTime = calendar_svc_struct_get_lli(platformEvent, CALS_VALUE_LLI_DTSTART_UTIME);
+ long long int detachedEndTime = calendar_svc_struct_get_lli(platformEvent, CALS_VALUE_LLI_DTEND_UTIME);
DPL::ScopedPtr<EventWrapper> eventWrapperChild(new EventWrapper(event->getEvent(), getType()));
eventWrapperChild->convertAbstractEventToPlatformEvent();
parentId)) {
ThrowMsg(PlatformException, "Can't set parent Id.");
}
- if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_GMT_START_DATE_TIME,
- CAL_TZ_FLAG_GMT,
+ if (CAL_SUCCESS != calendar_svc_struct_set_lli(eventWrapperChild->getPlatformEvent(),
+ CALS_VALUE_LLI_DTSTART_UTIME,
detachedStartTime)) {
ThrowMsg(PlatformException, "Can't set start time.");
}
- if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_GMT_END_DATE_TIME,
- CAL_TZ_FLAG_GMT,
+ if (CAL_SUCCESS != calendar_svc_struct_set_lli(eventWrapperChild->getPlatformEvent(),
+ CALS_VALUE_LLI_DTEND_UTIME,
detachedEndTime)) {
ThrowMsg(PlatformException, "Can't set end time.");
}
if (CAL_SUCCESS != calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_INT_REPEAT_TERM,
+ CALS_VALUE_INT_RRULE_FREQ,
CAL_REPEAT_NONE)) {
ThrowMsg(PlatformException, "Can't set repeat term.");
}
CAL_VALUE_INT_ORIGINAL_EVENT_ID, event->getEvent()->getId()) ) {
ThrowMsg(PlatformException, "cannot save exception event");
}
- // Use "CAL_VALUE_GMT_COMPLETED_DATE_TIME" as the recurrence id saving point.
- if ( CAL_SUCCESS!=calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT, event->getEvent()->getRecurrenceId()) ) {
+ // Use "CAL_VALUE_LLI_COMPLETED_TIME" as the recurrence id saving point.
+ if ( CAL_SUCCESS!=calendar_svc_struct_set_lli(eventWrapperChild->getPlatformEvent(),
+ CAL_VALUE_LLI_COMPLETED_TIME, event->getEvent()->getRecurrenceId()) ) {
ThrowMsg(PlatformException, "cannot save recurrence id");
} else {
LogInfo("Saved the rid for the child: "<<event->getEvent()->getRecurrenceId());
}
if (CAL_SUCCESS!=calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_INT_REPEAT_TERM, CAL_REPEAT_NONE) ) {
+ CALS_VALUE_INT_RRULE_FREQ, CAL_REPEAT_NONE) ) {
ThrowMsg(PlatformException, "cannot save exception event");
}
int childId = calendar_svc_insert(eventWrapperChild->getPlatformEvent());
ThrowMsg(PlatformException, "cannot save exception event");
}
- GList* list = NULL;
- cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
- if (CAL_SUCCESS!=calendar_svc_value_set_time(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_GMT, event->getEvent()->getRecurrenceId()) ) {
- ThrowMsg(PlatformException, "cannot save the exception date");
- } else {
- LogInfo("Saved the exception date: "<<event->getEvent()->getRecurrenceId());
- }
- if (CAL_SUCCESS!=calendar_svc_value_set_int(value, CAL_VALUE_INT_EXCEPTION_DATE_ID, childId)) {
- ThrowMsg(PlatformException, "cannot save the exception parent event");
- } else {
- LogInfo("Saved the exception id: "<<childId);
- }
- eventWrapper->loadEvent(event->getEvent()->getId());
- calendar_svc_struct_get_list(eventWrapper->getPlatformEvent(), CAL_VALUE_LST_EXCEPTION_DATE, &list);
- list = g_list_append(list, value);
- if (CAL_SUCCESS!=calendar_svc_struct_store_list(eventWrapper->getPlatformEvent(), CAL_VALUE_LST_EXCEPTION_DATE, list)) {
- ThrowMsg(PlatformException, "cannot save the exception parent event");
+ int error = calendar_svc_event_delete_normal_instance(event->getEvent()->getId(), event->getEvent()->getRecurrenceId());
+ if(error!=CAL_SUCCESS) {
+ ThrowMsg(PlatformException, "Can't delete the instance. Error code " << error);
}
- calendar_svc_update(eventWrapper->getPlatformEvent());
event->getEvent()->setIsDetached(true);
}
Try
{
if (events->getEvents()->empty()) {
- ThrowMsg(NullPointerException, "Item vector is empty.");
+ ThrowMsg(NullPointerException, "Item array is empty.");
+ }
+
+ int returnValue = calendar_svc_begin_trans();
+ if(CAL_SUCCESS!=returnValue) {
+ ThrowMsg(PlatformException, "Begin transaction failed with error code: "<<returnValue);
+ } else {
+ LogInfo("Begin transaction succeeded.");
}
- // Update the vector of events iteratively
bool failedUpdating = false;
for(unsigned int i=0; i<events->getEvents()->size(); i++)
{
- if (events->checkCancelled()) {
- events->setCancelAllowed(true);
- events->setResult(true);
- return;
- }
-
CalendarEventPtr thisEvent = events->getEvents()->at(i);
if (!thisEvent->getIdIsSet()) {
ThrowMsg(InvalidArgumentException, "Item id is not set.");
}
int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
- std::time_t detachedStartTime = calendar_svc_struct_get_time(platformEvent,
- CAL_VALUE_GMT_START_DATE_TIME,
- CAL_TZ_FLAG_GMT);
- std::time_t detachedEndTime = calendar_svc_struct_get_time(platformEvent,
- CAL_VALUE_GMT_END_DATE_TIME,
- CAL_TZ_FLAG_GMT);
+ long long int detachedStartTime = calendar_svc_struct_get_lli(platformEvent,
+ CALS_VALUE_LLI_DTSTART_UTIME);
+ long long int detachedEndTime = calendar_svc_struct_get_lli(platformEvent,
+ CALS_VALUE_LLI_DTEND_UTIME);
DPL::ScopedPtr<EventWrapper> eventWrapperChild(new EventWrapper(thisEvent, getType()));
eventWrapperChild->convertAbstractEventToPlatformEvent();
detachedEventId)) {
ThrowMsg(PlatformException, "Can't set event Id.");
}
- if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_GMT_START_DATE_TIME,
- CAL_TZ_FLAG_GMT,
+ if (CAL_SUCCESS != calendar_svc_struct_set_lli(eventWrapperChild->getPlatformEvent(),
+ CALS_VALUE_LLI_DTSTART_UTIME,
detachedStartTime)) {
ThrowMsg(PlatformException, "Can't set start time.");
}
- if (CAL_SUCCESS != calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_GMT_END_DATE_TIME,
- CAL_TZ_FLAG_GMT,
+ if (CAL_SUCCESS != calendar_svc_struct_set_lli(eventWrapperChild->getPlatformEvent(),
+ CALS_VALUE_LLI_DTEND_UTIME,
detachedEndTime)) {
ThrowMsg(PlatformException, "Can't set end time.");
}
CAL_VALUE_INT_ORIGINAL_EVENT_ID, thisEvent->getId()) ) {
ThrowMsg(PlatformException, "cannot save parent id.");
}
- // Use "CAL_VALUE_GMT_COMPLETED_DATE_TIME" as the recurrence id saving point.
- if ( CAL_SUCCESS!=calendar_svc_struct_set_time(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT, thisEvent->getRecurrenceId()) ) {
+ // Use "CAL_VALUE_LLI_COMPLETED_TIME" as the recurrence id saving point.
+ if ( CAL_SUCCESS!=calendar_svc_struct_set_lli(eventWrapperChild->getPlatformEvent(),
+ CAL_VALUE_LLI_COMPLETED_TIME, thisEvent->getRecurrenceId()) ) {
ThrowMsg(PlatformException, "cannot save recurrence id.");
} else {
LogInfo("Saved the rid for the child: "<<thisEvent->getRecurrenceId());
}
if (CAL_SUCCESS!=calendar_svc_struct_set_int(eventWrapperChild->getPlatformEvent(),
- CAL_VALUE_INT_REPEAT_TERM, CAL_REPEAT_NONE) ) {
+ CALS_VALUE_INT_RRULE_FREQ, CAL_REPEAT_NONE) ) {
ThrowMsg(PlatformException, "cannot save repeat term.");
}
int childId = calendar_svc_insert(eventWrapperChild->getPlatformEvent());
ThrowMsg(PlatformException, "cannot save exception event");
}
- GList* list = NULL;
- cal_value *value = calendar_svc_value_new(CAL_VALUE_LST_EXCEPTION_DATE);
- if (CAL_SUCCESS!=calendar_svc_value_set_time(value, CAL_VALUE_GMT_EXCEPTION_DATE_TIME, CAL_TZ_FLAG_GMT, thisEvent->getRecurrenceId()) ) {
- ThrowMsg(PlatformException, "cannot save the exception parent event");
- } else {
- LogInfo("Saved the exception date: "<<thisEvent->getRecurrenceId());
+ int error = calendar_svc_event_delete_normal_instance(thisEvent->getId(), thisEvent->getRecurrenceId());
+ if(error!=CAL_SUCCESS) {
+ ThrowMsg(PlatformException, "Can't delete the instance. Error code " << error);
}
- if (CAL_SUCCESS!=calendar_svc_value_set_int(value, CAL_VALUE_INT_EXCEPTION_DATE_ID, childId)) {
- ThrowMsg(PlatformException, "cannot save the exception parent event");
- } else {
- LogInfo("Saved the exception id: "<<childId);
- }
- calendar_svc_struct_get_list(eventWrapper->getPlatformEvent(), CAL_VALUE_LST_EXCEPTION_DATE, &list);
- list = g_list_append(list, value);
- if (CAL_SUCCESS!=calendar_svc_struct_store_list(eventWrapper->getPlatformEvent(), CAL_VALUE_LST_EXCEPTION_DATE, list)) {
- ThrowMsg(PlatformException, "cannot save the exception parent event");
- }
- calendar_svc_update(eventWrapper->getPlatformEvent());
thisEvent->setIsDetached(true);
}
if( false==failedUpdating ) {
events->setResult(true);
+
+ returnValue = calendar_svc_end_trans(true);
+ LogInfo("End transaction return value with true flag: "<<returnValue);
} else {
events->setResult(false);
+
+ returnValue = calendar_svc_end_trans(false);
+ LogInfo("End transaction return value with false flag: "<<returnValue);
}
}
Catch (Exception)
if(iter) {
calendar_svc_iter_remove(&iter);
}
- events->setCancelAllowed(false);
}
void Calendar::OnRequestReceived(const IEventDeleteEventPtr &event)
eventWrapper->getAbstractEvent()->setId(id);
std::stringstream ss(event->getEventId()->getRecurrenceId());
- std::time_t rid;
+ long long int rid;
ss>>rid;
eventWrapper->getAbstractEvent()->setRecurrenceId(rid);
ss>>id;
eventWrapper->loadEvent(id);
- event->setItem(eventWrapper->convertPlatformEventToAbstractEvent());
+ event->setItem(eventWrapper->getAbstractEvent());
event->setResult(true);
}
Catch (NotFoundException)
Try
{
if (events->getEventIds()->empty()) {
- ThrowMsg(NullPointerException, "event vector parameter is empty");
+ ThrowMsg(NullPointerException, "Item id array is empty.");
+ }
+
+ int returnValue = calendar_svc_begin_trans();
+ if(CAL_SUCCESS!=returnValue) {
+ ThrowMsg(PlatformException, "Begin transaction failed with error code: "<<returnValue);
+ } else {
+ LogInfo("Begin transaction succeeded.");
}
- // Delete the vector of events iteratively considering the recurrenceId
bool failedDeleting = false;
for(unsigned int i=0; i<events->getEventIds()->size(); i++)
{
eventWrapper->getAbstractEvent()->setId(id);
std::stringstream ss(events->getEventIds()->at(i)->getRecurrenceId());
- std::time_t rid;
+ long long int rid;
ss>>rid;
eventWrapper->getAbstractEvent()->setRecurrenceId(rid);
eventWrapper->convertAbstractEventToPlatformEvent();
if( false==failedDeleting ) {
events->setResult(true);
- }
- else {
+ returnValue = calendar_svc_end_trans(true);
+ LogInfo("End transaction return value with true flag: "<<returnValue);
+ } else {
events->setResult(false);
+
+ returnValue = calendar_svc_end_trans(false);
+ LogInfo("End transaction return value with false flag: "<<returnValue);
}
}
Catch (NotFoundException)
query.append(std::string(" AND ") + CAL_VALUE_INT_ACCOUNT_ID + " = " + ssAccount.str());
if (getType()==CalendarEvent::TASK_TYPE) {
ssType<<CALS_CALENDAR_TYPE_TODO;
- query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
+ query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str());
} else {
ssType<<CALS_CALENDAR_TYPE_EVENT;
- query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
+ query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str());
}
} else {
query.append(std::string(" WHERE ") + CAL_VALUE_INT_ACCOUNT_ID + " = " + ssAccount.str());
if (getType()==CalendarEvent::TASK_TYPE) {
ssType<<CALS_CALENDAR_TYPE_TODO;
- query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
+ query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str());
} else {
ssType<<CALS_CALENDAR_TYPE_EVENT;
- query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str() + " AND " + "is_deleted = 0");
+ query.append(std::string(" AND ") + CAL_VALUE_INT_TYPE + " = " + ssType.str());
}
}
// Now load the full calendar item using the retrieved id.
for( unsigned int i=0; i<event->getEvents()->size(); i++) {
- // platformEvent is freed when the wrapper destructor is called.
DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(event->getEvents()->at(i), getType()));
eventWrapper->loadEvent(event->getEvents()->at(i)->getId());
// If it's a detached event, set the saved rid.
if (eventWrapper->getAbstractEvent()->getParentId()>0) {
- LogInfo("Set the saved rid: "<<calendar_svc_struct_get_time(eventWrapper->getPlatformEvent(), CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT));
- event->getEvents()->at(i)->setRecurrenceId(calendar_svc_struct_get_time(eventWrapper->getPlatformEvent(), CAL_VALUE_GMT_COMPLETED_DATE_TIME, CAL_TZ_FLAG_GMT));
+ LogInfo("Set the saved rid: "<<calendar_svc_struct_get_lli(eventWrapper->getPlatformEvent(), CAL_VALUE_LLI_COMPLETED_TIME));
+ event->getEvents()->at(i)->setRecurrenceId(calendar_svc_struct_get_lli(eventWrapper->getPlatformEvent(), CAL_VALUE_LLI_COMPLETED_TIME));
}
}
}
// Determine the status of event change.
cal_iter *iter = NULL;
cal_struct *platformEvent = NULL;
- int index;
- int syncStatus;
-
- if( CAL_SUCCESS != calendar_svc_get_updated_event_list(thisCalendar->getAccountId(),
- thisCalendar->getLastChangeFetchTime(),
- &iter) ) {
- ThrowMsg(PlatformException, "Can't get the updated event list.");
+ int id;
+ int type;
+ int version = 0;
+ int errorCode;
+
+ int calendarId;
+ std::stringstream ss(thisCalendar->getId());
+ ss>>calendarId;
+
+ LogDebug("Getting items with calendar id: "<<calendarId<<", version: "<<thisCalendar->getLastChangedVersion()<<", type: "<<thisCalendar->getType());
+ if (CalendarEvent::TASK_TYPE==thisCalendar->getType()) {
+ errorCode = calendar_svc_todo_get_changes(calendarId,
+ thisCalendar->getLastChangedVersion(),
+ &iter);
+ } else {
+ errorCode = calendar_svc_event_get_changes(calendarId,
+ thisCalendar->getLastChangedVersion(),
+ &iter);
+ }
+ if( CAL_SUCCESS!=errorCode ) {
+ ThrowMsg(PlatformException, "Can't get the updated event list. Error code: "<<errorCode);
}
+
while( CAL_SUCCESS == calendar_svc_iter_next(iter) )
{
if ( CAL_SUCCESS != calendar_svc_iter_get_info(iter, &platformEvent) ) {
ThrowMsg(PlatformException, "Can't get the calendar info.");
}
- index = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
- syncStatus = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_SYNC_STATUS);
- LogDebug("index "<<index<<" , syncStatus "<<syncStatus);
- if ( CAL_SYNC_STATUS_NEW==syncStatus ) {
+ id = calendar_svc_struct_get_int(platformEvent, CALS_STRUCT_UPDATED_INT_ID);
+ type = calendar_svc_struct_get_int(platformEvent, CALS_STRUCT_UPDATED_INT_TYPE);
+ version = calendar_svc_struct_get_int(platformEvent, CALS_STRUCT_UPDATED_INT_VERSION);
+ LogDebug("id "<<id<<", type "<<type<<", version "<<version);
+ if ( CALS_UPDATED_TYPE_INSERTED==type ) {
eventPtr->setStatus(OnEventsChanged::ON_ADD);
- } else if ( CAL_SYNC_STATUS_UPDATED==syncStatus ) {
+ } else if ( CALS_UPDATED_TYPE_MODIFIED==type ) {
eventPtr->setStatus(OnEventsChanged::ON_UPDATE);
- } else if ( CAL_SYNC_STATUS_DELETED==syncStatus ) {
+ } else if ( CALS_UPDATED_TYPE_DELETED==type ) {
eventPtr->setStatus(OnEventsChanged::ON_DELETE);
} else {
if( platformEvent ) {
DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(thisCalendar->getType()));
Try {
- eventWrapper->loadEvent(index);
+ eventWrapper->loadEvent(id);
} Catch (NotFoundException){
- LogDebug("Handling deleted event with index: "<<index);
+ LogDebug("Handling deleted event with index: "<<id);
}
eventPtr->addEvent(eventWrapper->getAbstractEvent());
ThrowMsg(PlatformException, "Can't remove the iter.");
}
- std::time_t localTime = time(NULL);
- thisCalendar->setLastChangeFetchTime(localTime);
- LogInfo("Last change fetch time: "<<thisCalendar->getLastChangeFetchTime());
+ thisCalendar->setLastChangedVersion(version);
+ LogInfo("Last change fetch version: "<<thisCalendar->getLastChangedVersion());
eventPtr->setResult(true);
eventPtr->setCalendarType(thisCalendar->getType());
// Subscribe the watch to the platform just once.
if( m_changeEmitters.size()==0 )
{
- if( CAL_SUCCESS!=calendar_svc_subscribe_change(eventChangedCb, this) ) {
- ThrowMsg(PlatformException, "Can't subscribe the db change noti.");
+ if (CAL_SUCCESS!=calendar_svc_begin_trans() ) {
+ ThrowMsg(PlatformException, "Transaction failed.");
} else {
- // Save the last change fetch time to start watching.
- std::time_t localTime = time(NULL);
- setLastChangeFetchTime(localTime);
- LogInfo("Last change fetch time: "<<getLastChangeFetchTime());
+ if( CAL_SUCCESS!=calendar_svc_subscribe_change(eventChangedCb, this) ) {
+ calendar_svc_end_trans(true);
+ ThrowMsg(PlatformException, "Can't subscribe the db change noti.");
+ } else {
+ // Save the last change fetch version to start watching.
+ int version = calendar_svc_end_trans(true);
+ setLastChangedVersion(version);
+ LogInfo("Last change fetch version: "<<getLastChangedVersion());
+ }
}
}
LogDebug("entered");
Try
{
- m_changeEmitters.detach(event->getWatchId());
-
- if( m_changeEmitters.size()==0 ) {
- if( CAL_SUCCESS!=calendar_svc_unsubscribe_change(eventChangedCb) ) {
- ThrowMsg(PlatformException, "Can't unsubscribe the db change noti.");
- } else {
- LogDebug("Platform watch cleared successfully.");
+ if( m_changeEmitters.detach(event->getWatchId()) ) {
+ if( m_changeEmitters.size()==0 ) {
+ if( CAL_SUCCESS!=calendar_svc_unsubscribe_change(eventChangedCb) ) {
+ ThrowMsg(PlatformException, "Can't unsubscribe the db change noti.");
+ } else {
+ LogDebug("Platform watch cleared successfully.");
+ }
}
+ event->setResult(true);
+ } else {
+ LogInfo("Wrong watch Id.");
+ event->setResult(false);
}
- event->setResult(true);
}
Catch (Exception)
{
{
LogDebug("entered");
const CalendarEventPtr calEvent = event->getEvent();
- const std::time_t startDate = event->getStartDate();
- const std::time_t endDate = event->getEndDate();
+ const long long int startDate = event->getStartDate();
+ const long long int endDate = event->getEndDate();
event->setResult(true);
Try {
ThrowMsg(PlatformException, "This is not a recurring event.");
}
- std::time_t nextStartTime = 0;
- std::time_t nextEndTime = 0;
-
DPL::ScopedPtr<EventWrapper> eventWrapper(new EventWrapper(CalendarEvent::EVENT_TYPE));
// We must load the event from the DB in order to get the auto-calculated repeat end time.
- eventWrapper->loadEvent(event->getEvent()->getId());
- //eventWrapper->displayPlatformEvent();
+ eventWrapper->loadEvent(calEvent->getId());
- while ( CAL_SUCCESS==calendar_svc_util_next_valid_event(eventWrapper->getPlatformEvent(), startDate, endDate, &nextStartTime, &nextEndTime) )
+ cal_iter *iter = NULL;
+ cal_struct *cs;
+ int candidateIndex;
+ long long int dtstart, dtend;
+ int calendarId;
+ std::stringstream ss(getId());
+ ss>>calendarId;
+
+ int returnVal = calendar_svc_event_get_normal_list_by_period(calendarId, CALS_LIST_PERIOD_NORMAL_BASIC, startDate, endDate, &iter);
+ if( CAL_SUCCESS!=returnVal ) {
+ ThrowMsg(PlatformException, "Getting event instances failed due to "<<returnVal);
+ }
+
+ while ( CAL_SUCCESS==calendar_svc_iter_next(iter) )
{
- LogInfo("Found a next valid event: "<<nextStartTime);
- DPL::ScopedPtr<EventWrapper> recurringEventWrapper(new EventWrapper(getType()));
- recurringEventWrapper->loadEvent(calEvent->getId());
+ cs = NULL;
+ returnVal = calendar_svc_iter_get_info(iter, &cs);
+ if( CAL_SUCCESS!=returnVal ){
+ LogDebug("Iterator get info failed due to "<<returnVal);
+ continue;
+ }
- // Set distintive attributes of each instance.
- recurringEventWrapper->getAbstractEvent()->setRecurrenceId(nextStartTime);
- recurringEventWrapper->getAbstractEvent()->setStartTime(nextStartTime);
- recurringEventWrapper->getAbstractEvent()->setEndTime(nextEndTime);
+ candidateIndex = calendar_svc_struct_get_int(cs, CALS_LIST_PERIOD_NORMAL_BASIC_INT_EVENTID);
+ if(candidateIndex==calEvent->getId()) {
+ DPL::ScopedPtr<EventWrapper> recurringEventWrapper(new EventWrapper(getType()));
+ recurringEventWrapper->loadEvent(calEvent->getId());
- event->addExpandedEvent(recurringEventWrapper->getAbstractEvent());
+ // Set distintive attributes of each instance.
+ dtstart = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTSTART_UTIME);
+ dtend = calendar_svc_struct_get_lli(cs, CALS_LIST_PERIOD_NORMAL_BASIC_LLI_DTEND_UTIME);
+ recurringEventWrapper->getAbstractEvent()->setRecurrenceId(dtstart);
+ recurringEventWrapper->getAbstractEvent()->setStartTime(dtstart);
+ recurringEventWrapper->getAbstractEvent()->setEndTime(dtend);
+ LogInfo("Found a valid event instance with dtstart: "<<dtstart<<" and dtend: "<<dtend);
+
+ event->addExpandedEvent(recurringEventWrapper->getAbstractEvent());
+ }
}
LogInfo("Length of expanded events from parent: "<<event->getExpandedEventList()->size());
// Consider the detached events also.
- cal_iter *iter = NULL;
+ iter = NULL;
cal_struct *platformEvent = NULL;
int parentId = event->getEvent()->getId();
if(CAL_SUCCESS != calendar_svc_find_event_list(getAccountId(), CAL_VALUE_INT_ORIGINAL_EVENT_ID, (void*) parentId, &iter)) {
}
int detachedEventId = calendar_svc_struct_get_int(platformEvent, CAL_VALUE_INT_INDEX);
- std::time_t detachedStartTime = calendar_svc_struct_get_time(platformEvent, CAL_VALUE_GMT_START_DATE_TIME, CAL_TZ_FLAG_GMT);
- std::time_t detachedEndTime = calendar_svc_struct_get_time(platformEvent, CAL_VALUE_GMT_END_DATE_TIME, CAL_TZ_FLAG_GMT);
+ long long int detachedStartTime = calendar_svc_struct_get_lli(platformEvent, CALS_VALUE_LLI_DTSTART_UTIME);
+ long long int detachedEndTime = calendar_svc_struct_get_lli(platformEvent, CALS_VALUE_LLI_DTEND_UTIME);
if (detachedStartTime>=startDate && detachedStartTime<=endDate) {
LogInfo("Found a valid detached event: "<<detachedStartTime);
DPL::ScopedPtr<EventWrapper> detachedEventWrapper(new EventWrapper(getType()));