Friend now has _source field again :)
[hermes] / package / src / org / maemo / hermes / engine / provider.py
1 import re
2
3 class Provider:
4     """The notional `Provider' which defines the interface which all service
5        providers for Hermes must meet. Implementations of this class are expected
6        to load their preferences on construction, display them through open_preferences
7        and pass them to the service object as necessary. 
8        
9        Copyright (c) Andrew Flegg <andrew@bleb.org> 2010.
10        Released under the Artistic Licence."""
11
12
13     # -----------------------------------------------------------------------
14     def get_name(self):
15         """Return the display name of this service. An icon, of with the lower-case,
16            all-alphabetic version of this name is expected to be provided."""
17            
18         return None
19
20
21     # -----------------------------------------------------------------------
22     def get_id(self):
23         """Return the ID of this service. This should be alphanumeric characters
24            only. The default implementation is the lowercase version of get_name()
25            with all non-alphanumeric characters removed.
26            
27            Overridding this method is NOT recommended."""
28            
29         return re.sub('[^a-z0-9]+', '', self.get_name().lower())
30
31
32     # -----------------------------------------------------------------------
33     def get_account_detail(self):
34         """Return information on the configured account. This would, typically,
35            be the user's login for the service. If None is returned, no futher
36            information is available."""
37            
38         return None
39     
40     
41     # -----------------------------------------------------------------------
42     def has_preferences(self):
43         """Whether or not this provider has any preferences. If it does not,
44            open_preferences must NOT be called; as the behaviour is undetermined."""
45            
46         return False
47     
48     
49     # -----------------------------------------------------------------------
50     def open_preferences(self, parent):
51         """Open the preferences for this provider as a child of the 'parent' widget.
52            The dialogue box should have a _('Disable') and _('Enable') button; and
53            return True if the user chooses to enable the service; False if not.
54            If the user cancels the dialogue, return None."""
55         
56         pass
57
58     
59     # -----------------------------------------------------------------------
60     def service(self, gui_callback):
61         """Return the service backend. This must be a class which implements the
62            following methods:
63                * get_friends
64                * process_contact
65                * finalise
66         
67            See Service for more details."""
68            
69         return None