Implement progress bars and fix a few bugs.
[hermes] / package / src / org / maemo / hermes / engine / contact.py
index 0b8cbd4..b9a49d2 100644 (file)
@@ -27,13 +27,14 @@ class Contact:
 
        
     # -----------------------------------------------------------------------
-    def __init__(self, book, contact):
+    def __init__(self, book, econtact):
         """Create a new contact store for modifying contacts in the given
            EBook."""
         
         self._book = book
-        self._contact = contact
+        self._contact = econtact
         self._identifiers = self._find_ids()
+        self._mapped_to = set([])
         
         
     # -----------------------------------------------------------------------
@@ -71,6 +72,38 @@ class Contact:
            versions of identifiers for this contact."""
            
         return self._identifiers
+
+    
+    # -----------------------------------------------------------------------
+    def get_econtact(self):
+        """Return the EContact which backs this contact."""
+        
+        return self._contact
+    
+    
+    # -----------------------------------------------------------------------
+    def add_mapping(self, id):
+        """Record the fact that this contact is mapped against a provider.
+           'id' MUST match the string returned by Provider.get_id()."""
+        
+        self._mapped_to.add(id)
+        
+        
+    # ----------------------------------------------------------------------
+    def get_mappings(self):
+        """Return the set of IDs of providers which are mapped to this contact.
+           The data can only be relied upon after services have run."""
+           
+        return self._mapped_to
+
+
+    # -----------------------------------------------------------------------
+    def get_photo(self):
+        """Return the photo property, or None. The result is of type
+        EContactPhoto."""
+        
+        photo = self._contact.get_property('photo')
+        return cast(c_void_p(hash(photo)), POINTER(EContactPhoto))
     
     
     # -----------------------------------------------------------------------
@@ -110,12 +143,6 @@ class Contact:
         except:
             print "FAILED to get photo from URL %s" % url
             return False
-    
-    
-    # -----------------------------------------------------------------------
-    def has_photo(self):
-        # FIXME
-        return False
       
       
     # -----------------------------------------------------------------------