~ubuntu-branches/ubuntu/trusty/kdepimlibs/trusty

« back to all changes in this revision

Viewing changes to akonadi/monitor_p.cpp

  • Committer: Package Import Robot
  • Author(s): Rohan Garg, Rohan Garg, Philip Muškovac
  • Date: 2013-11-23 17:36:44 UTC
  • mfrom: (1.1.102)
  • Revision ID: package-import@ubuntu.com-20131123173644-p5ow94192ezsny8g
Tags: 4:4.11.80-0ubuntu1
[ Rohan Garg ]
* New upstream beta release
  - Bump akonadi requirement to 1.10.45
  - Update install files
  - Update symbols

[ Philip Muškovac ]
* kdepimlibs-dev/-dbg breaks/replaces kdepim-runtime/-dbg (<< 4:4.11.80)

Show diffs side-by-side

added added

removed removed

Lines of Context:
51
51
  collectionMoveTranslationEnabled( true ),
52
52
  useRefCounting( false )
53
53
{
 
54
 
54
55
}
55
56
 
56
57
void MonitorPrivate::init()
90
91
 
91
92
void MonitorPrivate::serverStateChanged(ServerManager::State state)
92
93
{
93
 
  if ( state == ServerManager::Running )
 
94
  if ( state == ServerManager::Running ) {
94
95
    connectToNotificationManager();
 
96
    notificationSource->setAllMonitored( monitorAll );
 
97
    Q_FOREACH ( const Collection &col, collections ) {
 
98
      notificationSource->setMonitoredCollection( col.id(), true );
 
99
    }
 
100
    Q_FOREACH ( const Entity::Id id, items ) {
 
101
      notificationSource->setMonitoredItem( id, true );
 
102
    }
 
103
    Q_FOREACH ( const QByteArray &resource, resources ) {
 
104
      notificationSource->setMonitoredResource( resource, true );
 
105
    }
 
106
    Q_FOREACH ( const QByteArray &session, sessions ) {
 
107
      notificationSource->setIgnoredSession( session, true );
 
108
    }
 
109
    Q_FOREACH ( const QString &mimeType, mimetypes ) {
 
110
      notificationSource->setMonitoredMimeType( mimeType, true );
 
111
    }
 
112
  }
95
113
}
96
114
 
97
115
void MonitorPrivate::invalidateCollectionCache( qint64 id )
155
173
      return false;
156
174
  }
157
175
 
158
 
 
159
176
  if ( op == NotificationMessageV2::Move )
160
177
  {
161
178
    if ( !refCountMap.contains( parentCollectionId ) && !m_buffer.isBuffered( parentCollectionId ) )
244
261
  return list;
245
262
}
246
263
 
247
 
bool MonitorPrivate::acceptNotification( const NotificationMessageV2 &msg, bool allowModifyFlagsConversion ) const
 
