added friend['contact'] to Twitter service, plus tests
[hermes] / package / src / org / maemo / hermes / engine / twitter / service.py
index 273b99d..a0b0408 100644 (file)
@@ -53,13 +53,12 @@ class Service(org.maemo.hermes.engine.service.Service):
     
     # -----------------------------------------------------------------------
     def process_contact(self, contact):
-        if self._friends_by_contact.has_key(contact):
-            return
+        if self._friends_by_contact.has_key(contact) or \
+            self._match_contact_to_friend_by_urls(contact) or \
+            self._match_contact_to_friend_by_identifiers(contact):
+            return self._get_friend_by_contact(contact)
         
-        if self._match_contact_to_friend_by_urls(contact):
-            return
-        
-        self._match_contact_to_friend_by_identifiers(contact)
+        return None
     
     
     # -----------------------------------------------------------------------
@@ -80,6 +79,11 @@ class Service(org.maemo.hermes.engine.service.Service):
     # -----------------------------------------------------------------------
     def _get_tweeters(self):
         return self._twitter.GetFriends()
+    
+    
+    # -----------------------------------------------------------------------
+    def _get_friend_by_contact(self, contact):
+        return self._friends_by_contact[contact]
 
 
     def _match_contact_to_friend_by_urls(self, contact):
@@ -105,6 +109,7 @@ class Service(org.maemo.hermes.engine.service.Service):
 
 
     def _register_match(self, contact, friend):
+        friend.set_contact(contact)
         self._friends_by_contact[contact] = friend
         self._friends.remove(friend)