File indexing completed on 2024-11-10 04:40:37

0001 /*
0002     SPDX-FileCopyrightText: 2011 Stephen Kelly <steveire@gmail.com>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-or-later
0005 */
0006 
0007 #include "changemediator_p.h"
0008 #include "changenotificationdependenciesfactory_p.h"
0009 #include "connection_p.h"
0010 #include "servermanager.h"
0011 #include "session_p.h"
0012 #include "sessionthread_p.h"
0013 
0014 #include <qdbusextratypes.h>
0015 
0016 using namespace Akonadi;
0017 
0018 Connection *ChangeNotificationDependenciesFactory::createNotificationConnection(Session *session, CommandBuffer *commandBuffer)
0019 {
0020     if (!Akonadi::ServerManager::self()->isRunning()) {
0021         return nullptr;
0022     }
0023 
0024     auto connection = new Connection(Connection::NotificationConnection, session->sessionId(), commandBuffer);
0025     addConnection(session, connection);
0026     return connection;
0027 }
0028 
0029 void ChangeNotificationDependenciesFactory::addConnection(Session *session, Connection *connection)
0030 {
0031     session->d->sessionThread()->addConnection(connection);
0032 }
0033 
0034 void ChangeNotificationDependenciesFactory::destroyNotificationConnection(Session *session, Connection *connection)
0035 {
0036     session->d->sessionThread()->destroyConnection(connection);
0037 }
0038 
0039 QObject *ChangeNotificationDependenciesFactory::createChangeMediator(QObject *parent)
0040 {
0041     Q_UNUSED(parent)
0042     return ChangeMediator::instance();
0043 }
0044 
0045 CollectionCache *ChangeNotificationDependenciesFactory::createCollectionCache(int maxCapacity, Session *session)
0046 {
0047     return new CollectionCache(maxCapacity, session);
0048 }
0049 
0050 ItemCache *ChangeNotificationDependenciesFactory::createItemCache(int maxCapacity, Session *session)
0051 {
0052     return new ItemCache(maxCapacity, session);
0053 }
0054 
0055 ItemListCache *ChangeNotificationDependenciesFactory::createItemListCache(int maxCapacity, Session *session)
0056 {
0057     return new ItemListCache(maxCapacity, session);
0058 }
0059 
0060 TagListCache *ChangeNotificationDependenciesFactory::createTagListCache(int maxCapacity, Session *session)
0061 {
0062     return new TagListCache(maxCapacity, session);
0063 }