From c3aa31820003bd62a863dc28d699cebdbcead228 Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Sun, 11 Apr 2010 13:22:15 -0700 Subject: [PATCH] Send email to organizer if attendee deletes event/exception * There are two cases, event and exception and both are fixed in this CL Bug: 2587775 Change-Id: Id325c4877a77074ca6edd4d7fbeb54971d4cf984 --- .../exchange/adapter/CalendarSyncAdapter.java | 41 ++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/src/com/android/exchange/adapter/CalendarSyncAdapter.java b/src/com/android/exchange/adapter/CalendarSyncAdapter.java index e1d7e4f6e..389e82b65 100644 --- a/src/com/android/exchange/adapter/CalendarSyncAdapter.java +++ b/src/com/android/exchange/adapter/CalendarSyncAdapter.java @@ -1384,6 +1384,21 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter { } } + /** + * Convenience method for sending an email to the organizer declining the meeting + * @param entity + * @param clientId + */ + private void sendDeclinedEmail(Entity entity, String clientId) { + Message msg = + CalendarUtilities.createMessageForEntity(mContext, entity, + Message.FLAG_OUTGOING_MEETING_DECLINE, clientId, mAccount); + if (msg != null) { + userLog("Queueing declined response to " + msg.mTo); + mOutgoingMailList.add(msg); + } + } + @Override public boolean sendLocalChanges(Serializer s) throws IOException { ContentResolver cr = mService.mContentResolver; @@ -1479,6 +1494,8 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter { mDeletedIdList.add(eventId); if (selfOrganizer) { mSendCancelIdList.add(eventId); + } else { + sendDeclinedEmail(entity, clientId); } continue; } @@ -1554,7 +1571,29 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter { // Copy location so that it's included in the outgoing email if (entityValues.containsKey(Events.EVENT_LOCATION)) { exValues.put(Events.EVENT_LOCATION, - entityValues.getAsString(Events.EVENT_LOCATION)); + entityValues.getAsString(Events.EVENT_LOCATION)); + } + + if ((getInt(exValues, Events.DELETED) == 1) || + (getInt(exValues, Events.STATUS) == + Events.STATUS_CANCELED)) { + // Add the eventId of the exception to the proper list, so that + // the dirty bit is cleared or the event is deleted after the + // sync has completed + mDeletedIdList.add(exEventId); + flag = Message.FLAG_OUTGOING_MEETING_CANCEL; + if (!selfOrganizer) { + // Send a cancellation notice to the organizer + // Since CalendarProvider2 sets the organizer of exceptions + // to the user, we have to reset it first to the original + // organizer + exValues.put(Events.ORGANIZER, + entityValues.getAsString(Events.ORGANIZER)); + sendDeclinedEmail(exEntity, clientId); + } + } else { + mUploadedIdList.add(exEventId); + flag = Message.FLAG_OUTGOING_MEETING_INVITE; } if (selfOrganizer) {