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

akonadi

  • akonadi
monitor.cpp
1 /*
2  Copyright (c) 2006 - 2007 Volker Krause <vkrause@kde.org>
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 "monitor.h"
21 #include "monitor_p.h"
22 
23 #include "changemediator_p.h"
24 #include "collectionfetchscope.h"
25 #include "itemfetchjob.h"
26 #include "notificationmessage_p.h"
27 #include "session.h"
28 
29 #include <kdebug.h>
30 
31 #include <QtDBus/QDBusInterface>
32 #include <QtDBus/QDBusConnection>
33 
34 #include <QtCore/QDebug>
35 #include <QtCore/QTimer>
36 #include <iterator>
37 
38 using namespace Akonadi;
39 
40 Monitor::Monitor( QObject *parent ) :
41  QObject( parent ),
42  d_ptr( new MonitorPrivate( 0, this ) )
43 {
44  d_ptr->init();
45  d_ptr->connectToNotificationManager();
46 }
47 
48 //@cond PRIVATE
49 Monitor::Monitor(MonitorPrivate * d, QObject *parent) :
50  QObject( parent ),
51  d_ptr( d )
52 {
53  d_ptr->init();
54  d_ptr->connectToNotificationManager();
55 
56  ChangeMediator::registerMonitor(this);
57 }
58 //@endcond
59 
60 Monitor::~Monitor()
61 {
62  ChangeMediator::unregisterMonitor(this);
63 
64  // :TODO: Unsubscribe from the notification manager. That means having some kind of reference
65  // counting on the server side.
66  delete d_ptr;
67 }
68 
69 void Monitor::setCollectionMonitored( const Collection &collection, bool monitored )
70 {
71  Q_D( Monitor );
72  if ( monitored ) {
73  d->collections << collection;
74  } else {
75  d->collections.removeAll( collection );
76  d->cleanOldNotifications();
77  }
78  emit collectionMonitored( collection, monitored );
79 }
80 
81 void Monitor::setItemMonitored( const Item & item, bool monitored )
82 {
83  Q_D( Monitor );
84  if ( monitored ) {
85  d->items.insert( item.id() );
86  } else {
87  d->items.remove( item.id() );
88  d->cleanOldNotifications();
89  }
90  emit itemMonitored( item, monitored );
91 }
92 
93 void Monitor::setResourceMonitored( const QByteArray & resource, bool monitored )
94 {
95  Q_D( Monitor );
96  if ( monitored ) {
97  d->resources.insert( resource );
98  } else {
99  d->resources.remove( resource );
100  d->cleanOldNotifications();
101  }
102  emit resourceMonitored( resource, monitored );
103 }
104 
105 void Monitor::setMimeTypeMonitored( const QString & mimetype, bool monitored )
106 {
107  Q_D( Monitor );
108  if ( monitored ) {
109  d->mimetypes.insert( mimetype );
110  } else {
111  d->mimetypes.remove( mimetype );
112  d->cleanOldNotifications();
113  }
114 
115  emit mimeTypeMonitored( mimetype, monitored );
116 }
117 
118 void Akonadi::Monitor::setAllMonitored( bool monitored )
119 {
120  Q_D( Monitor );
121  d->monitorAll = monitored;
122 
123  if ( !monitored ) {
124  d->cleanOldNotifications();
125  }
126 
127  emit allMonitored( monitored );
128 }
129 
130 void Monitor::ignoreSession(Session * session)
131 {
132  Q_D( Monitor );
133  d->sessions << session->sessionId();
134  connect( session, SIGNAL(destroyed(QObject*)), this, SLOT(slotSessionDestroyed(QObject*)) );
135 }
136 
137 void Monitor::fetchCollection(bool enable)
138 {
139  Q_D( Monitor );
140  d->fetchCollection = enable;
141 }
142 
143 void Monitor::fetchCollectionStatistics(bool enable)
144 {
145  Q_D( Monitor );
146  d->fetchCollectionStatistics = enable;
147 }
148 
149 void Monitor::setItemFetchScope( const ItemFetchScope &fetchScope )
150 {
151  Q_D( Monitor );
152  d->mItemFetchScope = fetchScope;
153 }
154 
155 ItemFetchScope &Monitor::itemFetchScope()
156 {
157  Q_D( Monitor );
158  return d->mItemFetchScope;
159 }
160 
161 void Monitor::fetchChangedOnly( bool enable )
162 {
163  Q_D( Monitor );
164  d->mFetchChangedOnly = enable;
165 }
166 
167 
168 void Monitor::setCollectionFetchScope( const CollectionFetchScope &fetchScope )
169 {
170  Q_D( Monitor );
171  d->mCollectionFetchScope = fetchScope;
172 }
173 
174 CollectionFetchScope& Monitor::collectionFetchScope()
175 {
176  Q_D( Monitor );
177  return d->mCollectionFetchScope;
178 }
179 
180 Akonadi::Collection::List Monitor::collectionsMonitored() const
181 {
182  Q_D( const Monitor );
183  return d->collections;
184 }
185 
186 QList<Item::Id> Monitor::itemsMonitored() const
187 {
188  Q_D( const Monitor );
189  return d->items.toList();
190 }
191 
192 QVector<Item::Id> Monitor::itemsMonitoredEx() const
193 {
194  Q_D( const Monitor );
195  QVector<Item::Id> result;
196  result.reserve( d->items.size() );
197  qCopy( d->items.begin(), d->items.end(), std::back_inserter( result ) );
198  return result;
199 }
200 
201 QStringList Monitor::mimeTypesMonitored() const
202 {
203  Q_D( const Monitor );
204  return d->mimetypes.toList();
205 }
206 
207 QList<QByteArray> Monitor::resourcesMonitored() const
208 {
209  Q_D( const Monitor );
210  return d->resources.toList();
211 }
212 
213 bool Monitor::isAllMonitored() const
214 {
215  Q_D( const Monitor );
216  return d->monitorAll;
217 }
218 
219 void Monitor::setSession( Akonadi::Session *session )
220 {
221  Q_D( Monitor );
222  if (session == d->session)
223  return;
224 
225  if (!session)
226  d->session = Session::defaultSession();
227  else
228  d->session = session;
229 
230  d->itemCache->setSession(d->session);
231  d->collectionCache->setSession(d->session);
232 }
233 
234 Session* Monitor::session() const
235 {
236  Q_D( const Monitor );
237  return d->session;
238 }
239 
240 void Monitor::setCollectionMoveTranslationEnabled( bool enabled )
241 {
242  Q_D( Monitor );
243  d->collectionMoveTranslationEnabled = enabled;
244 }
245 
246 #include "moc_monitor.cpp"
This file is part of the KDE documentation.
Documentation copyright © 1996-2013 The KDE developers.
Generated on Sat Jul 13 2013 01:27:39 by doxygen 1.8.3.1 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-4.10.5 API Reference

Skip menu "kdepimlibs-4.10.5 API Reference"
  • akonadi
  •   contact
  •   kmime
  •   socialutils
  • kabc
  • kalarmcal
  • kblog
  • kcal
  • kcalcore
  • kcalutils
  • kholidays
  • kimap
  • kioslave
  •   imap4
  •   mbox
  •   nntp
  • kldap
  • kmbox
  • kmime
  • kontactinterface
  • kpimidentities
  • kpimtextedit
  • kpimutils
  • kresources
  • ktnef
  • kxmlrpcclient
  • mailtransport
  • microblog
  • qgpgme
  • syndication
  •   atom
  •   rdf
  •   rss2
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