2 """Encapsulate the process of syncing online friends' information with the
3 Evolution contacts' database. This should be used as follows:
5 * Initialise, passing in a GUI callback.
6 * Call initialise_services().
7 * Call sync_contacts().
8 * Retrieve information on changes effected.
9 * Call update_contact to enact manual mapping.
11 Copyright (c) Andrew Flegg <andrew@bleb.org> 2009.
12 Released under the Artistic Licence."""
15 # -----------------------------------------------------------------------
16 def __init__(self, gui_callback):
17 """Constructor. Passed a callback which must implement three informational
20 need_auth() - called to indicate an external login is about to occur.
21 The user should be informed.
23 block_for_auth() - prompt the user to take some action once they have
24 successfully logged in to Facebook.
26 progress(i, j) - the application is currently processing friend 'i' of
27 'j'. Should be used to provide the user a progress bar.
33 for service in services:
34 for friend in service.get_friends():
37 all_contacts = get_contacts_as_set()
39 updated_contacts = set()
40 for econtact in addressbook.get_all_contacts():
41 contact = Contact(addressbook, econtact)
43 for service in something.get_services_by_prioritisation():
44 if service.process_contact(contact):
45 updated_contacts.add(contact)
47 for service in something.get_services_by_prioritisation():
48 service.finalise(updated_contacts)
50 for contact in updated_contacts: