• Skip to content
  • Skip to link menu
KDE 4.5 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • Sitemap
  • Contact Us
 

akonadi

monitor.cpp

00001 /*
00002     Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
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 "monitor.h"
00021 #include "monitor_p.h"
00022 
00023 #include "itemfetchjob.h"
00024 #include "notificationmessage_p.h"
00025 #include "session.h"
00026 
00027 #include <kdebug.h>
00028 
00029 #include <QtDBus/QDBusInterface>
00030 #include <QtDBus/QDBusConnection>
00031 
00032 #include <QtCore/QDebug>
00033 #include <QtCore/QTimer>
00034 #include "collectionfetchscope.h"
00035 
00036 using namespace Akonadi;
00037 
00038 #define d d_ptr
00039 
00040 Monitor::Monitor( QObject *parent ) :
00041     QObject( parent ),
00042     d_ptr( new MonitorPrivate( this ) )
00043 {
00044   d_ptr->init();
00045   d_ptr->connectToNotificationManager();
00046 }
00047 
00048 //@cond PRIVATE
00049 Monitor::Monitor(MonitorPrivate * d, QObject *parent) :
00050     QObject( parent ),
00051     d_ptr( d )
00052 {
00053 }
00054 //@endcond
00055 
00056 Monitor::~Monitor()
00057 {
00058   delete d;
00059 }
00060 
00061 void Monitor::setCollectionMonitored( const Collection &collection, bool monitored )
00062 {
00063   if ( monitored ) {
00064     d->collections << collection;
00065   } else {
00066     d->collections.removeAll( collection );
00067     d->cleanOldNotifications();
00068   }
00069   emit collectionMonitored( collection, monitored );
00070 }
00071 
00072 void Monitor::setItemMonitored( const Item & item, bool monitored )
00073 {
00074   if ( monitored ) {
00075     d->items.insert( item.id() );
00076   } else {
00077     d->items.remove( item.id() );
00078     d->cleanOldNotifications();
00079   }
00080   emit itemMonitored( item,  monitored );
00081 }
00082 
00083 void Monitor::setResourceMonitored( const QByteArray & resource, bool monitored )
00084 {
00085   if ( monitored ) {
00086     d->resources.insert( resource );
00087   } else {
00088     d->resources.remove( resource );
00089     d->cleanOldNotifications();
00090   }
00091   emit resourceMonitored( resource, monitored );
00092 }
00093 
00094 void Monitor::setMimeTypeMonitored( const QString & mimetype, bool monitored )
00095 {
00096   if ( monitored ) {
00097     d->mimetypes.insert( mimetype );
00098   } else {
00099     d->mimetypes.remove( mimetype );
00100     d->cleanOldNotifications();
00101   }
00102 
00103   emit mimeTypeMonitored( mimetype, monitored );
00104 }
00105 
00106 void Akonadi::Monitor::setAllMonitored( bool monitored )
00107 {
00108   d->monitorAll = monitored;
00109 
00110   if ( !monitored ) {
00111     d->cleanOldNotifications();
00112   }
00113 
00114   emit allMonitored( monitored );
00115 }
00116 
00117 void Monitor::ignoreSession(Session * session)
00118 {
00119   d->sessions << session->sessionId();
00120   connect( session, SIGNAL( destroyed( QObject* ) ), this, SLOT( slotSessionDestroyed( QObject* ) ) );
00121 }
00122 
00123 void Monitor::fetchCollection(bool enable)
00124 {
00125   d->fetchCollection = enable;
00126 }
00127 
00128 void Monitor::fetchCollectionStatistics(bool enable)
00129 {
00130   d->fetchCollectionStatistics = enable;
00131 }
00132 
00133 void Monitor::setItemFetchScope( const ItemFetchScope &fetchScope )
00134 {
00135   d->mItemFetchScope = fetchScope;
00136 }
00137 
00138 ItemFetchScope &Monitor::itemFetchScope()
00139 {
00140   return d->mItemFetchScope;
00141 }
00142 
00143 void Monitor::setCollectionFetchScope( const CollectionFetchScope &fetchScope )
00144 {
00145   d->mCollectionFetchScope = fetchScope;
00146 }
00147 
00148 CollectionFetchScope& Monitor::collectionFetchScope()
00149 {
00150   return d->mCollectionFetchScope;
00151 }
00152 
00153 Collection::List Monitor::collectionsMonitored() const
00154 {
00155   return d->collections;
00156 }
00157 
00158 QList<Item::Id> Monitor::itemsMonitored() const
00159 {
00160   return d->items.toList();
00161 }
00162 
00163 QStringList Monitor::mimeTypesMonitored() const
00164 {
00165   return d->mimetypes.toList();
00166 }
00167 
00168 QList<QByteArray> Monitor::resourcesMonitored() const
00169 {
00170   return d->resources.toList();
00171 }
00172 
00173 bool Monitor::isAllMonitored() const
00174 {
00175   return d->monitorAll;
00176 }
00177 
00178 void Monitor::setSession( Akonadi::Session *session )
00179 {
00180   if (session == d->session)
00181     return;
00182 
00183   if (!session)
00184     d->session = Session::defaultSession();
00185   else
00186     d->session = session;
00187 
00188   d->itemCache.setSession(d->session);
00189   d->collectionCache.setSession(d->session);
00190 }
00191 
00192 Session* Monitor::session() const
00193 {
00194   return d->session;
00195 }
00196 
00197 #undef d
00198 
00199 #include "monitor.moc"

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kblog
  • kcal
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  •   richtextbuilders
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
Generated for KDE-PIM Libraries by doxygen 1.7.1
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal