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

« back to all changes in this revision

Viewing changes to akonadi/monitor.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:
60
60
{
61
61
  ChangeMediator::unregisterMonitor(this);
62
62
 
63
 
  // :TODO: Unsubscribe from the notification manager. That means having some kind of reference
64
 
  // counting on the server side.
65
63
  delete d_ptr;
66
64
}
67
65
 
68
66
void Monitor::setCollectionMonitored( const Collection &collection, bool monitored )
69
67
{
70
68
  Q_D( Monitor );
71
 
  if ( monitored ) {
 
69
  if ( !d->collections.contains( collection ) && monitored ) {
72
70
    d->collections << collection;
73
 
  } else {
74
 
    d->collections.removeAll( collection );
75
 
    d->cleanOldNotifications();
 
71
    if ( d->notificationSource ) {
 
72
      d->notificationSource->setMonitoredCollection( collection.id(), true );
 
73
    }
 
74
  } else if ( !monitored ) {
 
75
    if ( d->collections.removeAll( collection ) ) {
 
76
      d->cleanOldNotifications();
 
77
      if ( d->notificationSource ) {
 
78
        d->notificationSource->setMonitoredCollection( collection.id(), false );
 
79
      }
 
80
    }
76
81
  }
 
82
 
77
83
  emit collectionMonitored( collection, monitored );
78
84
}
79
85
 
80
 
void Monitor::setItemMonitored( const Item & item, bool monitored )
 
86
void Monitor::setItemMonitored( const Item &item, bool monitored )
81
87
{
82
88
  Q_D( Monitor );
83
 
  if ( monitored ) {
 
89
  if ( !d->items.contains( item.id() ) && monitored ) {
84
90
    d->items.insert( item.id() );
85
 
  } else {
86
 
    d->items.remove( item.id() );
87
 
    d->cleanOldNotifications();
 
91
    if ( d->notificationSource ) {
 
92
      d->notificationSource->setMonitoredItem( item.id(), true );
 
93
    }
 
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 );
 
99
      }
 
100
    }
88
101
  }
 
102
 
89
103
  emit itemMonitored( item,  monitored );
90
104
}
91
105
 
92
 
void Monitor::setResourceMonitored( const QByteArray & resource, bool monitored )
 
106
void Monitor::setResourceMonitored( const QByteArray &resource, bool monitored )
93
107
{
94
108
  Q_D( Monitor );
95
 
  if ( monitored ) {
 
109
  if ( !d->resources.contains( resource) && monitored ) {
96
110
    d->resources.insert( resource );
97
 
  } else {
98
 
    d->resources.remove( resource );
99
 
    d->cleanOldNotifications();
 
111
    if ( d->notificationSource ) {
 
112
      d->notificationSource->setMonitoredResource( resource, true );
 
113
    }
 
114
  } else if ( !monitored ) {
 
115
    if ( d->resources.remove( resource ) ) {
 
116
      d->cleanOldNotifications();
 
117
      if ( d->notificationSource ) {
 
118
        d->notificationSource->setMonitoredResource( resource, false );
 
119
      }
 
120
    }
100
121
  }
 
122
 
101
123
  emit resourceMonitored( resource, monitored );
102
124
}
103
125
 
104
126
void Monitor::setMimeTypeMonitored( const QString & mimetype, bool monitored )
105
127
{
106
128
  Q_D( Monitor );
107
 
  if ( monitored ) {
 
129
  if ( !d->mimetypes.contains( mimetype ) && monitored ) {
108
130
    d->mimetypes.insert( mimetype );
109
 
  } else {
110
 
    d->mimetypes.remove( mimetype );
111
 
    d->cleanOldNotifications();
 
131
    if ( d->notificationSource ) {
 
132
      d->notificationSource->setMonitoredMimeType( mimetype, true );
 
133
    }
 
134
  } else if ( !monitored ) {
 
135
    if ( d->mimetypes.remove( mimetype ) ) {
 
136
      d->cleanOldNotifications();
 
137
      if ( d->notificationSource ) {
 
138
        d->notificationSource->setMonitoredMimeType( mimetype, false );
 
139
      }
 
140
    }
112
141
  }
113
142
 
114
143
  emit mimeTypeMonitored( mimetype, monitored );
117
146
void Akonadi::Monitor::setAllMonitored( bool monitored )
118
147
{
119
148
  Q_D( Monitor );
 
149
  if ( d->monitorAll == monitored ) {
 
150
    return;
 
151
  }
 
152
 
120
153
  d->monitorAll = monitored;
121
154
 
122
155
  if ( !monitored ) {
123
156
    d->cleanOldNotifications();
124
157
  }
125
158
 
 
159
  if ( d->notificationSource ) {
 
160
    d->notificationSource->setAllMonitored( monitored );
 
161
  }
 
162
 
126
163
  emit allMonitored( monitored );
127
164
}
128
165
 
129
 
void Monitor::ignoreSession(Session * session)
 
166
void Monitor::ignoreSession( Session * session )
130
167
{
131
168
  Q_D( Monitor );
132
 
  d->sessions << session->sessionId();
133
 
  connect( session, SIGNAL(destroyed(QObject*)), this, SLOT(slotSessionDestroyed(QObject*)) );
 
169
 
 
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 );
 
175
    }
 
176
  }
134
177
}
135
178
 
136
 
void Monitor::fetchCollection(bool enable)
 
179
void Monitor::fetchCollection( bool enable )
137
180
{
138
181
  Q_D( Monitor );
139
182
  d->fetchCollection = enable;
140
183
}
141
184
 
142
 
void Monitor::fetchCollectionStatistics(bool enable)
 
185
void Monitor::fetchCollectionStatistics( bool enable )
143
186
{
144
187
  Q_D( Monitor );
145
188
  d->fetchCollectionStatistics = enable;
163
206
  d->mFetchChangedOnly = enable;
164
207
}
165
208
 
166
 
 
167
209
void Monitor::setCollectionFetchScope( const CollectionFetchScope &fetchScope )
168
210
{
169
211
  Q_D( Monitor );