Send cancellation email when user-created event is deleted
Bug: 2465496 Change-Id: I49bf9951e816a4500b7622cbca84fb75edfdb76c
This commit is contained in:
parent
ec2f181b2c
commit
29c38d2c84
|
@ -634,6 +634,10 @@
|
||||||
and the title of the meeting (i.e. the title of the meeting becomes part of the subject of
|
and the title of the meeting (i.e. the title of the meeting becomes part of the subject of
|
||||||
the message that's sent) -->
|
the message that's sent) -->
|
||||||
<string name="meeting_tentative">Tentative: <xliff:g id="subject">%s</xliff:g></string>
|
<string name="meeting_tentative">Tentative: <xliff:g id="subject">%s</xliff:g></string>
|
||||||
|
<!-- Message subject for a canceled meeting email. This is followed by a colon
|
||||||
|
and the title of the meeting (i.e. the title of the meeting becomes part of the subject of
|
||||||
|
the message that's sent) -->
|
||||||
|
<string name="meeting_canceled">Canceled: <xliff:g id="subject">%s</xliff:g></string>
|
||||||
|
|
||||||
<!-- Message that appears if the AccountManager cannot create the system Account -->
|
<!-- Message that appears if the AccountManager cannot create the system Account -->
|
||||||
<string name="system_account_create_failed">The AccountManager could not create the Account; please try again.</string>
|
<string name="system_account_create_failed">The AccountManager could not create the Account; please try again.</string>
|
||||||
|
|
|
@ -590,6 +590,8 @@ public abstract class EmailContent {
|
||||||
FLAG_OUTGOING_MEETING_INVITE | FLAG_OUTGOING_MEETING_CANCEL |
|
FLAG_OUTGOING_MEETING_INVITE | FLAG_OUTGOING_MEETING_CANCEL |
|
||||||
FLAG_OUTGOING_MEETING_ACCEPT | FLAG_OUTGOING_MEETING_DECLINE |
|
FLAG_OUTGOING_MEETING_ACCEPT | FLAG_OUTGOING_MEETING_DECLINE |
|
||||||
FLAG_OUTGOING_MEETING_TENTATIVE;
|
FLAG_OUTGOING_MEETING_TENTATIVE;
|
||||||
|
public static final int FLAG_OUTGOING_MEETING_REQUEST_MASK =
|
||||||
|
FLAG_OUTGOING_MEETING_INVITE | FLAG_OUTGOING_MEETING_CANCEL;
|
||||||
|
|
||||||
public Message() {
|
public Message() {
|
||||||
mBaseUri = CONTENT_URI;
|
mBaseUri = CONTENT_URI;
|
||||||
|
|
|
@ -103,6 +103,7 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
|
||||||
|
|
||||||
private ArrayList<Long> mDeletedIdList = new ArrayList<Long>();
|
private ArrayList<Long> mDeletedIdList = new ArrayList<Long>();
|
||||||
private ArrayList<Long> mUpdatedIdList = new ArrayList<Long>();
|
private ArrayList<Long> mUpdatedIdList = new ArrayList<Long>();
|
||||||
|
private ArrayList<Long> mSendCancelIdList = new ArrayList<Long>();
|
||||||
|
|
||||||
private String[] mCalendarIdArgument;
|
private String[] mCalendarIdArgument;
|
||||||
|
|
||||||
|
@ -772,6 +773,23 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
|
||||||
mOps.add(SyncStateContract.Helpers.newSetOperation(SyncState.CONTENT_URI,
|
mOps.add(SyncStateContract.Helpers.newSetOperation(SyncState.CONTENT_URI,
|
||||||
mAccountManagerAccount, mMailbox.mSyncKey.getBytes()));
|
mAccountManagerAccount, mMailbox.mSyncKey.getBytes()));
|
||||||
|
|
||||||
|
// We need to send cancellations now, because the Event won't exist after the commit
|
||||||
|
for (long eventId: mSendCancelIdList) {
|
||||||
|
EmailContent.Message msg;
|
||||||
|
try {
|
||||||
|
msg = CalendarUtilities.createMessageForEventId(mContext, eventId,
|
||||||
|
EmailContent.Message.FLAG_OUTGOING_MEETING_CANCEL, null,
|
||||||
|
mAccount);
|
||||||
|
} catch (RemoteException e) {
|
||||||
|
// Nothing to do here; the Event may no longer exist
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (msg != null) {
|
||||||
|
EasOutboxService.sendMessage(mContext, mAccount.mId, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mSendCancelIdList.clear();
|
||||||
|
|
||||||
// Execute these all at once...
|
// Execute these all at once...
|
||||||
mOps.execute();
|
mOps.execute();
|
||||||
|
|
||||||
|
@ -781,6 +799,13 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
|
||||||
cv.put(Events._SYNC_DIRTY, 0);
|
cv.put(Events._SYNC_DIRTY, 0);
|
||||||
mContentResolver.update(sEventsUri, cv, DIRTY_IN_CALENDAR,
|
mContentResolver.update(sEventsUri, cv, DIRTY_IN_CALENDAR,
|
||||||
new String[] {Long.toString(mCalendarId)});
|
new String[] {Long.toString(mCalendarId)});
|
||||||
|
// Send meeting cancelation notices
|
||||||
|
// Really delete the events...
|
||||||
|
for (long eventId: mDeletedIdList) {
|
||||||
|
mContentResolver.delete(ContentUris.withAppendedId(sEventsUri, eventId),
|
||||||
|
null, null);
|
||||||
|
}
|
||||||
|
mDeletedIdList.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1218,7 +1243,11 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
|
||||||
if (entityValues.getAsInteger(Events.DELETED) == 1) {
|
if (entityValues.getAsInteger(Events.DELETED) == 1) {
|
||||||
userLog("Deleting event with serverId: ", serverId);
|
userLog("Deleting event with serverId: ", serverId);
|
||||||
s.start(Tags.SYNC_DELETE).data(Tags.SYNC_SERVER_ID, serverId).end();
|
s.start(Tags.SYNC_DELETE).data(Tags.SYNC_SERVER_ID, serverId).end();
|
||||||
mDeletedIdList.add(entityValues.getAsLong(Events._ID));
|
mDeletedIdList.add(eventId);
|
||||||
|
if (entityValues.getAsString(Events.ORGANIZER)
|
||||||
|
.equalsIgnoreCase(mAccount.mEmailAddress)) {
|
||||||
|
mSendCancelIdList.add(eventId);
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
userLog("Upsync change to event with serverId: " + serverId);
|
userLog("Upsync change to event with serverId: " + serverId);
|
||||||
|
|
|
@ -858,7 +858,7 @@ public class CalendarUtilities {
|
||||||
msg.mTimeStamp = System.currentTimeMillis();
|
msg.mTimeStamp = System.currentTimeMillis();
|
||||||
|
|
||||||
String method;
|
String method;
|
||||||
if (messageFlag == EmailContent.Message.FLAG_OUTGOING_MEETING_INVITE) {
|
if ((messageFlag & EmailContent.Message.FLAG_OUTGOING_MEETING_REQUEST_MASK) != 0) {
|
||||||
method = "REQUEST";
|
method = "REQUEST";
|
||||||
} else {
|
} else {
|
||||||
method = "REPLY";
|
method = "REPLY";
|
||||||
|
@ -934,14 +934,18 @@ public class CalendarUtilities {
|
||||||
case Message.FLAG_OUTGOING_MEETING_TENTATIVE:
|
case Message.FLAG_OUTGOING_MEETING_TENTATIVE:
|
||||||
titleId = R.string.meeting_tentative;
|
titleId = R.string.meeting_tentative;
|
||||||
break;
|
break;
|
||||||
|
case Message.FLAG_OUTGOING_MEETING_CANCEL:
|
||||||
|
titleId = R.string.meeting_canceled;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
String title = entityValues.getAsString(Events.TITLE);
|
String title = entityValues.getAsString(Events.TITLE);
|
||||||
if (title == null) {
|
if (title == null) {
|
||||||
title = "";
|
title = "";
|
||||||
}
|
}
|
||||||
ics.writeTag("SUMMARY", title);
|
ics.writeTag("SUMMARY", title);
|
||||||
msg.mSubject = context.getResources().getString(titleId, title);
|
if (titleId != 0) {
|
||||||
|
msg.mSubject = context.getResources().getString(titleId, title);
|
||||||
|
}
|
||||||
if (method.equals("REQUEST")) {
|
if (method.equals("REQUEST")) {
|
||||||
if (entityValues.containsKey(Events.ALL_DAY)) {
|
if (entityValues.containsKey(Events.ALL_DAY)) {
|
||||||
Integer ade = entityValues.getAsInteger(Events.ALL_DAY);
|
Integer ade = entityValues.getAsInteger(Events.ALL_DAY);
|
||||||
|
@ -1006,7 +1010,7 @@ public class CalendarUtilities {
|
||||||
// This shouldn't be possible, but allow for it
|
// This shouldn't be possible, but allow for it
|
||||||
if (attendeeEmail == null) continue;
|
if (attendeeEmail == null) continue;
|
||||||
|
|
||||||
if (messageFlag == Message.FLAG_OUTGOING_MEETING_INVITE) {
|
if ((messageFlag & Message.FLAG_OUTGOING_MEETING_REQUEST_MASK) != 0) {
|
||||||
String icalTag = ICALENDAR_ATTENDEE_INVITE;
|
String icalTag = ICALENDAR_ATTENDEE_INVITE;
|
||||||
if (attendeeName != null) {
|
if (attendeeName != null) {
|
||||||
icalTag += ";CN=" + attendeeName;
|
icalTag += ";CN=" + attendeeName;
|
||||||
|
|
Loading…
Reference in New Issue