Fix # 2467153 (Handle change in attendee status from Calendar UI)
* Fill in this missing piece of meeting related functionality. * We keep track of the last synced attendee status in the newly created syncAdapterData event column * When this changes, we (in addition to syncing up the change) send an email to the organizer (unless we're the organizer, of course) Bug: 2467153 Change-Id: I6332fb6d0839e33d4c54bd4358ee0f154bff6612
This commit is contained in:
parent
ed4d09a614
commit
4c6683f152
@ -20,6 +20,7 @@ package com.android.exchange.adapter;
|
|||||||
import com.android.email.Email;
|
import com.android.email.Email;
|
||||||
import com.android.email.provider.EmailContent;
|
import com.android.email.provider.EmailContent;
|
||||||
import com.android.email.provider.EmailContent.Mailbox;
|
import com.android.email.provider.EmailContent.Mailbox;
|
||||||
|
import com.android.email.provider.EmailContent.Message;
|
||||||
import com.android.exchange.EasOutboxService;
|
import com.android.exchange.EasOutboxService;
|
||||||
import com.android.exchange.EasSyncService;
|
import com.android.exchange.EasSyncService;
|
||||||
import com.android.exchange.utility.CalendarUtilities;
|
import com.android.exchange.utility.CalendarUtilities;
|
||||||
@ -1184,11 +1185,17 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
|
|||||||
boolean first = true;
|
boolean first = true;
|
||||||
while (eventIterator.hasNext()) {
|
while (eventIterator.hasNext()) {
|
||||||
Entity entity = eventIterator.next();
|
Entity entity = eventIterator.next();
|
||||||
String clientId = UUID.randomUUID().toString();
|
|
||||||
// For each of these entities, create the change commands
|
// For each of these entities, create the change commands
|
||||||
ContentValues entityValues = entity.getEntityValues();
|
ContentValues entityValues = entity.getEntityValues();
|
||||||
String serverId = entityValues.getAsString(Events._SYNC_ID);
|
String serverId = entityValues.getAsString(Events._SYNC_ID);
|
||||||
|
|
||||||
|
// Find our uid in the entity; otherwise create one
|
||||||
|
String clientId = entityValues.getAsString(Events._SYNC_LOCAL_ID);
|
||||||
|
if (clientId == null) {
|
||||||
|
clientId = UUID.randomUUID().toString();
|
||||||
|
}
|
||||||
|
|
||||||
// EAS 2.5 needs: BusyStatus DtStamp EndTime Sensitivity StartTime TimeZone UID
|
// EAS 2.5 needs: BusyStatus DtStamp EndTime Sensitivity StartTime TimeZone UID
|
||||||
// We can generate all but what we're testing for below
|
// We can generate all but what we're testing for below
|
||||||
String organizerEmail = entityValues.getAsString(Events.ORGANIZER);
|
String organizerEmail = entityValues.getAsString(Events.ORGANIZER);
|
||||||
@ -1251,7 +1258,8 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
|
|||||||
mUpdatedIdList.add(entityValues.getAsLong(Events._ID));
|
mUpdatedIdList.add(entityValues.getAsLong(Events._ID));
|
||||||
|
|
||||||
// Send the meeting invite if there are attendees and we're the organizer
|
// Send the meeting invite if there are attendees and we're the organizer
|
||||||
if (hasAttendees && organizerEmail.equalsIgnoreCase(mAccount.mEmailAddress)) {
|
boolean selfOrganizer = organizerEmail.equalsIgnoreCase(mAccount.mEmailAddress);
|
||||||
|
if (hasAttendees && selfOrganizer) {
|
||||||
EmailContent.Message msg =
|
EmailContent.Message msg =
|
||||||
CalendarUtilities.createMessageForEventId(mContext, eventId,
|
CalendarUtilities.createMessageForEventId(mContext, eventId,
|
||||||
EmailContent.Message.FLAG_OUTGOING_MEETING_INVITE, clientId,
|
EmailContent.Message.FLAG_OUTGOING_MEETING_INVITE, clientId,
|
||||||
@ -1259,6 +1267,46 @@ public class CalendarSyncAdapter extends AbstractSyncAdapter {
|
|||||||
if (msg != null) {
|
if (msg != null) {
|
||||||
EasOutboxService.sendMessage(mContext, mAccount.mId, msg);
|
EasOutboxService.sendMessage(mContext, mAccount.mId, msg);
|
||||||
}
|
}
|
||||||
|
} else if (!selfOrganizer) {
|
||||||
|
// If we're not the organizer, see if we've changed our attendee status
|
||||||
|
int currentStatus = entityValues.getAsInteger(Events.SELF_ATTENDEE_STATUS);
|
||||||
|
String adapterData = entityValues.getAsString(Events.SYNC_ADAPTER_DATA);
|
||||||
|
int syncStatus = Attendees.ATTENDEE_STATUS_NONE;
|
||||||
|
if (adapterData != null) {
|
||||||
|
syncStatus = Integer.parseInt(adapterData);
|
||||||
|
}
|
||||||
|
if ((currentStatus != syncStatus) &&
|
||||||
|
(currentStatus != Attendees.ATTENDEE_STATUS_NONE)) {
|
||||||
|
// If so, send a meeting reply
|
||||||
|
int messageFlag = 0;
|
||||||
|
switch (currentStatus) {
|
||||||
|
case Attendees.ATTENDEE_STATUS_ACCEPTED:
|
||||||
|
messageFlag = Message.FLAG_OUTGOING_MEETING_ACCEPT;
|
||||||
|
break;
|
||||||
|
case Attendees.ATTENDEE_STATUS_DECLINED:
|
||||||
|
messageFlag = Message.FLAG_OUTGOING_MEETING_DECLINE;
|
||||||
|
break;
|
||||||
|
case Attendees.ATTENDEE_STATUS_TENTATIVE:
|
||||||
|
messageFlag = Message.FLAG_OUTGOING_MEETING_TENTATIVE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
// Make sure we have a valid status (messageFlag should never be zero)
|
||||||
|
if (messageFlag != 0) {
|
||||||
|
// Save away the new status
|
||||||
|
cidValues.clear();
|
||||||
|
cidValues.put(Events.SYNC_ADAPTER_DATA,
|
||||||
|
Integer.toString(currentStatus));
|
||||||
|
cr.update(ContentUris.withAppendedId(uri, eventId), cidValues, null,
|
||||||
|
null);
|
||||||
|
// Send mail to the organizer advising of the new status
|
||||||
|
EmailContent.Message msg =
|
||||||
|
CalendarUtilities.createMessageForEventId(mContext, eventId,
|
||||||
|
messageFlag, clientId, mAccount);
|
||||||
|
if (msg != null) {
|
||||||
|
EasOutboxService.sendMessage(mContext, mAccount.mId, msg);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!first) {
|
if (!first) {
|
||||||
|
Loading…
Reference in New Issue
Block a user