Changeset 335:207e58b25f82 in SMSSender


Ignore:
Timestamp:
Mar 13, 2014 9:53:47 PM (6 years ago)
Author:
Sämy Zehnder <saemy.zehnder@…>
Branch:
separation-frontend-backend
Message:
  • Adds persistence gateway manager.
  • Fixes bug where gateways were not loaded from and stored to storage.
Location:
frontend
Files:
2 added
7 edited

Legend:

Unmodified
Added
Removed
  • frontend/business/gatewaymanager.cpp

    r316 r335  
    1818#include "gatewaymanager.h"
    1919
     20#include "common/persistence/istoragehelper.h"
     21
     22GatewayManager::GatewayManager(Persistence::GatewayManager *persGatewayManager)
     23    : m_persGatewayManager(persGatewayManager)
     24{
     25}
     26
     27void GatewayManager::saveGateways() const {
     28    foreach (IGateway *gateway, m_gatewayList) {
     29        m_persGatewayManager->saveGateway(gateway);
     30    }
     31}
     32
    2033void GatewayManager::registerGateway(IGateway *gateway) {
    2134    Q_ASSERT(!m_gatewayList.contains(gateway->name()));
    2235    m_gatewayList.insert(gateway->name(), gateway);
     36
     37    m_persGatewayManager->loadGateway(gateway);
    2338}
    2439
     
    3045    return m_gatewayList.values().toSet();
    3146}
     47
  • frontend/business/gatewaymanager.h

    r319 r335  
    2424
    2525#include "common/business/igateway.h"
     26#include "common/persistence/imainstorage.h"
     27#include "frontend/persistence/gatewaymanager.h"
    2628
    2729class GatewayManager {
    2830public:
    29     GatewayManager() {}
     31    // Takes ownership of the gatewayManager.
     32    explicit GatewayManager(Persistence::GatewayManager *persGatewayManager);
     33    virtual ~GatewayManager() {}
    3034
    3135    IGateway *gateway(const QString& gatewayName) const;
    3236    QSet<IGateway*> gateways() const;
    3337
     38    // Registers the gateway and loads it from storage.
    3439    void registerGateway(IGateway *gateway);
    3540
     41    void saveGateways() const;
     42
    3643private:
     44    QScopedPointer<Persistence::GatewayManager> m_persGatewayManager;
     45
    3746    QMap<QString, IGateway*> m_gatewayList;
    3847
  • frontend/business/libraryloader_base.cpp

    r320 r335  
    3737
    3838BaseLibraryLoader::~BaseLibraryLoader() {
     39    m_gatewayManager->saveGateways();
    3940    qDeleteAll(m_libraries);
    4041}
  • frontend/frontend-base.pro

    r328 r335  
    5959    persistence/contactmanager.h \
    6060    persistence/database.h \
     61    persistence/gatewaymanager.h \
    6162    persistence/groupmanager.h \
    6263    persistence/mainstorage_base.h \
    6364    persistence/persistenceintegrationhelper.h \
    64     persistence/restrictedmainstorage.h
     65    persistence/restrictedmainstorage.h \
     66
    6567SOURCES += \
    6668    business/accountinitmanager.cpp \
     
    8789    persistence/pers_contactmanager_storage.cpp \
    8890    persistence/pers_database.cpp \
     91    persistence/pers_gatewaymanager.cpp \
    8992    persistence/pers_groupmanager.cpp \
    9093    persistence/pers_groupmanager_storage.cpp \
    9194    persistence/persistenceintegrationhelper.cpp \
    92     persistence/restrictedmainstorage.cpp
     95    persistence/restrictedmainstorage.cpp \
     96
    9397RESOURCES += \
    9498    lib/frontend.qrc
  • frontend/gui/business/managerfactory.cpp

    r320 r335  
    3838ManagerFactory::ManagerFactory(const Persistence::PersistenceFactory &persistenceFactory)
    3939    : m_accountInitManager(new AccountInitManager)
    40     , m_gatewayManager(new GatewayManager)
     40    , m_gatewayManager(new GatewayManager(persistenceFactory.createGatewayManager()))
    4141    , m_accountManager(new AccountManager(m_accountInitManager.data(), persistenceFactory.createAccountManager(*m_gatewayManager)))
    4242    , m_contactManager(new ContactManager(persistenceFactory.createContactManager()))
  • frontend/gui/persistence/persistencefactory.cpp

    r316 r335  
    2626#include "frontend/persistence/accountmanager.h"
    2727#include "frontend/persistence/contactmanager.h"
     28#include "frontend/persistence/gatewaymanager.h"
    2829#include "frontend/persistence/groupmanager.h"
    2930#include "frontend/gui/persistence/mainstorage.h"
     
    4748ContactManager *PersistenceFactory::createContactManager() const {
    4849    return new ContactManager(m_mainDatabase.data(), mainStorage());
     50}
     51
     52GatewayManager *PersistenceFactory::createGatewayManager() const {
     53    return new GatewayManager(m_mainStorage.data());
    4954}
    5055
  • frontend/gui/persistence/persistencefactory.h

    r319 r335  
    3030class AccountManager;
    3131class ContactManager;
     32class GatewayManager;
    3233class GroupManager;
    3334class IDatabase;
     
    4243    AccountManager *createAccountManager(const ::GatewayManager &gatewayManager) const;
    4344    ContactManager *createContactManager() const;
     45    GatewayManager *createGatewayManager() const;
    4446    GroupManager *createGroupManager(const ::ContactManager &contactManager) const;
    4547
Note: See TracChangeset for help on using the changeset viewer.