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

Method onSynchronizeMessages

app/src/main/java/eu/faircode/email/Core.java:3352–3858  ·  view source on GitHub ↗
(
            Context context, JSONArray jargs,
            EntityAccount account, final EntityFolder folder,
            POP3Folder ifolder, POP3Store istore, State state)

Source from the content-addressed store, hash-verified

3350 }
3351
3352 private static void onSynchronizeMessages(
3353 Context context, JSONArray jargs,
3354 EntityAccount account, final EntityFolder folder,
3355 POP3Folder ifolder, POP3Store istore, State state) throws MessagingException, IOException {
3356 DB db = DB.getInstance(context);
3357 SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
3358 boolean sync_quick_pop = prefs.getBoolean("sync_quick_pop", true);
3359 boolean notify_known = prefs.getBoolean("notify_known", false);
3360 boolean native_dkim = prefs.getBoolean("native_dkim", false);
3361 boolean download_eml = prefs.getBoolean("download_eml", false);
3362 boolean download_plain = prefs.getBoolean("download_plain", false);
3363 boolean check_blocklist = prefs.getBoolean("check_blocklist", false);
3364 boolean use_blocklist_pop = prefs.getBoolean("use_blocklist_pop", false);
3365 boolean pro = ActivityBilling.isPro(context);
3366
3367 boolean force = jargs.optBoolean(5, false);
3368
3369 EntityLog.log(context, account.name + " POP sync type=" + folder.type +
3370 " quick=" + sync_quick_pop + " force=" + force +
3371 " connected=" + (ifolder != null));
3372
3373 if (!EntityFolder.INBOX.equals(folder.type)) {
3374 folder.synchronize = false;
3375 db.folder().setFolderSynchronize(folder.id, folder.synchronize);
3376 db.folder().setFolderSyncState(folder.id, null);
3377 return;
3378 }
3379
3380 List<EntityRule> rules = db.rule().getEnabledRules(folder.id, false);
3381
3382 try {
3383 db.folder().setFolderSyncState(folder.id, "syncing");
3384
3385 // Get capabilities
3386 Map<String, String> caps = istore.capabilities();
3387 boolean hasUidl = caps.containsKey("UIDL");
3388 String capabilities = TextUtils.join(" ", caps.values());
3389 EntityLog.log(context, EntityLog.Type.Protocol, account, capabilities);
3390 db.account().setAccountCapabilities(account.id, capabilities, false, false);
3391
3392 if (hasUidl) {
3393 if (Boolean.FALSE.equals(account.capability_uidl)) {
3394 hasUidl = false;
3395 Log.w(account.host + " did not had UIDL before");
3396 }
3397 } else {
3398 account.capability_uidl = false;
3399 db.account().setAccountUidl(account.id, account.capability_uidl);
3400 }
3401
3402 // Get messages
3403 Message[] imessages = ifolder.getMessages();
3404
3405 List<TupleUidl> ids = db.message().getUidls(folder.id);
3406 int max = (account.max_messages == null
3407 ? imessages.length
3408 : Math.min(imessages.length, Math.abs(account.max_messages)));
3409 boolean reversed = (account.max_messages != null && account.max_messages < 0);

Callers 1

processOperationsMethod · 0.95

Calls 15

getInstanceMethod · 0.95
isProMethod · 0.95
logMethod · 0.95
folderMethod · 0.95
ruleMethod · 0.95
accountMethod · 0.95
wMethod · 0.95
messageMethod · 0.95
getPOP3MessageIDMethod · 0.95
iMethod · 0.95
addMethod · 0.95
getMessageIDMethod · 0.95

Tested by

no test coverage detected