app/core/CalendarPushSource.cpp
| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | #include "CalendarPushSource.h" | ||
| 2 | |||
| 3 | #include "CalendarSyncCoordinator.h" | ||
| 4 | #include "DavSyncScheduler.h" | ||
| 5 | #include "data/CalendarStore.h" | ||
| 6 | |||
| 7 | 851 | CalendarPushSource::CalendarPushSource(CalendarSyncCoordinator *calendar, QObject *parent) | |
| 8 | 851 | : DavPushSource(parent), m_calendar(calendar) { | |
| 9 | 851 | connect(calendar, &CalendarSyncCoordinator::collectionsDiscovered, this, | |
| 10 |
1/1✓ Branch 3 → 4 taken 851 times.
|
851 | [this](const QString &accountId, const QList<CalendarInfo> &calendars) { |
| 11 | 34 | QList<DavPushDiscovery> found; | |
| 12 |
2/2✓ Branch 11 → 4 taken 102 times.
✓ Branch 11 → 12 taken 34 times.
|
136 | for (const auto &calendar : calendars) found.append({calendar.path, calendar.push}); |
| 13 |
1/1✓ Branch 12 → 13 taken 34 times.
|
34 | emit discovered(accountId, found); |
| 14 |
1/3✓ Branch 7 → 8 taken 102 times.
✗ Branch 17 → 18 not taken.
✗ Branch 17 → 19 not taken.
|
136 | }); |
| 15 |
1/1✓ Branch 5 → 6 taken 851 times.
|
851 | connect(calendar, &CalendarSyncCoordinator::accountSyncFinished, this, [this](const CalendarSyncResult &result) { |
| 16 | 67 | DavPushSyncReport report; | |
| 17 | 67 | report.accountId = result.accountId; | |
| 18 |
1/1✓ Branch 5 → 6 taken 67 times.
|
67 | report.syncedPaths = QStringList(result.syncedPaths.cbegin(), result.syncedPaths.cend()); |
| 19 |
1/1✓ Branch 10 → 11 taken 67 times.
|
67 | report.failedPaths = QStringList(result.failedPaths.cbegin(), result.failedPaths.cend()); |
| 20 | 67 | report.reasons = result.reasons; | |
| 21 |
1/1✓ Branch 13 → 14 taken 67 times.
|
67 | emit syncFinished(report); |
| 22 | 67 | }); | |
| 23 |
1/1✓ Branch 8 → 9 taken 851 times.
|
851 | connect(calendar->scheduler(), &DavSyncScheduler::batchStarted, this, [this](const CalendarSyncRequest &request) { |
| 24 | 84 | emit batchStarted(request.accountId, request.forcedPaths); | |
| 25 | 84 | }); | |
| 26 | 851 | } | |
| 27 | |||
| 28 | 727 | QList<DavPushSourceCollection> CalendarPushSource::collections(const QString &accountId) const { | |
| 29 | 727 | QList<DavPushSourceCollection> result; | |
| 30 |
1/1✓ Branch 2 → 3 taken 727 times.
|
727 | const auto config = CalendarSyncCoordinator::syncConfiguration(accountId); |
| 31 |
2/2✓ Branch 4 → 5 taken 2 times.
✓ Branch 4 → 6 taken 725 times.
|
727 | if (!config) return result; |
| 32 | 725 | QHash<QString, CalendarInfo> known; | |
| 33 |
5/5✓ Branch 7 → 8 taken 725 times.
✓ Branch 8 → 9 taken 725 times.
✓ Branch 9 → 10 taken 725 times.
✓ Branch 17 → 11 taken 1233 times.
✓ Branch 17 → 18 taken 725 times.
|
1958 | for (const auto &calendar : m_calendar->store()->allCalendars()) |
| 34 |
3/3✓ Branch 13 → 14 taken 1061 times.
✓ Branch 13 → 15 taken 172 times.
✓ Branch 14 → 15 taken 1061 times.
|
1958 | if (calendar.accountId == accountId) known.insert(calendar.path, calendar); |
| 35 |
2/2✓ Branch 41 → 22 taken 1097 times.
✓ Branch 41 → 42 taken 725 times.
|
1822 | for (const QString &path : config->selectedCalendars) { |
| 36 | 1097 | const CalendarInfo calendar = known.value(path); | |
| 37 | 1097 | result.append({path, calendar.displayName.isEmpty() ? path : calendar.displayName, | |
| 38 |
1/2✗ Branch 33 → 34 not taken.
✓ Branch 33 → 35 taken 1097 times.
|
1097 | calendar.readOnly || config->readOnlyCalendars.contains(path)}); |
| 39 | 1097 | } | |
| 40 | 725 | return result; | |
| 41 | 2921 | } | |
| 42 | |||
| 43 | 448 | int CalendarPushSource::intervalMinutes() const { | |
| 44 | 448 | return CalendarSyncCoordinator::configuredIntervalMinutes(); | |
| 45 | } | ||
| 46 | |||
| 47 | 60 | void CalendarPushSource::requestSync(const QString &accountId, const QStringList &paths, unsigned reasons) { | |
| 48 |
2/2✓ Branch 3 → 4 taken 3 times.
✓ Branch 3 → 5 taken 57 times.
|
60 | if (paths.isEmpty()) m_calendar->requestAccount(accountId, reasons); |
| 49 | 57 | else m_calendar->requestCollections(accountId, paths, reasons); | |
| 50 | 60 | } | |
| 51 | |||
| 52 | 1 | void CalendarPushSource::requestAll(unsigned reasons) { | |
| 53 | 1 | m_calendar->scheduler()->requestAll(reasons); | |
| 54 | 1 | } | |
| 55 | |||
| 56 | 2 | QString CalendarPushSource::storedToken(const QString &accountId, const QString &path) const { | |
| 57 | 2 | return m_calendar->store()->calendarSyncToken(accountId, path); | |
| 58 | } | ||
| 59 | |||
| 60 | 851 | void CalendarPushSource::setPushDontNotifyProvider(std::function<QString(const QString &, const QString &)> provider) { | |
| 61 | 851 | m_calendar->setPushDontNotifyProvider(std::move(provider)); | |
| 62 | 851 | } | |
| 63 | |||
| 64 | 10 | void CalendarPushSource::setFallback(const QString &accountId, bool failing) { | |
| 65 |
2/2✓ Branch 2 → 3 taken 8 times.
✓ Branch 2 → 5 taken 2 times.
|
10 | if (failing) m_calendar->scheduler()->enterFallback(accountId); |
| 66 | 2 | else m_calendar->scheduler()->leaveFallback(accountId); | |
| 67 | 10 | } | |
| 68 | |||
| 69 | 456 | bool CalendarPushSource::inFallback(const QString &accountId) const { | |
| 70 | 456 | return m_calendar->scheduler()->inFallback(accountId); | |
| 71 | } | ||
| 72 | |||
| 73 | 448 | bool CalendarPushSource::syncRunning(const QString &accountId) const { | |
| 74 | 448 | return m_calendar->accountRunning(accountId); | |
| 75 | } | ||
| 76 |