Lines Matching refs:Attachment
42 import com.android.emailcommon.provider.EmailContent.Attachment;
68 // Try to download an attachment in the background this many times before giving up
93 "com.android.email.AttachmentDownloadService.attachment";
105 // A map of attachment storage used per account
110 // A map of attachment ids to the number of failed attempts to download the attachment
177 private DownloadRequest(Context context, Attachment attachment) {
178 attachmentId = attachment.mId;
179 Message msg = Message.restoreMessageWithId(context, attachment.mMessageKey);
186 priority = getPriority(attachment);
196 * Two download requests are equals if their attachment id's are equals
231 * priority key represents this ordering. Note: All methods that change the attachment map are
244 * Maps attachment id to DownloadRequest
251 * EmailProvider that an attachment has been inserted or modified. It's not strictly
252 * necessary that we detect a deleted attachment, as the code always checks for the
253 * existence of an attachment before acting on it.
255 public synchronized void onChange(Context context, Attachment att) {
260 Log.d(TAG, "== Attachment changed: " + att.mId);
262 // In this case, there is no download priority for this attachment
267 Log.d(TAG, "== Attachment " + att.mId + " was in queue, removing");
282 Log.d(TAG, "== Download queued for attachment " + att.mId + ", class " +
291 * Find a queued DownloadRequest, given the attachment's id
292 * @param id the id of the attachment
293 * @return the DownloadRequest for that attachment (or null, if none)
317 Log.d(TAG, "== Checking attachment queue, " + mDownloadSet.size() + " entries");
352 Uri lookupUri = EmailContent.uriWithLimit(Attachment.CONTENT_URI,
355 EmailContent.Attachment.PRECACHE_INBOX_SELECTION,
356 null, Attachment.RECORD_ID + " DESC");
364 // Clean up this orphaned attachment; there's no point in keeping it
366 EmailContent.delete(mContext, Attachment.CONTENT_URI, id);
368 // Check that the attachment meets system requirements for download
371 Attachment att = Attachment.restoreAttachmentWithId(mContext, id);
376 // move onto the next attachment
455 // Do not download the same attachment multiple times
461 Log.d(TAG, ">> Starting download for attachment #" + req.attachmentId);
477 * Do the work of starting an attachment download using the EmailService interface, and
515 * @param attachmentId the id of the attachment whose download is finished
527 // Update the attachment failure list if needed
542 Log.d(TAG, "== The download for attachment #" + attachmentId +
563 Log.d(TAG, "<< Download finished for attachment #" + attachmentId + "; " + secs +
567 Attachment attachment = Attachment.restoreAttachmentWithId(mContext, attachmentId);
568 if (attachment != null) {
569 long accountId = attachment.mAccountKey;
570 // Update our attachment storage for this account
575 mAttachmentStorageMap.put(accountId, currentStorage + attachment.mSize);
577 if ((attachment.mFlags & Attachment.FLAG_DOWNLOAD_FORWARD) != 0) {
579 // If this is a forwarding download, and the attachment doesn't exist (or
582 EmailContent.delete(mContext, Attachment.CONTENT_URI, attachment.mId);
585 nc.showDownloadForwardFailedNotification(attachment);
588 // If we're an attachment on forwarded mail, and if we're not still blocked,
591 !Utility.hasUnloadedAttachments(mContext, attachment.mMessageKey)) {
599 Message msg = Message.restoreMessageWithId(mContext, attachment.mMessageKey);
601 // If there's no associated message, delete the attachment
602 EmailContent.delete(mContext, Attachment.CONTENT_URI, attachment.mId);
616 Attachment.FLAG_DOWNLOAD_FORWARD | Attachment.FLAG_DOWNLOAD_USER_REQUEST;
617 cv.put(Attachment.FLAGS, attachment.mFlags &= ~flags);
618 attachment.update(mContext, cv);
627 * Calculate the download priority of an Attachment. A priority of zero means that the
628 * attachment is not marked for download.
629 * @param att the Attachment
630 * @return the priority key of the Attachment
632 private static int getPriority(Attachment att) {
635 if ((flags & Attachment.FLAG_DOWNLOAD_FORWARD) != 0) {
637 } else if ((flags & Attachment.FLAG_DOWNLOAD_USER_REQUEST) != 0) {
668 Log.d(TAG, ">> Attachment " + attachmentId + ": " + code);
670 Log.d(TAG, ">> Attachment " + attachmentId + ": " + progress + "%");
727 Attachment att) {
764 * Ask the service whether a particular attachment is queued for download
765 * @param attachmentId the id of the Attachment (as stored by EmailProvider)
766 * @return whether or not the attachment is queued for download
777 * Ask the service to remove an attachment from the download queue
778 * @param attachmentId the id of the Attachment (as stored by EmailProvider)
779 * @return whether or not the attachment was removed from the queue
797 * Called directly by EmailProvider whenever an attachment is inserted or changed
799 * @param id the attachment's id
800 * @param flags the new flags for the attachment
805 Attachment attachment = Attachment.restoreAttachmentWithId(context, id);
806 if (attachment != null) {
810 attachment.mFlags = flags;
812 intent.putExtra(EXTRA_ATTACHMENT, attachment);
819 * Determine whether an attachment can be prefetched for the given account
841 // Retrieve our idea of currently used attachment storage; since we don't track deletions,
846 // Calculate the exact figure for attachment storage for this account
878 int mask = Attachment.FLAG_DOWNLOAD_FORWARD | Attachment.FLAG_DOWNLOAD_USER_REQUEST;
879 Cursor c = getContentResolver().query(Attachment.CONTENT_URI,
880 EmailContent.ID_PROJECTION, "(" + Attachment.FLAGS + " & ?) != 0",
885 Attachment attachment = Attachment.restoreAttachmentWithId(
887 if (attachment != null) {
888 mDownloadSet.onChange(this, attachment);
900 // Here's where we run our attachment loading logic...
929 Attachment att = (Attachment)intent.getParcelableExtra(EXTRA_ATTACHMENT);
969 pw.println(" Account: " + req.accountId + ", Attachment: " + req.attachmentId);
972 Attachment att = Attachment.restoreAttachmentWithId(this, req.attachmentId);
974 pw.println(" Attachment not in database?");