(
Context context, EntityAccount account, Store istore, State state,
boolean keep_alive, boolean force)
| 2565 | } |
| 2566 | |
| 2567 | static void onSynchronizeFolders( |
| 2568 | Context context, EntityAccount account, Store istore, State state, |
| 2569 | boolean keep_alive, boolean force) throws MessagingException { |
| 2570 | // Folder names: https://datatracker.ietf.org/doc/html/rfc2060#section-5.1.3 |
| 2571 | DB db = DB.getInstance(context); |
| 2572 | |
| 2573 | if (account.protocol != EntityAccount.TYPE_IMAP) |
| 2574 | return; |
| 2575 | |
| 2576 | SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); |
| 2577 | boolean sync_folders = prefs.getBoolean("sync_folders", true); |
| 2578 | boolean sync_folders_poll = prefs.getBoolean("sync_folders_poll", false); |
| 2579 | boolean sync_shared_folders = prefs.getBoolean("sync_shared_folders", false); |
| 2580 | boolean sync_added_folders = prefs.getBoolean("sync_added_folders", false); |
| 2581 | Log.i(account.name + " sync folders=" + sync_folders + |
| 2582 | " poll=" + sync_folders_poll + |
| 2583 | " shared=" + sync_shared_folders + |
| 2584 | " added=" + sync_added_folders + |
| 2585 | " keep_alive=" + keep_alive + |
| 2586 | " force=" + force); |
| 2587 | |
| 2588 | // Fix folder poll setting |
| 2589 | boolean fixed = prefs.getBoolean("fixed_poll." + account.id, false); |
| 2590 | if (!fixed && |
| 2591 | account.created != null && |
| 2592 | account.created > 1691193600 * 1000L /* 2023-08-05 00:00 */ && |
| 2593 | account.created < 1692223200 * 1000L /* 2023-05-17 00:00 */) |
| 2594 | try { |
| 2595 | int count = 0; |
| 2596 | EntityFolder inbox = db.folder().getFolderByType(account.id, EntityFolder.INBOX); |
| 2597 | List<EntityFolder> children = db.folder().getChildFolders(inbox.id); |
| 2598 | for (EntityFolder child : children) |
| 2599 | if (!child.poll && EntityFolder.USER.equals(child.type)) { |
| 2600 | count++; |
| 2601 | db.folder().setFolderPoll(child.id, true); |
| 2602 | EntityLog.log(context, "Fixed poll=" + child.name + ":" + child.type); |
| 2603 | } |
| 2604 | if (count > 0) |
| 2605 | Log.e("Fixed poll count=" + count); |
| 2606 | } catch (Throwable ex) { |
| 2607 | Log.e(ex); |
| 2608 | } finally { |
| 2609 | prefs.edit().putBoolean("fixed_poll." + account.id, true).apply(); |
| 2610 | } |
| 2611 | |
| 2612 | if (force) |
| 2613 | sync_folders = true; |
| 2614 | if (keep_alive) |
| 2615 | sync_folders = sync_folders_poll; |
| 2616 | if (!sync_folders) |
| 2617 | sync_shared_folders = false; |
| 2618 | |
| 2619 | // Get folder names |
| 2620 | boolean drafts = false; |
| 2621 | boolean user = false; |
| 2622 | Map<String, EntityFolder> local = new HashMap<>(); |
| 2623 | List<EntityFolder> folders = db.folder().getFolders(account.id, false, false); |
| 2624 | for (EntityFolder folder : folders) { |
no test coverage detected