def __init__(self, backend):
self._backend = backend
self._contacts = {}
- self._addedContacts = set()
- self._removedContacts = set()
- self._changedContacts = set()
self.updateSignalHandler = coroutines.CoTee()
self._populate_contacts()
newContactIds = set(self.get_contacts())
- self._addedContacts = newContactIds - oldContactIds
- self._removedContacts = oldContactIds - newContactIds
- self._changedContacts = set(
+ addedContacts = newContactIds - oldContactIds
+ removedContacts = oldContactIds - newContactIds
+ changedContacts = set(
contactId
for contactId in newContactIds.intersection(oldContactIds)
if self._has_contact_changed(contactId, oldContacts)
)
- if self._addedContacts or self._removedContacts or self._changedContacts:
- message = self, self._addedContacts, self._removedContacts, self._changedContacts
+ if addedContacts or removedContacts or changedContacts:
+ message = self, addedContacts, removedContacts, changedContacts
self.updateSignalHandler.stage.send(message)
def get_contacts(self):
return self._contacts[contactId][0]
def get_contact_details(self, contactId):
- self._populate_contact_details(contactId)
- return self._get_contact_details(contactId)
+ return iter(self._contacts[contactId][1])
def find_contacts_with_number(self, queryNumber):
strippedQueryNumber = util_misc.strip_number(queryNumber)
]
self._contacts[contactId] = (contactName, contactNumbers)
- def _populate_contact_details(self, contactId):
- if self._get_contact_details(contactId):
- return
- self._get_contact_details(contactId).extend(
- self._backend.get_contact_details(contactId)
- )
-
- def _get_contact_details(self, contactId):
- return self._contacts[contactId][1]
-
def _has_contact_changed(self, contactId, oldContacts):
oldContact = oldContacts[contactId]
oldContactName = oldContact[0]