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

Method onSync

app/src/main/java/eu/faircode/email/ServiceSend.java:601–642  ·  view source on GitHub ↗
(EntityFolder outbox)

Source from the content-addressed store, hash-verified

599 }
600
601 private void onSync(EntityFolder outbox) {
602 NotificationManager nm = Helper.getSystemService(this, NotificationManager.class);
603
604 DB db = DB.getInstance(this);
605 try {
606 db.beginTransaction();
607
608 db.folder().setFolderError(outbox.id, null);
609
610 // Requeue non executing operations
611 for (long id : db.message().getMessageByFolder(outbox.id)) {
612 EntityMessage message = db.message().getMessage(id);
613 if (message == null || message.warning != null)
614 continue;
615
616 EntityOperation op = db.operation().getOperation(message.id, EntityOperation.SEND);
617 if (op != null) {
618 if ("executing".equals(op.state))
619 continue;
620 db.operation().deleteOperation(op.id);
621 }
622
623 EntityLog.log(this, "Send restore id=" + message.id + " error=" + message.error);
624
625 db.message().setMessageError(message.id, null);
626 nm.cancel("send:" + message.id, NotificationHelper.NOTIFICATION_TAGGED);
627
628 if (message.ui_snoozed == null)
629 EntityOperation.queue(this, message, EntityOperation.SEND);
630 else
631 EntityMessage.snooze(this, message.id, message.ui_snoozed);
632 }
633
634 db.setTransactionSuccessful();
635 } catch (IllegalArgumentException ex) {
636 Log.w(ex);
637 } finally {
638 db.endTransaction();
639 }
640
641 ServiceSend.start(this);
642 }
643
644 private void onSend(EntityMessage message) throws JSONException, MessagingException, IOException {
645 DB db = DB.getInstance(this);

Callers 1

processOperationsMethod · 0.95

Calls 15

getSystemServiceMethod · 0.95
getInstanceMethod · 0.95
beginTransactionMethod · 0.95
folderMethod · 0.95
messageMethod · 0.95
operationMethod · 0.95
logMethod · 0.95
queueMethod · 0.95
snoozeMethod · 0.95
wMethod · 0.95
endTransactionMethod · 0.95

Tested by

no test coverage detected