~ubuntu-branches/ubuntu/saucy/kdepimlibs/saucy-proposed

« back to all changes in this revision

Viewing changes to akonadi/monitor_p.cpp

  • Committer: Package Import Robot
  • Author(s): Philip Muškovac
  • Date: 2012-11-06 22:34:01 UTC
  • mfrom: (1.1.84)
  • Revision ID: package-import@ubuntu.com-20121106223401-p31t84xgazzfj3ln
Tags: 4:4.9.3-0ubuntu1
* New upstream release (LP: #1074747)
  - build-depend on libakonadi-dev (>= 1.8.1)
  - add new symbols to libakonadi-kde4.symbols

Show diffs side-by-side

added added

removed removed

Lines of Context:
155
155
  return true;
156
156
}
157
157
 
158
 
bool MonitorPrivate::acceptNotification( const NotificationMessage & msg )
 
158
bool MonitorPrivate::acceptNotification( const NotificationMessage & msg ) const
159
159
{
160
160
  // session is ignored
161
161
  if ( sessions.contains( msg.sessionId() ) )
166
166
    return false;
167
167
 
168
168
  // user requested everything
169
 
  if ( monitorAll )
 
169
  if ( monitorAll && msg.type() != NotificationMessage::InvalidType)
170
170
    return true;
171
171
 
172
172
  switch ( msg.type() ) {
209
209
 
210
210
void MonitorPrivate::cleanOldNotifications()
211
211
{
 
212
  bool erased = false;
212
213
  for ( NotificationMessage::List::iterator it = pipeline.begin(); it != pipeline.end(); ) {
213
 
    if ( !acceptNotification( *it ) )
 
214
    if ( !acceptNotification( *it ) ) {
214
215
      it = pipeline.erase( it );
215
 
    else
 
216
      erased = true;
 
217
    } else {
216
218
      ++it;
 
219
    }
217
220
  }
218
221
 
219
222
  for ( NotificationMessage::List::iterator it = pendingNotifications.begin(); it != pendingNotifications.end(); ) {
220
 
    if ( !acceptNotification( *it ) )
 
223
    if ( !acceptNotification( *it ) ) {
221
224
      it = pendingNotifications.erase( it );
222
 
    else
 
225
      erased = true;
 
226
    } else {
223
227
      ++it;
 
228
    }
224
229
  }
 
230
  if (erased)
 
231
    notificationsErased();
225
232
}
226
233
 
227
234
bool MonitorPrivate::ensureDataAvailable( const NotificationMessage &msg )
408
415
 
409
416
void MonitorPrivate::slotNotify( const NotificationMessage::List &msgs )
410
417
{
 
418
  int appendedMessages = 0;
 
419
  int modifiedMessages = 0;
 
420
  int erasedMessages = 0;
411
421
  foreach ( const NotificationMessage &msg, msgs ) {
412
422
    invalidateCaches( msg );
413
423
    updatePendingStatistics( msg );
414
424
    if ( acceptNotification( msg ) ) {
415
 
      translateAndCompress( pendingNotifications, msg );
 
425
      const int oldSize = pendingNotifications.size();
 
426
      const bool appended = translateAndCompress( pendingNotifications, msg );
 
427
      if ( appended ) {
 
428
        ++appendedMessages;
 
429
        // translateAndCompress can remove an existing "modify" when msg is a "delete". We need to detect that, for ChangeRecorder.
 
430
        if ( pendingNotifications.count() != oldSize + 1 )
 
431
          ++erasedMessages;
 
432
      }
 
433
      else
 
434
        ++modifiedMessages;
416
435
    }
417
436
  }
418
437
 
 
438
  // tell ChangeRecorder (even if 0 appended, the compression could have made changes to existing messages)
 
439
  if ( appendedMessages > 0 || modifiedMessages > 0 ) {
 
440
    if ( erasedMessages > 0 )
 
441
      notificationsErased();
 
442
    else
 
443
      notificationsEnqueued( appendedMessages );
 
444
  }
 
445
 
419
446
  dispatchNotifications();
420
447
}
421
448
 
442
469
 
443
470
void MonitorPrivate::dispatchNotifications()
444
471
{
 
472
  // Note that this code is not used in a ChangeRecorder (pipelineSize==0)
445
473
  while ( pipeline.size() < pipelineSize() && !pendingNotifications.isEmpty() ) {
446
474
    const NotificationMessage msg = pendingNotifications.dequeue();
447
475
    if ( ensureDataAvailable( msg ) && pipeline.isEmpty() )