61
61
ChangeMediator::unregisterMonitor(this);
63
// :TODO: Unsubscribe from the notification manager. That means having some kind of reference
64
// counting on the server side.
68
66
void Monitor::setCollectionMonitored( const Collection &collection, bool monitored )
69
if ( !d->collections.contains( collection ) && monitored ) {
72
70
d->collections << collection;
74
d->collections.removeAll( collection );
75
d->cleanOldNotifications();
71
if ( d->notificationSource ) {
72
d->notificationSource->setMonitoredCollection( collection.id(), true );
74
} else if ( !monitored ) {
75
if ( d->collections.removeAll( collection ) ) {
76
d->cleanOldNotifications();
77
if ( d->notificationSource ) {
78
d->notificationSource->setMonitoredCollection( collection.id(), false );
77
83
emit collectionMonitored( collection, monitored );
80
void Monitor::setItemMonitored( const Item & item, bool monitored )
86
void Monitor::setItemMonitored( const Item &item, bool monitored )
89
if ( !d->items.contains( item.id() ) && monitored ) {
84
90
d->items.insert( item.id() );
86
d->items.remove( item.id() );
87
d->cleanOldNotifications();
91
if ( d->notificationSource ) {
92
d->notificationSource->setMonitoredItem( item.id(), true );
94
} else if ( !monitored ) {
95
if ( d->items.remove( item.id() ) ) {
96
d->cleanOldNotifications();
97
if ( d->notificationSource ) {
98
d->notificationSource->setMonitoredItem( item.id(), false );
89
103
emit itemMonitored( item, monitored );
92
void Monitor::setResourceMonitored( const QByteArray & resource, bool monitored )
106
void Monitor::setResourceMonitored( const QByteArray &resource, bool monitored )
109
if ( !d->resources.contains( resource) && monitored ) {
96
110
d->resources.insert( resource );
98
d->resources.remove( resource );
99
d->cleanOldNotifications();
111
if ( d->notificationSource ) {
112
d->notificationSource->setMonitoredResource( resource, true );
114
} else if ( !monitored ) {
115
if ( d->resources.remove( resource ) ) {
116
d->cleanOldNotifications();
117
if ( d->notificationSource ) {
118
d->notificationSource->setMonitoredResource( resource, false );
101
123
emit resourceMonitored( resource, monitored );
104
126
void Monitor::setMimeTypeMonitored( const QString & mimetype, bool monitored )
129
if ( !d->mimetypes.contains( mimetype ) && monitored ) {
108
130
d->mimetypes.insert( mimetype );
110
d->mimetypes.remove( mimetype );
111
d->cleanOldNotifications();
131
if ( d->notificationSource ) {
132
d->notificationSource->setMonitoredMimeType( mimetype, true );
134
} else if ( !monitored ) {
135
if ( d->mimetypes.remove( mimetype ) ) {
136
d->cleanOldNotifications();
137
if ( d->notificationSource ) {
138
d->notificationSource->setMonitoredMimeType( mimetype, false );
114
143
emit mimeTypeMonitored( mimetype, monitored );
117
146
void Akonadi::Monitor::setAllMonitored( bool monitored )
149
if ( d->monitorAll == monitored ) {
120
153
d->monitorAll = monitored;
122
155
if ( !monitored ) {
123
156
d->cleanOldNotifications();
159
if ( d->notificationSource ) {
160
d->notificationSource->setAllMonitored( monitored );
126
163
emit allMonitored( monitored );
129
void Monitor::ignoreSession(Session * session)
166
void Monitor::ignoreSession( Session * session )
132
d->sessions << session->sessionId();
133
connect( session, SIGNAL(destroyed(QObject*)), this, SLOT(slotSessionDestroyed(QObject*)) );
170
if ( !d->sessions.contains( session->sessionId() )) {
171
d->sessions << session->sessionId();
172
connect( session, SIGNAL(destroyed(QObject*)), this, SLOT(slotSessionDestroyed(QObject*)) );
173
if ( d->notificationSource ) {
174
d->notificationSource->setIgnoredSession( session->sessionId(), true );
136
void Monitor::fetchCollection(bool enable)
179
void Monitor::fetchCollection( bool enable )
139
182
d->fetchCollection = enable;
142
void Monitor::fetchCollectionStatistics(bool enable)
185
void Monitor::fetchCollectionStatistics( bool enable )
145
188
d->fetchCollectionStatistics = enable;