91
92
void MonitorPrivate::serverStateChanged(ServerManager::State state)
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 );
100
Q_FOREACH ( const Entity::Id id, items ) {
101
notificationSource->setMonitoredItem( id, true );
103
Q_FOREACH ( const QByteArray &resource, resources ) {
104
notificationSource->setMonitoredResource( resource, true );
106
Q_FOREACH ( const QByteArray &session, sessions ) {
107
notificationSource->setIgnoredSession( session, true );
109
Q_FOREACH ( const QString &mimeType, mimetypes ) {
110
notificationSource->setMonitoredMimeType( mimeType, true );
97
115
void MonitorPrivate::invalidateCollectionCache( qint64 id )
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;
543
checkBatchSupport( msg, needsSplit, 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;
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
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 );
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();
555
bool needsSplit = true;
556
bool supportsBatch = false;
558
if ( isLazilyIgnored( msg, true ) ) {
562
checkBatchSupport( msg, needsSplit, 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;
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
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 );
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();