Skip to content
This repository has been archived by the owner on Sep 4, 2021. It is now read-only.

Commit

Permalink
Merge pull request #15 from matthewvogt/remove-listeners
Browse files Browse the repository at this point in the history
[libcontacts] Allow listeners to be removed
  • Loading branch information
matthewvogt committed Aug 13, 2013
2 parents 42fda18 + 535f60e commit f9d3617
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions src/seasidecache.h
Expand Up @@ -173,13 +173,32 @@ class CONTACTCACHE_EXPORT SeasideCache : public QObject
return listener;
}

bool removeListener(ItemListener *listener)
{
if (listeners) {
ItemListener *existing(listeners);
ItemListener **previous = &listeners;

while (existing) {
if (existing == listener) {
*previous = listener->next;
return true;
}
previous = &existing->next;
existing = existing->next;
}
}

return false;
}

ItemListener *listener(void *key)
{
ItemListener *l(listeners);
while (l && (l->key != key) && (l->next)) {
l = l->next;
ItemListener *existing(listeners);
while (existing && (existing->key != key) && (existing->next)) {
existing = existing->next;
}
return (l && (l->key == key)) ? l : 0;
return (existing && (existing->key == key)) ? existing : 0;
}

QContact contact;
Expand Down

0 comments on commit f9d3617

Please sign in to comment.