264
bool MonitorPrivate::acceptNotification( const NotificationMessageV2 &msg ) const
248
265
{
249
266
  // session is ignored
250
267
  if ( sessions.contains( msg.sessionId() ) )
253
270
  if ( msg.entities().count() == 0 )
254
271
    return false;
255
272
 
256
 
  // corresponding signal is not connected
257
 
  if ( isLazilyIgnored( msg, allowModifyFlagsConversion ) ) {
258
 
    return false;
259
 
  }
260
 
 
261
273
  // user requested everything
262
274
  if ( monitorAll && msg.type() != NotificationMessageV2::InvalidType)
263
275
    return true;
366
378
 
367
379
      QSet<QByteArray> changedParts = msg.itemParts();
368
380
      Q_FOREACH( const QByteArray &part, changedParts )  {
369
 
        if( part.startsWith( "PLD:" ) && //krazy:exclude=strings since QByteArray
 
381
        if ( part.startsWith( "PLD:" ) && //krazy:exclude=strings since QByteArray
370
382
            ( fullPayloadWasRequested || requestedPayloadParts.contains( part ) ) ) {
371
383
          scope.fetchPayloadPart( part.mid(4), true );;
372
384
        }
431
443
void MonitorPrivate::slotSessionDestroyed( QObject * object )
432
444
{
433
445
  Session* objectSession = qobject_cast<Session*>( object );
434
 
  if ( objectSession )
 
446
  if ( objectSession ) {
435
447
    sessions.removeAll( objectSession->sessionId() );
 
448
    if ( notificationSource ) {
 
449
      notificationSource->setIgnoredSession( objectSession->sessionId(), false );
 
450
    }
 
451
  }
436
452
}
437
453
 
438
454
void MonitorPrivate::slotStatisticsChangedFinished( KJob* job )
536
552
  foreach ( const NotificationMessageV2 &msg, msgs ) {
537
553
    invalidateCaches( msg );
538
554
    updatePendingStatistics( msg );
539
 
    if ( acceptNotification( msg, true ) ) {
540
 
      bool needsSplit = true;
541
 
      bool supportsBatch = false;
542
 
 
543
 
      checkBatchSupport( msg, needsSplit, supportsBatch );
544
 
 
545
 
      if ( supportsBatch
546
 
          || ( !needsSplit && !supportsBatch && msg.operation() != NotificationMessageV2::ModifyFlags )
547
 
          || msg.type() == NotificationMessageV2::Collections ) {
548
 
        // Make sure the batch msg is always queued before the split notifications
549
 
        const int oldSize = pendingNotifications.size();
550
 
        const int appended = translateAndCompress( pendingNotifications, msg );
551
 
        if ( appended > 0 ) {
552
 
          appendedMessages += appended;
553
 
        } else {
554
 
          ++modifiedMessages;
555
 
        }
556
 
        // translateAndCompress can remove an existing "modify" when msg is a "delete".
557
 
        // Or it can merge two ModifyFlags and return false.
558
 
        // We need to detect such removals, for ChangeRecorder.
559
 
        if ( pendingNotifications.count() != oldSize + appended ) {
560
 
          ++erasedMessages; // this count isn't exact, but it doesn't matter
561
 
        }
562
 
      } else if ( needsSplit ) {
563
 
        // If it's not queued at least make sure we fetch all the items from split
564
 
        // notifications in one go.
565
 
        itemCache->ensureCached( msg.uids(), mItemFetchScope );
566
 
      }
567
 
 
568
 
      // if the message contains more items, but we need to emit single-item notification,
569
 
      // split the message into one message per item and queue them
570
 
      // if the message contains only one item, but batches are not supported
571
 
      // (and thus neither is flagsModified), splitMessage() will convert the
572
 
      // notification to regular Modify with "FLAGS" part changed
573
 
      if ( needsSplit || ( !needsSplit && !supportsBatch && msg.operation() == Akonadi::NotificationMessageV2::ModifyFlags ) ) {
574
 
        const NotificationMessageV2::List split = splitMessage( msg, !supportsBatch );
575
 
        pendingNotifications << split.toList();
576
 
        appendedMessages += split.count();
577
 
      }
 
555
    bool needsSplit = true;
 
556
    bool supportsBatch = false;
 
557
 
 
558
    if ( isLazilyIgnored( msg, true ) ) {
 
559
      continue;
 
560
    }
 
561
 
 
562
    checkBatchSupport( msg, needsSplit, supportsBatch );
 
563
 
 
564
    if ( supportsBatch
 
565
        || ( !needsSplit && !supportsBatch && msg.operation() != NotificationMessageV2::ModifyFlags )
 
566
        || msg.type() == NotificationMessageV2::Collections ) {
 
567
      // Make sure the batch msg is always queued before the split notifications
 
568
      const int oldSize = pendingNotifications.size();
 
569
      const int appended = translateAndCompress( pendingNotifications, msg );
 
570
      if ( appended > 0 ) {
 
571
        appendedMessages += appended;
 
572
      } else {
 
573
        ++modifiedMessages;
 
574
      }
 
575
      // translateAndCompress can remove an existing "modify" when msg is a "delete".
 
576
      // Or it can merge two ModifyFlags and return false.
 
577
      // We need to detect such removals, for ChangeRecorder.
 
578
      if ( pendingNotifications.count() != oldSize + appended ) {
 
579
        ++erasedMessages; // this count isn't exact, but it doesn't matter
 
580
      }
 
581
    } else if ( needsSplit ) {
 
582
      // If it's not queued at least make sure we fetch all the items from split
 
583
      // notifications in one go.
 
584
      itemCache->ensureCached( msg.uids(), mItemFetchScope );
 
585
    }
 
586
 
 
587
    // if the message contains more items, but we need to emit single-item notification,
 
588
    // split the message into one message per item and queue them
 
589
    // if the message contains only one item, but batches are not supported
 
590
    // (and thus neither is flagsModified), splitMessage() will convert the
 
591
    // notification to regular Modify with "FLAGS" part changed
 
592
    if ( needsSplit || ( !needsSplit && !supportsBatch && msg.operation() == Akonadi::NotificationMessageV2::ModifyFlags ) ) {
 
593
      const NotificationMessageV2::List split = splitMessage( msg, !supportsBatch );
 
594
      pendingNotifications << split.toList();
 
595
      appendedMessages += split.count();
578
596
    }
579
597
  }
580
598
 
683
701
    }
684
702
  }
685
703
 
686
 
 
687
704
  // Now reconstruct any items there were left in msgItems
688
705
  Q_FOREACH( const NotificationMessageV2::Entity &msgItem, msgEntities ) {
689
706
    Item it( msgItem.id );