Files
MuditaOS/module-apps/application-settings/models/network/SimContactsRepository.hpp
Mateusz Grzegorzek 58dd02cff1 [BH-861] Cleanup Application split - part I
1. Prepare Pure and Bell specific `Application`
   classes and add them to `app` target:

- `products/BellHybrid/apps/Application.cpp`
- `products/PurePhone/apps/Application.cpp`

2. Update `CMakeLists.txt` files.
3. Move `ApplicationBell` implementation to Bell-specific
   `Application` class and remove `ApplicationBell` files.
4. Change Bell apps parent classes from `ApplicationBell`
  to Bell-specific `Application` class.
5. Rename `Application` to `ApplicationCommon` in the rest of the files.
2021-09-13 11:58:10 +02:00

50 lines
2.3 KiB
C++

// Copyright (c) 2017-2021, Mudita Sp. z.o.o. All rights reserved.
// For licensing, see https://github.com/mudita/MuditaOS/LICENSE.md
#pragma once
#include <apps-common/ApplicationCommon.hpp>
#include <module-db/Interface/ContactRecord.hpp>
#include <service-cellular/CellularMessage.hpp>
class AbstractSimContactsRepository
{
public:
using OnReadCallback = std::function<void()>;
using OnDupplicatesCheckCallback = std::function<void(bool duplicatesFound)>;
using OnSaveCallback = std::function<void()>;
virtual ~AbstractSimContactsRepository() noexcept = default;
virtual const std::vector<ContactRecord> &getImportedRecords() = 0;
virtual const std::vector<ContactRecord> &getDuplicatedRecords() = 0;
virtual void read(OnReadCallback callback) = 0;
virtual void clear() = 0;
virtual void save(const std::vector<bool> &selectedContacts, bool duplicatesFound, OnSaveCallback callback) = 0;
virtual void findDuplicates(const std::vector<bool> &selectedContacts, OnDupplicatesCheckCallback callback) = 0;
};
class SimContactsRepository : public AbstractSimContactsRepository, public app::AsyncCallbackReceiver
{
public:
explicit SimContactsRepository(app::ApplicationCommon *application);
const std::vector<ContactRecord> &getImportedRecords() override;
const std::vector<ContactRecord> &getDuplicatedRecords() override;
void read(OnReadCallback callback) override;
void clear() override;
void save(const std::vector<bool> &selectedContacts, bool duplicatesFound, OnSaveCallback callback) override;
void findDuplicates(const std::vector<bool> &selectedContacts, OnDupplicatesCheckCallback callback) override;
void updateImportedRecords(const std::vector<cellular::SimContact> &simData);
private:
std::vector<ContactRecord> importedRecords;
std::vector<ContactRecord> uniqueRecords;
std::vector<ContactRecord> duplicatedRecords;
app::ApplicationCommon *application;
#if DEBUG_SIM_IMPORT_DATA == 1
void printRecordsData(const std::string &name, const std::vector<ContactRecord> &data);
#endif
};