[telepathy-butterfly/master] Only add MailNotification interface if profile says it's supported
Nicolas Dufresne
nicolas.dufresne at collabora.co.uk
Thu Jan 14 08:43:30 PST 2010
Signed-off-by: Nicolas Dufresne <nicolas.dufresne at collabora.co.uk>
---
butterfly/connection.py | 2 ++
butterfly/mail_notification.py | 8 ++++++++
2 files changed, 10 insertions(+), 0 deletions(-)
diff --git a/butterfly/connection.py b/butterfly/connection.py
index 541d738..81044d9 100644
--- a/butterfly/connection.py
+++ b/butterfly/connection.py
@@ -268,6 +268,8 @@ class ButterflyConnection(telepathy.server.Connection,
self._presence_changed(ButterflyHandleFactory(self, 'self'),
self._client.profile.presence,
self._client.profile.personal_message)
+ if self._client.profile.profile['EmailEnabled'] == '1':
+ self.EnableMailNotification()
elif state == papyon.event.ClientState.CLOSED:
self.StatusChanged(telepathy.CONNECTION_STATUS_DISCONNECTED,
self.__disconnect_reason)
diff --git a/butterfly/mail_notification.py b/butterfly/mail_notification.py
index adaca13..2331402 100644
--- a/butterfly/mail_notification.py
+++ b/butterfly/mail_notification.py
@@ -60,6 +60,10 @@ class ButterflyMailNotification(
logger.debug("Initialized")
telepathy.server.DBusProperties.__init__(self)
ConnectionInterfaceMailNotification.__init__(self)
+ # FIXME MSN Account is not always attached to an e-mail account. The
+ # tp-python generator should allow sub-class initialisation without
+ # adding the interface to the list. (see bug #26044)
+ self._interfaces.remove(CONN_IFACE_MAIL_NOTIFICATION)
papyon.event.MailboxEventInterface.__init__(self, self.msn_client)
self._implement_property_get(CONN_IFACE_MAIL_NOTIFICATION,
@@ -67,6 +71,10 @@ class ButterflyMailNotification(
'UnreadMailCount': lambda: self.unread_mail_count,})
+ def EnableMailNotification(self):
+ self._interfaces.add(CONN_IFACE_MAIL_NOTIFICATION)
+
+
@property
def capabilities(self):
return MAIL_NOTIFICATION_HAS_PROP_UNREADMAILCOUNT \
--
1.5.6.5
More information about the telepathy-commits
mailing list