MCPcopy Create free account
hub / github.com/M66B/FairEmail / onAttachment

Method onAttachment

app/src/main/java/eu/faircode/email/Core.java:2232–2265  ·  view source on GitHub ↗
(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, EntityOperation op, IMAPFolder ifolder)

Source from the content-addressed store, hash-verified

2230 }
2231
2232 private static void onAttachment(Context context, JSONArray jargs, EntityFolder folder, EntityMessage message, EntityOperation op, IMAPFolder ifolder) throws JSONException, MessagingException, IOException {
2233 // Download attachment
2234 DB db = DB.getInstance(context);
2235
2236 long id = jargs.getLong(0);
2237
2238 // Get attachment
2239 EntityAttachment attachment = db.attachment().getAttachment(id);
2240 if (attachment == null)
2241 attachment = db.attachment().getAttachment(message.id, (int) id); // legacy
2242 if (attachment == null)
2243 throw new IllegalArgumentException("Local attachment not found");
2244 if (attachment.subsequence != null)
2245 throw new IllegalArgumentException("Download of sub attachment");
2246 if (attachment.available)
2247 return;
2248 if (message.uid == null)
2249 throw new IllegalArgumentException("Attachment/message uid missing");
2250
2251 // Get message
2252 Message imessage = ifolder.getMessageByUID(message.uid);
2253 if (imessage == null)
2254 throw new MessageRemovedException();
2255
2256 // Get message parts
2257 MessageHelper helper = new MessageHelper((MimeMessage) imessage, context);
2258 MessageHelper.MessageParts parts = helper.getMessageParts();
2259
2260 // Download attachment
2261 parts.downloadAttachment(context, attachment, folder);
2262
2263 if (attachment.size != null)
2264 EntityLog.log(context, "Operation attachment size=" + attachment.size);
2265 }
2266
2267 private static void onDetach(Context context, JSONArray jargs, EntityAccount account, EntityFolder folder, EntityMessage message, IMAPStore istore, IMAPFolder ifolder, State state) throws JSONException, MessagingException, IOException {
2268 DB db = DB.getInstance(context);

Callers 1

processOperationsMethod · 0.95

Calls 14

getInstanceMethod · 0.95
attachmentMethod · 0.95
getMessagePartsMethod · 0.95
logMethod · 0.95
findMessagesMethod · 0.95
getLongMethod · 0.80
getAttachmentMethod · 0.80
downloadAttachmentMethod · 0.80
getMessageByUIDMethod · 0.65
getValueMethod · 0.65
equalsMethod · 0.45
getMethod · 0.45

Tested by

no test coverage detected