• Skip to content
  • Skip to link menu
KDE 4.8 API Reference
  • KDE API Reference
  • KDE-PIM Libraries
  • KDE Home
  • 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 "changemediator_p.h"
00024 #include "collectionfetchscope.h"
00025 #include "itemfetchjob.h"
00026 #include "notificationmessage_p.h"
00027 #include "session.h"
00028 
00029 #include <kdebug.h>
00030 
00031 #include <QtDBus/QDBusInterface>
00032 #include <QtDBus/QDBusConnection>
00033 
00034 #include <QtCore/QDebug>
00035 #include <QtCore/QTimer>
00036 #include <iterator>
00037 
00038 using namespace Akonadi;
00039 
00040 Monitor::Monitor( QObject *parent ) :
00041     QObject( parent ),
00042     d_ptr( new MonitorPrivate( 0, 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   d_ptr->init();
00054   d_ptr->connectToNotificationManager();
00055 
00056   ChangeMediator::registerMonitor(this);
00057 }
00058 //@endcond
00059 
00060 Monitor::~Monitor()
00061 {
00062   ChangeMediator::unregisterMonitor(this);
00063 
00064   // :TODO: Unsubscribe from the notification manager. That means having some kind of reference
00065   // counting on the server side.
00066   delete d_ptr;
00067 }
00068 
00069 void Monitor::setCollectionMonitored( const Collection &collection, bool monitored )
00070 {
00071   Q_D( Monitor );
00072   if ( monitored ) {
00073     d->collections << collection;
00074   } else {
00075     d->collections.removeAll( collection );
00076     d->cleanOldNotifications();
00077   }
00078   emit collectionMonitored( collection, monitored );
00079 }
00080 
00081 void Monitor::setItemMonitored( const Item & item, bool monitored )
00082 {
00083   Q_D( Monitor );
00084   if ( monitored ) {
00085     d->items.insert( item.id() );
00086   } else {
00087     d->items.remove( item.id() );
00088     d->cleanOldNotifications();
00089   }
00090   emit itemMonitored( item,  monitored );
00091 }
00092 
00093 void Monitor::setResourceMonitored( const QByteArray & resource, bool monitored )
00094 {
00095   Q_D( Monitor );
00096   if ( monitored ) {
00097     d->resources.insert( resource );
00098   } else {
00099     d->resources.remove( resource );
00100     d->cleanOldNotifications();
00101   }
00102   emit resourceMonitored( resource, monitored );
00103 }
00104 
00105 void Monitor::setMimeTypeMonitored( const QString & mimetype, bool monitored )
00106 {
00107   Q_D( Monitor );
00108   if ( monitored ) {
00109     d->mimetypes.insert( mimetype );
00110   } else {
00111     d->mimetypes.remove( mimetype );
00112     d->cleanOldNotifications();
00113   }
00114 
00115   emit mimeTypeMonitored( mimetype, monitored );
00116 }
00117 
00118 void Akonadi::Monitor::setAllMonitored( bool monitored )
00119 {
00120   Q_D( Monitor );
00121   d->monitorAll = monitored;
00122 
00123   if ( !monitored ) {
00124     d->cleanOldNotifications();
00125   }
00126 
00127   emit allMonitored( monitored );
00128 }
00129 
00130 void Monitor::ignoreSession(Session * session)
00131 {
00132   Q_D( Monitor );
00133   d->sessions << session->sessionId();
00134   connect( session, SIGNAL(destroyed(QObject*)), this, SLOT(slotSessionDestroyed(QObject*)) );
00135 }
00136 
00137 void Monitor::fetchCollection(bool enable)
00138 {
00139   Q_D( Monitor );
00140   d->fetchCollection = enable;
00141 }
00142 
00143 void Monitor::fetchCollectionStatistics(bool enable)
00144 {
00145   Q_D( Monitor );
00146   d->fetchCollectionStatistics = enable;
00147 }
00148 
00149 void Monitor::setItemFetchScope( const ItemFetchScope &fetchScope )
00150 {
00151   Q_D( Monitor );
00152   d->mItemFetchScope = fetchScope;
00153 }
00154 
00155 ItemFetchScope &Monitor::itemFetchScope()
00156 {
00157   Q_D( Monitor );
00158   return d->mItemFetchScope;
00159 }
00160 
00161 void Monitor::fetchChangedOnly( bool enable )
00162 {
00163   Q_D( Monitor );
00164   d->mFetchChangedOnly = enable;
00165 }
00166 
00167 
00168 void Monitor::setCollectionFetchScope( const CollectionFetchScope &fetchScope )
00169 {
00170   Q_D( Monitor );
00171   d->mCollectionFetchScope = fetchScope;
00172 }
00173 
00174 CollectionFetchScope& Monitor::collectionFetchScope()
00175 {
00176   Q_D( Monitor );
00177   return d->mCollectionFetchScope;
00178 }
00179 
00180 Akonadi::Collection::List Monitor::collectionsMonitored() const
00181 {
00182   Q_D( const Monitor );
00183   return d->collections;
00184 }
00185 
00186 QList<Item::Id> Monitor::itemsMonitored() const
00187 {
00188   Q_D( const Monitor );
00189   if ( !d->items.isEmpty() ) {
00190     return d->items.toList();
00191   } else {
00192     return QList<Item::Id>();
00193   }
00194 }
00195 
00196 QVector<Item::Id> Monitor::itemsMonitoredEx() const
00197 {
00198   Q_D( const Monitor );
00199   QVector<Item::Id> result;
00200   result.reserve( d->items.size() );
00201   qCopy( d->items.begin(), d->items.end(), std::back_inserter( result ) );
00202   return result;
00203 }
00204 
00205 QStringList Monitor::mimeTypesMonitored() const
00206 {
00207   Q_D( const Monitor );
00208   if ( !d->mimetypes.isEmpty() ) {
00209     return d->mimetypes.toList();
00210   } else {
00211     return QStringList();
00212   }
00213 }
00214 
00215 QList<QByteArray> Monitor::resourcesMonitored() const
00216 {
00217   Q_D( const Monitor );
00218   return d->resources.toList();
00219 }
00220 
00221 bool Monitor::isAllMonitored() const
00222 {
00223   Q_D( const Monitor );
00224   return d->monitorAll;
00225 }
00226 
00227 void Monitor::setSession( Akonadi::Session *session )
00228 {
00229   Q_D( Monitor );
00230   if (session == d->session)
00231     return;
00232 
00233   if (!session)
00234     d->session = Session::defaultSession();
00235   else
00236     d->session = session;
00237 
00238   d->itemCache->setSession(d->session);
00239   d->collectionCache->setSession(d->session);
00240 }
00241 
00242 Session* Monitor::session() const
00243 {
00244   Q_D( const Monitor );
00245   return d->session;
00246 }
00247 
00248 #include "monitor.moc"

akonadi

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

KDE-PIM Libraries

Skip menu "KDE-PIM Libraries"
  • akonadi
  •   contact
  •   kmime
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • 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.6.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