changenotificationdependenciesfactory.cpp
00001 /* 00002 Copyright (c) 2011 Stephen Kelly <steveire@gmail.com> 00003 00004 This library is free software; you can redistribute it and/or modify it 00005 under the terms of the GNU Library General Public License as published by 00006 the Free Software Foundation; either version 2 of the License, or (at your 00007 option) any later version. 00008 00009 This library is distributed in the hope that it will be useful, but WITHOUT 00010 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 00011 FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public 00012 License for more details. 00013 00014 You should have received a copy of the GNU Library General Public License 00015 along with this library; see the file COPYING.LIB. If not, write to the 00016 Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00017 02110-1301, USA. 00018 */ 00019 00020 #include "changenotificationdependenciesfactory_p.h" 00021 #include "dbusconnectionpool.h" 00022 #include "notificationsourceinterface.h" 00023 #include "notificationmanagerinterface.h" 00024 #include "changemediator_p.h" 00025 00026 #include <KComponentData> 00027 #include <KGlobal> 00028 #include <qdbusextratypes.h> 00029 00030 using namespace Akonadi; 00031 00032 QObject* ChangeNotificationDependenciesFactory::createNotificationSource(QObject *parent) 00033 { 00034 org::freedesktop::Akonadi::NotificationManager manager( 00035 QLatin1String( "org.freedesktop.Akonadi" ), 00036 QLatin1String( "/notifications" ), 00037 DBusConnectionPool::threadConnection() ); 00038 00039 QDBusObjectPath p = manager.subscribe( KGlobal::mainComponent().componentName() ); 00040 if ( manager.lastError().isValid() ) { 00041 // :TODO: What to do? 00042 return 0; 00043 } 00044 00045 org::freedesktop::Akonadi::NotificationSource *notificationSource = new org::freedesktop::Akonadi::NotificationSource( 00046 QLatin1String( "org.freedesktop.Akonadi" ), 00047 p.path(), 00048 DBusConnectionPool::threadConnection(), parent ); 00049 00050 if ( !notificationSource ) { 00051 // :TODO: error handling 00052 return 0; 00053 } 00054 return notificationSource; 00055 } 00056 00057 QObject* ChangeNotificationDependenciesFactory::createChangeMediator(QObject* parent) 00058 { 00059 Q_UNUSED( parent ); 00060 return ChangeMediator::instance(); 00061 } 00062 00063 CollectionCache* ChangeNotificationDependenciesFactory::createCollectionCache(int maxCapacity, Session *session) 00064 { 00065 return new CollectionCache(maxCapacity, session); 00066 } 00067 00068 ItemCache* ChangeNotificationDependenciesFactory::createItemCache(int maxCapacity, Session* session) 00069 { 00070 return new ItemCache(maxCapacity, session); 00071 }