(
Context context,
EntityAccount account, EntityFolder folder,
IMAPStore istore, IMAPFolder ifolder,
MimeMessage imessage, long id, State state, SyncStats stats)
| 5587 | } |
| 5588 | |
| 5589 | private static boolean downloadMessage( |
| 5590 | Context context, |
| 5591 | EntityAccount account, EntityFolder folder, |
| 5592 | IMAPStore istore, IMAPFolder ifolder, |
| 5593 | MimeMessage imessage, long id, State state, SyncStats stats) throws MessagingException, IOException { |
| 5594 | if (state.getNetworkState().isRoaming()) |
| 5595 | return false; |
| 5596 | |
| 5597 | if (imessage == null) |
| 5598 | return false; |
| 5599 | |
| 5600 | DB db = DB.getInstance(context); |
| 5601 | EntityMessage message = db.message().getMessage(id); |
| 5602 | if (message == null || message.ui_hide) |
| 5603 | return false; |
| 5604 | |
| 5605 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 5606 | long maxSize = prefs.getInt("download", MessageHelper.DEFAULT_DOWNLOAD_SIZE); |
| 5607 | if (maxSize == 0) |
| 5608 | maxSize = Long.MAX_VALUE; |
| 5609 | boolean download_limited = prefs.getBoolean("download_limited", false); |
| 5610 | boolean download_eml = prefs.getBoolean("download_eml", false); |
| 5611 | |
| 5612 | List<EntityAttachment> attachments = db.attachment().getAttachments(message.id); |
| 5613 | |
| 5614 | boolean fetch = false; |
| 5615 | if (!message.content) |
| 5616 | if ((!download_limited && state.getNetworkState().isUnmetered()) || |
| 5617 | (message.size != null && message.size < maxSize)) |
| 5618 | fetch = true; |
| 5619 | |
| 5620 | if (!fetch) |
| 5621 | for (EntityAttachment attachment : attachments) |
| 5622 | if (!attachment.available) |
| 5623 | if ((!download_limited && state.getNetworkState().isUnmetered()) || |
| 5624 | (attachment.size != null && attachment.size < maxSize)) { |
| 5625 | fetch = true; |
| 5626 | break; |
| 5627 | } |
| 5628 | |
| 5629 | if (fetch) { |
| 5630 | Log.i(folder.name + " fetching message id=" + message.id); |
| 5631 | |
| 5632 | // Fetch on demand to prevent OOM |
| 5633 | |
| 5634 | //FetchProfile fp = new FetchProfile(); |
| 5635 | //fp.add(FetchProfile.Item.ENVELOPE); |
| 5636 | //fp.add(FetchProfile.Item.FLAGS); |
| 5637 | //fp.add(FetchProfile.Item.CONTENT_INFO); // body structure |
| 5638 | //fp.add(UIDFolder.FetchProfileItem.UID); |
| 5639 | //fp.add(IMAPFolder.FetchProfileItem.HEADERS); |
| 5640 | //fp.add(IMAPFolder.FetchProfileItem.MESSAGE); |
| 5641 | //fp.add(FetchProfile.Item.SIZE); |
| 5642 | //fp.add(IMAPFolder.FetchProfileItem.INTERNALDATE); |
| 5643 | //if (account.isGmail()) { |
| 5644 | // fp.add(GmailFolder.FetchProfileItem.THRID); |
| 5645 | // fp.add(GmailFolder.FetchProfileItem.LABELS); |
| 5646 | //} |
no test coverage detected