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'])
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):
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)
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.
"""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 = {}
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
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)
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):
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)