• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepimlibs API Reference
  • KDE Home
  • Contact Us
 

akonadi

  • sources
  • kde-4.12
  • kdepimlibs
  • akonadi
changenotificationdependenciesfactory.cpp
1 /*
2  Copyright (c) 2011 Stephen Kelly <steveire@gmail.com>
3 
4  This library is free software; you can redistribute it and/or modify it
5  under the terms of the GNU Library General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or (at your
7  option) any later version.
8 
9  This library is distributed in the hope that it will be useful, but WITHOUT
10  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Library General Public
12  License for more details.
13 
14  You should have received a copy of the GNU Library General Public License
15  along with this library; see the file COPYING.LIB. If not, write to the
16  Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
17  02110-1301, USA.
18 */
19 
20 #include "changenotificationdependenciesfactory_p.h"
21 #include "dbusconnectionpool.h"
22 #include "notificationsource_p.h"
23 #include "notificationsourceinterface.h"
24 #include "notificationmanagerinterface.h"
25 #include "changemediator_p.h"
26 #include "servermanager.h"
27 
28 #include <KComponentData>
29 #include <KGlobal>
30 #include <KRandom>
31 #include <qdbusextratypes.h>
32 
33 using namespace Akonadi;
34 
35 NotificationSource* ChangeNotificationDependenciesFactory::createNotificationSource(QObject *parent)
36 {
37  if ( !Akonadi::ServerManager::self()->isRunning() ) {
38  return 0;
39  }
40 
41  org::freedesktop::Akonadi::NotificationManager *manager =
42  new org::freedesktop::Akonadi::NotificationManager(
43  ServerManager::serviceName( Akonadi::ServerManager::Server ),
44  QLatin1String( "/notifications" ),
45  DBusConnectionPool::threadConnection() );
46 
47  if ( !manager ) {
48  // :TODO: error handling
49  return 0;
50  }
51 
52  const QString name = QString::fromLatin1( "%1_%2_%3" ).arg(
53  KGlobal::mainComponent().componentName(),
54  QString::number( QCoreApplication::applicationPid() ),
55  KRandom::randomString( 6 ) );
56  QDBusObjectPath p = manager->subscribeV2( name, true );
57  const bool validError = manager->lastError().isValid();
58  if ( validError ) {
59  kWarning() << manager->lastError().name() << manager->lastError().message();
60  // :TODO: What to do?
61  delete manager;
62  return 0;
63  }
64  delete manager;
65  org::freedesktop::Akonadi::NotificationSource *notificationSource =
66  new org::freedesktop::Akonadi::NotificationSource(
67  ServerManager::serviceName( Akonadi::ServerManager::Server ),
68  p.path(),
69  DBusConnectionPool::threadConnection(), parent );
70 
71  if ( !notificationSource ) {
72  // :TODO: error handling
73  return 0;
74  }
75  return new NotificationSource( notificationSource );
76 }
77 
78 QObject* ChangeNotificationDependenciesFactory::createChangeMediator(QObject* parent)
79 {
80  Q_UNUSED( parent );
81  return ChangeMediator::instance();
82 }
83 
84 CollectionCache* ChangeNotificationDependenciesFactory::createCollectionCache(int maxCapacity, Session *session)
85 {
86  return new CollectionCache( maxCapacity, session );
87 }
88 
89 ItemCache* ChangeNotificationDependenciesFactory::createItemCache(int maxCapacity, Session* session)
90 {
91  return new ItemCache( maxCapacity, session );
92 }
93 
94 ItemListCache* ChangeNotificationDependenciesFactory::createItemListCache(int maxCapacity, Session *session)
95 {
96  return new ItemListCache( maxCapacity, session );
97 }
Akonadi::ServerManager::self
static ServerManager * self()
Returns the singleton instance of this class, for connecting to its signals.
Definition: servermanager.cpp:152
Akonadi::ServerManager::serviceName
static QString serviceName(ServiceType serviceType)
Returns the namespaced D-Bus service name for serviceType.
Definition: servermanager.cpp:298
Akonadi::Session
A communication session with the Akonadi storage.
Definition: session.h:59
Akonadi::EntityCache
Definition: entitycache_p.h:83
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 23:00:26 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

akonadi

Skip menu "akonadi"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • Modules
  • Related Pages

kdepimlibs API Reference

Skip menu "kdepimlibs API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kldap
  • kmbox
  • kmime
  • kpimidentities
  • kpimtextedit
  • kresources
  • ktnef
  • kxmlrpcclient
  • microblog

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal