LegacyConversions.java revision 2193962ca2b3157e79f731736afa2a0c972e778a
1/*
2 * Copyright (C) 2009 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package com.android.email;
18
19import com.android.email.provider.EmailContent;
20import com.android.email.provider.EmailContent.Attachment;
21import com.android.email.provider.EmailContent.AttachmentColumns;
22import com.android.email.provider.EmailContent.Mailbox;
23import com.android.emailcommon.internet.MimeBodyPart;
24import com.android.emailcommon.internet.MimeHeader;
25import com.android.emailcommon.internet.MimeMessage;
26import com.android.emailcommon.internet.MimeMultipart;
27import com.android.emailcommon.internet.MimeUtility;
28import com.android.emailcommon.internet.TextBody;
29import com.android.emailcommon.mail.Address;
30import com.android.emailcommon.mail.Flag;
31import com.android.emailcommon.mail.Message;
32import com.android.emailcommon.mail.MessagingException;
33import com.android.emailcommon.mail.Part;
34import com.android.emailcommon.mail.Message.RecipientType;
35import com.android.emailcommon.utility.AttachmentUtilities;
36
37import org.apache.commons.io.IOUtils;
38
39import android.content.ContentUris;
40import android.content.ContentValues;
41import android.content.Context;
42import android.database.Cursor;
43import android.net.Uri;
44import android.util.Log;
45
46import java.io.File;
47import java.io.FileOutputStream;
48import java.io.IOException;
49import java.io.InputStream;
50import java.util.ArrayList;
51import java.util.Date;
52import java.util.HashMap;
53
54public class LegacyConversions {
55
56    /** DO NOT CHECK IN "TRUE" */
57    private static final boolean DEBUG_ATTACHMENTS = false;
58
59    /** Used for mapping folder names to type codes (e.g. inbox, drafts, trash) */
60    private static final HashMap<String, Integer>
61            sServerMailboxNames = new HashMap<String, Integer>();
62
63    /**
64     * Values for HEADER_ANDROID_BODY_QUOTED_PART to tag body parts
65     */
66    /* package */ static final String BODY_QUOTED_PART_REPLY = "quoted-reply";
67    /* package */ static final String BODY_QUOTED_PART_FORWARD = "quoted-forward";
68    /* package */ static final String BODY_QUOTED_PART_INTRO = "quoted-intro";
69
70    /**
71     * Copy field-by-field from a "store" message to a "provider" message
72     * @param message The message we've just downloaded (must be a MimeMessage)
73     * @param localMessage The message we'd like to write into the DB
74     * @result true if dirty (changes were made)
75     */
76    public static boolean updateMessageFields(EmailContent.Message localMessage, Message message,
77                long accountId, long mailboxId) throws MessagingException {
78
79        Address[] from = message.getFrom();
80        Address[] to = message.getRecipients(Message.RecipientType.TO);
81        Address[] cc = message.getRecipients(Message.RecipientType.CC);
82        Address[] bcc = message.getRecipients(Message.RecipientType.BCC);
83        Address[] replyTo = message.getReplyTo();
84        String subject = message.getSubject();
85        Date sentDate = message.getSentDate();
86        Date internalDate = message.getInternalDate();
87
88        if (from != null && from.length > 0) {
89            localMessage.mDisplayName = from[0].toFriendly();
90        }
91        if (sentDate != null) {
92            localMessage.mTimeStamp = sentDate.getTime();
93        }
94        if (subject != null) {
95            localMessage.mSubject = subject;
96        }
97        localMessage.mFlagRead = message.isSet(Flag.SEEN);
98
99        // Keep the message in the "unloaded" state until it has (at least) a display name.
100        // This prevents early flickering of empty messages in POP download.
101        if (localMessage.mFlagLoaded != EmailContent.Message.FLAG_LOADED_COMPLETE) {
102            if (localMessage.mDisplayName == null || "".equals(localMessage.mDisplayName)) {
103                localMessage.mFlagLoaded = EmailContent.Message.FLAG_LOADED_UNLOADED;
104            } else {
105                localMessage.mFlagLoaded = EmailContent.Message.FLAG_LOADED_PARTIAL;
106            }
107        }
108        localMessage.mFlagFavorite = message.isSet(Flag.FLAGGED);
109//        public boolean mFlagAttachment = false;
110//        public int mFlags = 0;
111
112        localMessage.mServerId = message.getUid();
113        if (internalDate != null) {
114            localMessage.mServerTimeStamp = internalDate.getTime();
115        }
116//        public String mClientId;
117
118        // Only replace the local message-id if a new one was found.  This is seen in some ISP's
119        // which may deliver messages w/o a message-id header.
120        String messageId = ((MimeMessage)message).getMessageId();
121        if (messageId != null) {
122            localMessage.mMessageId = messageId;
123        }
124
125//        public long mBodyKey;
126        localMessage.mMailboxKey = mailboxId;
127        localMessage.mAccountKey = accountId;
128
129        if (from != null && from.length > 0) {
130            localMessage.mFrom = Address.pack(from);
131        }
132
133        localMessage.mTo = Address.pack(to);
134        localMessage.mCc = Address.pack(cc);
135        localMessage.mBcc = Address.pack(bcc);
136        localMessage.mReplyTo = Address.pack(replyTo);
137
138//        public String mText;
139//        public String mHtml;
140//        public String mTextReply;
141//        public String mHtmlReply;
142
143//        // Can be used while building messages, but is NOT saved by the Provider
144//        transient public ArrayList<Attachment> mAttachments = null;
145
146        return true;
147    }
148
149    /**
150     * Copy attachments from MimeMessage to provider Message.
151     *
152     * @param context a context for file operations
153     * @param localMessage the attachments will be built against this message
154     * @param attachments the attachments to add
155     * @throws IOException
156     */
157    public static void updateAttachments(Context context, EmailContent.Message localMessage,
158            ArrayList<Part> attachments) throws MessagingException, IOException {
159        localMessage.mAttachments = null;
160        for (Part attachmentPart : attachments) {
161            addOneAttachment(context, localMessage, attachmentPart);
162        }
163    }
164
165    /**
166     * Add a single attachment part to the message
167     *
168     * This will skip adding attachments if they are already found in the attachments table.
169     * The heuristic for this will fail (false-positive) if two identical attachments are
170     * included in a single POP3 message.
171     * TODO: Fix that, by (elsewhere) simulating an mLocation value based on the attachments
172     * position within the list of multipart/mixed elements.  This would make every POP3 attachment
173     * unique, and might also simplify the code (since we could just look at the positions, and
174     * ignore the filename, etc.)
175     *
176     * TODO: Take a closer look at encoding and deal with it if necessary.
177     *
178     * @param context a context for file operations
179     * @param localMessage the attachments will be built against this message
180     * @param part a single attachment part from POP or IMAP
181     * @throws IOException
182     */
183    private static void addOneAttachment(Context context, EmailContent.Message localMessage,
184            Part part) throws MessagingException, IOException {
185
186        Attachment localAttachment = new Attachment();
187
188        // Transfer fields from mime format to provider format
189        String contentType = MimeUtility.unfoldAndDecode(part.getContentType());
190        String name = MimeUtility.getHeaderParameter(contentType, "name");
191        if (name == null) {
192            String contentDisposition = MimeUtility.unfoldAndDecode(part.getDisposition());
193            name = MimeUtility.getHeaderParameter(contentDisposition, "filename");
194        }
195
196        // Incoming attachment: Try to pull size from disposition (if not downloaded yet)
197        long size = 0;
198        String disposition = part.getDisposition();
199        if (disposition != null) {
200            String s = MimeUtility.getHeaderParameter(disposition, "size");
201            if (s != null) {
202                size = Long.parseLong(s);
203            }
204        }
205
206        // Get partId for unloaded IMAP attachments (if any)
207        // This is only provided (and used) when we have structure but not the actual attachment
208        String[] partIds = part.getHeader(MimeHeader.HEADER_ANDROID_ATTACHMENT_STORE_DATA);
209        String partId = partIds != null ? partIds[0] : null;
210
211        localAttachment.mFileName = name;
212        localAttachment.mMimeType = part.getMimeType();
213        localAttachment.mSize = size;           // May be reset below if file handled
214        localAttachment.mContentId = part.getContentId();
215        localAttachment.mContentUri = null;     // Will be rewritten by saveAttachmentBody
216        localAttachment.mMessageKey = localMessage.mId;
217        localAttachment.mLocation = partId;
218        localAttachment.mEncoding = "B";        // TODO - convert other known encodings
219        localAttachment.mAccountKey = localMessage.mAccountKey;
220
221        if (DEBUG_ATTACHMENTS) {
222            Log.d(Email.LOG_TAG, "Add attachment " + localAttachment);
223        }
224
225        // To prevent duplication - do we already have a matching attachment?
226        // The fields we'll check for equality are:
227        //  mFileName, mMimeType, mContentId, mMessageKey, mLocation
228        // NOTE:  This will false-positive if you attach the exact same file, twice, to a POP3
229        // message.  We can live with that - you'll get one of the copies.
230        Uri uri = ContentUris.withAppendedId(Attachment.MESSAGE_ID_URI, localMessage.mId);
231        Cursor cursor = context.getContentResolver().query(uri, Attachment.CONTENT_PROJECTION,
232                null, null, null);
233        boolean attachmentFoundInDb = false;
234        try {
235            while (cursor.moveToNext()) {
236                Attachment dbAttachment = new Attachment();
237                dbAttachment.restore(cursor);
238                // We test each of the fields here (instead of in SQL) because they may be
239                // null, or may be strings.
240                if (stringNotEqual(dbAttachment.mFileName, localAttachment.mFileName)) continue;
241                if (stringNotEqual(dbAttachment.mMimeType, localAttachment.mMimeType)) continue;
242                if (stringNotEqual(dbAttachment.mContentId, localAttachment.mContentId)) continue;
243                if (stringNotEqual(dbAttachment.mLocation, localAttachment.mLocation)) continue;
244                // We found a match, so use the existing attachment id, and stop looking/looping
245                attachmentFoundInDb = true;
246                localAttachment.mId = dbAttachment.mId;
247                if (DEBUG_ATTACHMENTS) {
248                    Log.d(Email.LOG_TAG, "Skipped, found db attachment " + dbAttachment);
249                }
250                break;
251            }
252        } finally {
253            cursor.close();
254        }
255
256        // Save the attachment (so far) in order to obtain an id
257        if (!attachmentFoundInDb) {
258            localAttachment.save(context);
259        }
260
261        // If an attachment body was actually provided, we need to write the file now
262        saveAttachmentBody(context, part, localAttachment, localMessage.mAccountKey);
263
264        if (localMessage.mAttachments == null) {
265            localMessage.mAttachments = new ArrayList<Attachment>();
266        }
267        localMessage.mAttachments.add(localAttachment);
268        localMessage.mFlagAttachment = true;
269    }
270
271    /**
272     * Helper for addOneAttachment that compares two strings, deals with nulls, and treats
273     * nulls and empty strings as equal.
274     */
275    /* package */ static boolean stringNotEqual(String a, String b) {
276        if (a == null && b == null) return false;       // fast exit for two null strings
277        if (a == null) a = "";
278        if (b == null) b = "";
279        return !a.equals(b);
280    }
281
282    /**
283     * Save the body part of a single attachment, to a file in the attachments directory.
284     */
285    public static void saveAttachmentBody(Context context, Part part, Attachment localAttachment,
286            long accountId) throws MessagingException, IOException {
287        if (part.getBody() != null) {
288            long attachmentId = localAttachment.mId;
289
290            InputStream in = part.getBody().getInputStream();
291
292            File saveIn = AttachmentUtilities.getAttachmentDirectory(context, accountId);
293            if (!saveIn.exists()) {
294                saveIn.mkdirs();
295            }
296            File saveAs = AttachmentUtilities.getAttachmentFilename(context, accountId,
297                    attachmentId);
298            saveAs.createNewFile();
299            FileOutputStream out = new FileOutputStream(saveAs);
300            long copySize = IOUtils.copy(in, out);
301            in.close();
302            out.close();
303
304            // update the attachment with the extra information we now know
305            String contentUriString = AttachmentUtilities.getAttachmentUri(
306                    accountId, attachmentId).toString();
307
308            localAttachment.mSize = copySize;
309            localAttachment.mContentUri = contentUriString;
310
311            // update the attachment in the database as well
312            ContentValues cv = new ContentValues();
313            cv.put(AttachmentColumns.SIZE, copySize);
314            cv.put(AttachmentColumns.CONTENT_URI, contentUriString);
315            Uri uri = ContentUris.withAppendedId(Attachment.CONTENT_URI, attachmentId);
316            context.getContentResolver().update(uri, cv, null, null);
317        }
318    }
319
320    /**
321     * Read a complete Provider message into a legacy message (for IMAP upload).  This
322     * is basically the equivalent of LocalFolder.getMessages() + LocalFolder.fetch().
323     */
324    public static Message makeMessage(Context context, EmailContent.Message localMessage)
325            throws MessagingException {
326        MimeMessage message = new MimeMessage();
327
328        // LocalFolder.getMessages() equivalent:  Copy message fields
329        message.setSubject(localMessage.mSubject == null ? "" : localMessage.mSubject);
330        Address[] from = Address.unpack(localMessage.mFrom);
331        if (from.length > 0) {
332            message.setFrom(from[0]);
333        }
334        message.setSentDate(new Date(localMessage.mTimeStamp));
335        message.setUid(localMessage.mServerId);
336        message.setFlag(Flag.DELETED,
337                localMessage.mFlagLoaded == EmailContent.Message.FLAG_LOADED_DELETED);
338        message.setFlag(Flag.SEEN, localMessage.mFlagRead);
339        message.setFlag(Flag.FLAGGED, localMessage.mFlagFavorite);
340//      message.setFlag(Flag.DRAFT, localMessage.mMailboxKey == draftMailboxKey);
341        message.setRecipients(RecipientType.TO, Address.unpack(localMessage.mTo));
342        message.setRecipients(RecipientType.CC, Address.unpack(localMessage.mCc));
343        message.setRecipients(RecipientType.BCC, Address.unpack(localMessage.mBcc));
344        message.setReplyTo(Address.unpack(localMessage.mReplyTo));
345        message.setInternalDate(new Date(localMessage.mServerTimeStamp));
346        message.setMessageId(localMessage.mMessageId);
347
348        // LocalFolder.fetch() equivalent: build body parts
349        message.setHeader(MimeHeader.HEADER_CONTENT_TYPE, "multipart/mixed");
350        MimeMultipart mp = new MimeMultipart();
351        mp.setSubType("mixed");
352        message.setBody(mp);
353
354        try {
355            addTextBodyPart(mp, "text/html", null,
356                    EmailContent.Body.restoreBodyHtmlWithMessageId(context, localMessage.mId));
357        } catch (RuntimeException rte) {
358            Log.d(Email.LOG_TAG, "Exception while reading html body " + rte.toString());
359        }
360
361        try {
362            addTextBodyPart(mp, "text/plain", null,
363                    EmailContent.Body.restoreBodyTextWithMessageId(context, localMessage.mId));
364        } catch (RuntimeException rte) {
365            Log.d(Email.LOG_TAG, "Exception while reading text body " + rte.toString());
366        }
367
368        boolean isReply = (localMessage.mFlags & EmailContent.Message.FLAG_TYPE_REPLY) != 0;
369        boolean isForward = (localMessage.mFlags & EmailContent.Message.FLAG_TYPE_FORWARD) != 0;
370
371        // If there is a quoted part (forwarding or reply), add the intro first, and then the
372        // rest of it.  If it is opened in some other viewer, it will (hopefully) be displayed in
373        // the same order as we've just set up the blocks:  composed text, intro, replied text
374        if (isReply || isForward) {
375            try {
376                addTextBodyPart(mp, "text/plain", BODY_QUOTED_PART_INTRO,
377                        EmailContent.Body.restoreIntroTextWithMessageId(context, localMessage.mId));
378            } catch (RuntimeException rte) {
379                Log.d(Email.LOG_TAG, "Exception while reading text reply " + rte.toString());
380            }
381
382            String replyTag = isReply ? BODY_QUOTED_PART_REPLY : BODY_QUOTED_PART_FORWARD;
383            try {
384                addTextBodyPart(mp, "text/html", replyTag,
385                        EmailContent.Body.restoreReplyHtmlWithMessageId(context, localMessage.mId));
386            } catch (RuntimeException rte) {
387                Log.d(Email.LOG_TAG, "Exception while reading html reply " + rte.toString());
388            }
389
390            try {
391                addTextBodyPart(mp, "text/plain", replyTag,
392                        EmailContent.Body.restoreReplyTextWithMessageId(context, localMessage.mId));
393            } catch (RuntimeException rte) {
394                Log.d(Email.LOG_TAG, "Exception while reading text reply " + rte.toString());
395            }
396        }
397
398        // Attachments
399        // TODO: Make sure we deal with these as structures and don't accidentally upload files
400//        Uri uri = ContentUris.withAppendedId(Attachment.MESSAGE_ID_URI, localMessage.mId);
401//        Cursor attachments = context.getContentResolver().query(uri, Attachment.CONTENT_PROJECTION,
402//                null, null, null);
403//        try {
404//
405//        } finally {
406//            attachments.close();
407//        }
408
409        return message;
410    }
411
412    /**
413     * Helper method to add a body part for a given type of text, if found
414     *
415     * @param mp The text body part will be added to this multipart
416     * @param contentType The content-type of the text being added
417     * @param quotedPartTag If non-null, HEADER_ANDROID_BODY_QUOTED_PART will be set to this value
418     * @param partText The text to add.  If null, nothing happens
419     */
420    private static void addTextBodyPart(MimeMultipart mp, String contentType, String quotedPartTag,
421            String partText) throws MessagingException {
422        if (partText == null) {
423            return;
424        }
425        TextBody body = new TextBody(partText);
426        MimeBodyPart bp = new MimeBodyPart(body, contentType);
427        if (quotedPartTag != null) {
428            bp.addHeader(MimeHeader.HEADER_ANDROID_BODY_QUOTED_PART, quotedPartTag);
429        }
430        mp.addBodyPart(bp);
431    }
432
433    /**
434     * Conversion from provider account to legacy account
435     *
436     * Used for backup/restore.
437     *
438     * @param context application context
439     * @param fromAccount the provider account to be backed up (including transient hostauth's)
440     * @return a legacy Account object ready to be committed to preferences
441     */
442    /* package */ static Account makeLegacyAccount(Context context,
443            EmailContent.Account fromAccount) {
444        Account result = new Account(context);
445
446        result.setDescription(fromAccount.getDisplayName());
447        result.setEmail(fromAccount.getEmailAddress());
448        // fromAccount.mSyncKey - assume lost if restoring
449        result.setSyncWindow(fromAccount.getSyncLookback());
450        result.setAutomaticCheckIntervalMinutes(fromAccount.getSyncInterval());
451        // fromAccount.mHostAuthKeyRecv - id not saved; will be reassigned when restoring
452        // fromAccount.mHostAuthKeySend - id not saved; will be reassigned when restoring
453
454        // Provider Account flags, and how they are mapped.
455        //  FLAGS_NOTIFY_NEW_MAIL       -> mNotifyNewMail
456        //  FLAGS_VIBRATE_ALWAYS        -> mVibrate
457        //  FLAGS_VIBRATE_WHEN_SILENT   -> mVibrateWhenSilent
458        //  DELETE_POLICY_NEVER         -> mDeletePolicy
459        //  DELETE_POLICY_7DAYS
460        //  DELETE_POLICY_ON_DELETE
461        result.setNotifyNewMail(0 !=
462            (fromAccount.getFlags() & EmailContent.Account.FLAGS_NOTIFY_NEW_MAIL));
463        result.setVibrate(0 !=
464            (fromAccount.getFlags() & EmailContent.Account.FLAGS_VIBRATE_ALWAYS));
465        result.setVibrateWhenSilent(0 !=
466            (fromAccount.getFlags() & EmailContent.Account.FLAGS_VIBRATE_WHEN_SILENT));
467        result.setDeletePolicy(fromAccount.getDeletePolicy());
468
469        result.mUuid = fromAccount.getUuid();
470        result.setName(fromAccount.mSenderName);
471        result.setRingtone(fromAccount.mRingtoneUri);
472        result.mProtocolVersion = fromAccount.mProtocolVersion;
473        // int fromAccount.mNewMessageCount = will be reset on next sync
474        result.mSecurityFlags = fromAccount.mSecurityFlags;
475        result.mSignature = fromAccount.mSignature;
476
477        // Use the existing conversions from HostAuth <-> Uri
478        result.setStoreUri(fromAccount.getStoreUri(context));
479        result.setSenderUri(fromAccount.getSenderUri(context));
480
481        return result;
482    }
483
484    /**
485     * Conversion from legacy account to provider account
486     *
487     * Used for backup/restore.
488     *
489     * @param context application context
490     * @param fromAccount the legacy account to convert to modern format
491     * @return an Account ready to be committed to provider
492     */
493    public static EmailContent.Account makeAccount(Context context, Account fromAccount) {
494
495        EmailContent.Account result = new EmailContent.Account();
496
497        result.setDisplayName(fromAccount.getDescription());
498        result.setEmailAddress(fromAccount.getEmail());
499        result.mSyncKey = null;
500        result.setSyncLookback(fromAccount.getSyncWindow());
501        result.setSyncInterval(fromAccount.getAutomaticCheckIntervalMinutes());
502        // result.mHostAuthKeyRecv;     -- will be set when object is saved
503        // result.mHostAuthKeySend;     -- will be set when object is saved
504        int flags = 0;
505        if (fromAccount.isNotifyNewMail())  flags |= EmailContent.Account.FLAGS_NOTIFY_NEW_MAIL;
506        if (fromAccount.isVibrate())        flags |= EmailContent.Account.FLAGS_VIBRATE_ALWAYS;
507        if (fromAccount.isVibrateWhenSilent())
508            flags |= EmailContent.Account.FLAGS_VIBRATE_WHEN_SILENT;
509        result.setFlags(flags);
510        result.setDeletePolicy(fromAccount.getDeletePolicy());
511        // result.setDefaultAccount();  -- will be set by caller, if needed
512        result.mCompatibilityUuid = fromAccount.getUuid();
513        result.setSenderName(fromAccount.getName());
514        result.setRingtone(fromAccount.getRingtone());
515        result.mProtocolVersion = fromAccount.mProtocolVersion;
516        result.mNewMessageCount = 0;
517        result.mSecurityFlags = fromAccount.mSecurityFlags;
518        result.mSecuritySyncKey = null;
519        result.mSignature = fromAccount.mSignature;
520
521        result.setStoreUri(context, fromAccount.getStoreUri());
522        result.setSenderUri(context, fromAccount.getSenderUri());
523
524        return result;
525    }
526
527    /**
528     * Infer mailbox type from mailbox name.  Used by MessagingController (for live folder sync).
529     */
530    public static synchronized int inferMailboxTypeFromName(Context context, String mailboxName) {
531        if (sServerMailboxNames.size() == 0) {
532            // preload the hashmap, one time only
533            sServerMailboxNames.put(
534                    context.getString(R.string.mailbox_name_server_inbox).toLowerCase(),
535                    Mailbox.TYPE_INBOX);
536            sServerMailboxNames.put(
537                    context.getString(R.string.mailbox_name_server_outbox).toLowerCase(),
538                    Mailbox.TYPE_OUTBOX);
539            sServerMailboxNames.put(
540                    context.getString(R.string.mailbox_name_server_drafts).toLowerCase(),
541                    Mailbox.TYPE_DRAFTS);
542            sServerMailboxNames.put(
543                    context.getString(R.string.mailbox_name_server_trash).toLowerCase(),
544                    Mailbox.TYPE_TRASH);
545            sServerMailboxNames.put(
546                    context.getString(R.string.mailbox_name_server_sent).toLowerCase(),
547                    Mailbox.TYPE_SENT);
548            sServerMailboxNames.put(
549                    context.getString(R.string.mailbox_name_server_junk).toLowerCase(),
550                    Mailbox.TYPE_JUNK);
551        }
552        if (mailboxName == null || mailboxName.length() == 0) {
553            return EmailContent.Mailbox.TYPE_MAIL;
554        }
555        String lowerCaseName = mailboxName.toLowerCase();
556        Integer type = sServerMailboxNames.get(lowerCaseName);
557        if (type != null) {
558            return type;
559        }
560        return EmailContent.Mailbox.TYPE_MAIL;
561    }
562}
563