File indexing completed on 2024-05-12 04:45:56
0001 #include "syncer.h" 0002 #include "abstractnotesprovider.h" 0003 #include "db/db.h" 0004 0005 #include <MauiKit3/Accounts/mauiaccounts.h> 0006 0007 Syncer::Syncer(QObject *parent) 0008 : QObject(parent) 0009 , m_provider(nullptr) // online service handler 0010 { 0011 connect(MauiAccounts::instance(), &MauiAccounts::currentAccountChanged, [&](QVariantMap currentAccount) { 0012 0013 qDebug() << "Current account changed" << currentAccount; 0014 this->setAccount(FMH::toModel(currentAccount)); 0015 }); 0016 } 0017 0018 void Syncer::setAccount(const FMH::MODEL &account) 0019 { 0020 if (this->m_provider) 0021 this->m_provider->setCredentials(account); 0022 } 0023 0024 void Syncer::setProvider(AbstractNotesProvider *provider) 0025 { 0026 this->m_provider = std::move(provider); 0027 this->m_provider->setParent(this); 0028 this->m_provider->disconnect(); 0029 this->setConections(); 0030 }