added Friend (a data container)
[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 the user to take some action once they have
24                                 successfully logged in to Facebook.
25                               
26              progress(i, j) - the application is currently processing friend 'i' of
27                               'j'. Should be used to provide the user a progress bar.
28         """
29         
30         pass
31 """        
32  friends = ()
33  for service in services:
34    for friend in service.get_friends():
35      friends.add(friend)
36
37  all_contacts = get_contacts_as_set()
38  contacts = set()
39  updated_contacts = set()
40  for econtact in addressbook.get_all_contacts():
41    contact = Contact(addressbook, econtact)
42    contacts.add(contact)
43    for service in something.get_services_by_prioritisation():
44      if service.process_contact(contact):
45        updated_contacts.add(contact)
46
47  for service in something.get_services_by_prioritisation():
48    service.finalise(updated_contacts)
49
50  for contact in updated_contacts:
51    contact.save()
52 """