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 = False) - prompt the user to take some action
24 once they have successfully logged in via the
25 external login. If 'prompt' is true, a text entry
26 box will be shown and the user-entered value returned.
27 If the user cancels the dialogue, None is returned.
29 progress(i, j) - the application is currently processing friend 'i' of
30 'j'. Should be used to provide the user a progress bar.
36 for service in services:
37 for friend in service.get_friends():
40 all_contacts = get_contacts_as_set()
42 updated_contacts = set()
43 for econtact in addressbook.get_all_contacts():
44 contact = Contact(addressbook, econtact)
46 for service in something.get_services_by_prioritisation():
47 if service.process_contact(contact):
48 updated_contacts.add(contact)
50 for service in something.get_services_by_prioritisation():
51 service.finalise(updated_contacts)
53 for contact in updated_contacts: