From ad809fd7441d72e8cde7a9e68f5c8b8e7e8c871d Mon Sep 17 00:00:00 2001 From: Marc Blank Date: Tue, 16 Mar 2010 10:45:27 -0700 Subject: [PATCH] Send appropriate response email when reply from MessageView * The code was hard-wired to accept (ancient placehold code) * Send code that depends on the user's actual response * Rename inappropriately named method in Controller Bug: 2515961 Change-Id: I8985a3206fc8c4498521b08806a1093abaf4a42c --- .../android/email/activity/MessageView.java | 8 +++---- src/com/android/exchange/EasSyncService.java | 21 +++++++++++++++---- 2 files changed, 21 insertions(+), 8 deletions(-) diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java index 53039e369..1e05622e3 100644 --- a/src/com/android/email/activity/MessageView.java +++ b/src/com/android/email/activity/MessageView.java @@ -703,7 +703,7 @@ public class MessageView extends Activity implements OnClickListener { /** * Send a service message indicating that a meeting invite button has been clicked. */ - private void onAccept(int response, int toastResId) { + private void onRespond(int response, int toastResId) { // do not send twice in a row the same response if (mPreviousMeetingResponse != response) { mController.sendMeetingResponse(mMessageId, response, mControllerCallback); @@ -791,15 +791,15 @@ public class MessageView extends Activity implements OnClickListener { onShowPictures(); break; case R.id.accept: - onAccept(EmailServiceConstants.MEETING_REQUEST_ACCEPTED, + onRespond(EmailServiceConstants.MEETING_REQUEST_ACCEPTED, R.string.message_view_invite_toast_yes); break; case R.id.maybe: - onAccept(EmailServiceConstants.MEETING_REQUEST_TENTATIVE, + onRespond(EmailServiceConstants.MEETING_REQUEST_TENTATIVE, R.string.message_view_invite_toast_maybe); break; case R.id.decline: - onAccept(EmailServiceConstants.MEETING_REQUEST_DECLINED, + onRespond(EmailServiceConstants.MEETING_REQUEST_DECLINED, R.string.message_view_invite_toast_no); break; case R.id.invite_link: diff --git a/src/com/android/exchange/EasSyncService.java b/src/com/android/exchange/EasSyncService.java index 15b4b684e..9c71cf1a3 100644 --- a/src/com/android/exchange/EasSyncService.java +++ b/src/com/android/exchange/EasSyncService.java @@ -33,6 +33,7 @@ import com.android.email.provider.EmailContent.HostAuth; import com.android.email.provider.EmailContent.Mailbox; import com.android.email.provider.EmailContent.MailboxColumns; import com.android.email.provider.EmailContent.Message; +import com.android.email.service.EmailServiceConstants; import com.android.email.service.EmailServiceProxy; import com.android.email.service.EmailServiceStatus; import com.android.exchange.adapter.AbstractSyncAdapter; @@ -852,7 +853,7 @@ public class EasSyncService extends AbstractSyncService { * will consist a little bit of event information and an iCalendar attachment * @param msg the meeting request email */ - private void sendMeetingResponseMail(Message msg) { + private void sendMeetingResponseMail(Message msg, int response) { // Get the meeting information; we'd better have some... PackedString meetingInfo = new PackedString(msg.mMeetingInfo); if (meetingInfo == null) return; @@ -899,9 +900,21 @@ public class EasSyncService extends AbstractSyncService { // Create a message from the Entity we've built. The message will have fields like // to, subject, date, and text filled in. There will also be an "inline" attachment // which is in iCalendar format + int flag; + switch(response) { + case EmailServiceConstants.MEETING_REQUEST_ACCEPTED: + flag = Message.FLAG_OUTGOING_MEETING_ACCEPT; + break; + case EmailServiceConstants.MEETING_REQUEST_DECLINED: + flag = Message.FLAG_OUTGOING_MEETING_DECLINE; + break; + case EmailServiceConstants.MEETING_REQUEST_TENTATIVE: + default: + flag = Message.FLAG_OUTGOING_MEETING_TENTATIVE; + break; + } Message outgoingMsg = - CalendarUtilities.createMessageForEntity(mContext, entity, - Message.FLAG_OUTGOING_MEETING_ACCEPT, + CalendarUtilities.createMessageForEntity(mContext, entity, flag, meetingInfo.get(MeetingInfo.MEETING_UID), mAccount); // Assuming we got a message back (we might not if the event has been deleted), send it if (outgoingMsg != null) { @@ -935,7 +948,7 @@ public class EasSyncService extends AbstractSyncService { InputStream is = res.getEntity().getContent(); if (len != 0) { new MeetingResponseParser(is, this).parse(); - sendMeetingResponseMail(msg); + sendMeetingResponseMail(msg, req.mResponse); } } else if (isAuthError(status)) { throw new EasAuthenticationException();