Log In
New Account
  
Home My Page Project Cloud Code Snippets Project Openings Hermes
Summary Lists News SCM
authorFredrik Wendt <fredrik@wendt.se>
Wed, 9 Jun 2010 14:05:30 +0000 (15:05 +0100)
committerFredrik Wendt <fredrik@wendt.se>
Wed, 9 Jun 2010 14:05:30 +0000 (15:05 +0100)
moved installation check of gravatar from service to provider

Signed-off-by: Fredrik Wendt <fredrik@wendt.se>

package/src/org/maemo/hermes/engine/facebook/service.py
package/src/org/maemo/hermes/engine/gravatar/provider.py
package/src/org/maemo/hermes/engine/gravatar/service.py
package/src/org/maemo/hermes/engine/service.py
package/src/org/maemo/hermes/engine/twitter/service.py

index 30d24cc..b227277 100644 (file)
@@ -69,7 +69,7 @@ class Service(org.maemo.hermes.engine.service.Service):
         friends_data = self._get_friends_data()
         for data in friends_data:
             key = canonical(data['name']) # FIXME: deal with name collision
-            friend = self._create_friend(data['name'])
+            friend = Friend(data['name'])
         
             if 'profile_url' not in data:
                 data['profile_url'] = "http://www.facebook.com/profile.php?id=" + str(data['uid'])
index 96e81e9..c9e003e 100644 (file)
@@ -13,6 +13,12 @@ class Provider(org.maemo.hermes.engine.provider.Provider):
     def __init__(self):
         self._gconf = gnome.gconf.client_get_default()
 
+        self._api_email = self._gconf.get_string('/apps/maemo/hermes/gravatar_email')
+        self._api_key = self._gconf.get_string('/apps/maemo/hermes/gravatar_key')
+
+        if self._api_key is None or self._api_email is None:
+            raise Exception('No Gravatar application keys found. Installation error.')
+
 
     # -----------------------------------------------------------------------
     def get_name(self):
@@ -34,7 +40,4 @@ class Provider(org.maemo.hermes.engine.provider.Provider):
     def service(self, gui_callback):
         """Return the service backend"""
 
-        api_email = self._gconf.get_string('/apps/maemo/hermes/gravatar_email')
-        api_key = self._gconf.get_string('/apps/maemo/hermes/gravatar_key')
-
-        return org.maemo.hermes.engine.gravatar.service.Service(self.get_id(), api_email, api_key)
+        return org.maemo.hermes.engine.gravatar.service.Service(self.get_id(), self.api_email, self.api_key)
index f8f336c..6c4880b 100644 (file)
@@ -1,5 +1,6 @@
 import urllib, hashlib, xmlrpclib
 import org.maemo.hermes.engine.service
+from org.maemo.hermes.engine.friend import Friend
 
 class Service(org.maemo.hermes.engine.service.Service):
     """Gravatar backend for Hermes.
@@ -14,15 +15,13 @@ class Service(org.maemo.hermes.engine.service.Service):
         """Initialise the Gravatar service.
         
         api_email is the email address to use when talking to the backend.
-        api_key is the "secret" key used when talking to the backend
+        api_key is the "secret" key to use when talking to the backend.
         """
         
         org.maemo.hermes.engine.service.Service.__init__(self, service_id)
 
         self._api_email  = api_email
         self._api_key    = api_key
-        if self._api_key is None or self._api_email is None:
-            raise Exception('No Gravatar application keys found. Installation error.')
          
         self._address_to_contact = {}
         self._hash_to_address = {}
@@ -50,7 +49,7 @@ class Service(org.maemo.hermes.engine.service.Service):
             for address in contact.get_emails():
                 hash = self._get_hash_for_address(address)
                 if (self._hash_has_gravatar.has_key(hash) and self._hash_has_gravatar[hash]):
-                    friend = self._create_friend(contact.get_name())
+                    friend = Friend(contact.get_name())
                     friend.set_photo_url(self._get_url_for_email_hash(hash))
                     self._register_match(contact, friend)
                     return friend
index 85469b1..65bdab7 100644 (file)
@@ -67,11 +67,3 @@ class Service:
            be added to."""
            
         pass
-
-
-    # -----------------------------------------------------------------------
-    ###DEPRECATED
-    def _create_friend(self, name):
-        """Used to create a Friend object for a contact"""
-        
-        return Friend(name, self._service_id)
index 9042076..6257840 100644 (file)
@@ -1,4 +1,5 @@
 from org.maemo.hermes.engine.names import canonical
+from org.maemo.hermes.engine.friend import Friend
 import org.maemo.hermes.engine.service
 
 class Service(org.maemo.hermes.engine.service.Service):
@@ -35,7 +36,7 @@ class Service(org.maemo.hermes.engine.service.Service):
         for tweeter in self._get_tweeters():
             key = canonical(tweeter.name)
             url = 'http://twitter.com/%s' % (tweeter.screen_name)
-            friend = self._create_friend(tweeter.name)
+            friend = Friend(tweeter.name)
             friend.set_nickname(tweeter.screen_name)
             friend.add_url(url)
             friend.add_url(tweeter.url)

Terms of Use    Privacy Policy    Contribution Guidelines    Feedback

Powered By GForge Collaborative Development Environment