Change the block_for_auth API so that an argument can be passed
[hermes] / package / src / org / maemo / hermes / engine / __init__.py
1 class Hermes:
2     """Encapsulate the process of syncing online friends' information with the
3        Evolution contacts' database. This should be used as follows:
4        
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.
10          
11        Copyright (c) Andrew Flegg <andrew@bleb.org> 2009.
12        Released under the Artistic Licence."""
13     
14     
15     # -----------------------------------------------------------------------
16     def __init__(self, gui_callback):
17         """Constructor. Passed a callback which must implement three informational
18            methods:
19            
20              need_auth() - called to indicate an external login is about to occur.
21                            The user should be informed.
22                            
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.
28                               
29              progress(i, j) - the application is currently processing friend 'i' of
30                               'j'. Should be used to provide the user a progress bar.
31         """
32         
33         pass
34 """        
35  friends = ()
36  for service in services:
37    for friend in service.get_friends():
38      friends.add(friend)
39
40  all_contacts = get_contacts_as_set()
41  contacts = set()
42  updated_contacts = set()
43  for econtact in addressbook.get_all_contacts():
44    contact = Contact(addressbook, econtact)
45    contacts.add(contact)
46    for service in something.get_services_by_prioritisation():
47      if service.process_contact(contact):
48        updated_contacts.add(contact)
49
50  for service in something.get_services_by_prioritisation():
51    service.finalise(updated_contacts)
52
53  for contact in updated_contacts:
54    contact.save()
55 """