[telepathy-ashes/master] omgstfu

David Laban david.laban at collabora.co.uk
Fri Oct 9 11:06:04 PDT 2009


---
 ashes/tools/bases.py         |   18 +++++++++++++-----
 ashes/tools/dispatchers.py   |   16 ++++------------
 ashes/tools/file_transfer.py |    2 +-
 ashes/tools/groups.py        |    1 +
 ashes/tools/media_echoer.py  |    2 +-
 ashes/tools/text.py          |    1 +
 6 files changed, 21 insertions(+), 19 deletions(-)

diff --git a/ashes/tools/bases.py b/ashes/tools/bases.py
index 6631903..5b496c3 100644
--- a/ashes/tools/bases.py
+++ b/ashes/tools/bases.py
@@ -1,6 +1,10 @@
 """
 This module contains the base classes for dbus and telepathy client objects.
+If you are developing a new client, it might be useful to set the environment
+variable TPPY_DEBUG=signals. This will cause unhandled dbus signals to be
+printed.
 """
+import os
 
 import gobject
 import dbus
@@ -57,9 +61,13 @@ class ObjectListener(object):
         #FIXME: port to dbus.Objets rather than ifacefactories.
         iface = self.dbus_object[iface_name]
         cb = getattr(self, signal_name, None)
-        if not cb:
-            cb = self._make_printer(iface_name, signal_name)
-        iface.connect_to_signal(signal_name, cb)
+        if cb:
+            iface.connect_to_signal(signal_name, cb)
+        else:
+            # FIXME: actually decide how to configure debug messages.
+            if "signals" in os.environ.get("TPPY_DEBUG", ""):
+                cb = self._make_printer(iface_name, signal_name)
+                iface.connect_to_signal(signal_name, cb)
 
     def _make_printer(self, iface_name, function_name):
         """
@@ -172,14 +180,14 @@ class ChannelListener(ObjectListener):
     ChannelDispatcher is currently in flux. In the past, you used the
     ChannelDispatcher.handler_for decorator, which is made of bong.
     What you now need to do is ensure that your ChannelListener subclass has
-    non-None values for channel_type, handle_type, and capabilities_flag, and
+    non-None values for channel_type, handle_type, and capability_flags, and
     then ensure that your ChannelDispatcher subclass/mixin contains a dict.
 
     The channel object will be ready for use when the constructor is called.
     """
     channel_type = None
     handle_type = None
-    capabilities_flag = None
+    capability_flags = None
 
     _signal_names = {
         'org.freedesktop.Telepathy.Channel.Type.Text':
diff --git a/ashes/tools/dispatchers.py b/ashes/tools/dispatchers.py
index 24c025e..8b6ed21 100644
--- a/ashes/tools/dispatchers.py
+++ b/ashes/tools/dispatchers.py
@@ -42,7 +42,6 @@ class ChannelDispatcher(ConnectionListener):
         handler_classes.update(self._handler_classes) # For backwards compat.
         useful_names = [n for n in dir(self) if n.endswith("handler_classes")]
         for name in useful_names:
-            print name
             # TODO: Might be worth having some pattern to match name against.
             classes = getattr(self, name)
             if isinstance(classes, dict):
@@ -71,26 +70,19 @@ class ChannelDispatcher(ConnectionListener):
         for (chantype, handletype), handler_class in handler_classes.items():
             if (handler_class.channel_type != None and
                     handler_class.handle_type != None and
-                    handler_class.capabilities_flag != None):
+                    handler_class.capability_flags != None):
                 caps.append((handler_class.channel_type,
-                        handler_class.capabilities_flag))
+                        handler_class.capability_flags))
                 assert chantype == handler_class.channel_type
                 assert handletype == handler_class.handle_type
             else:
-                print "WARNING: %s needs to override channel_type handle_type"\
-                    "and capabilities_flag. It doesn't." % handler_class
+                print "WARNING: %s needs to override channel_type handle_type "\
+                    "and capability_flags. It doesn't." % handler_class
 
         self.connection[self.CAPS].AdvertiseCapabilities(caps, [])
         get_property(self.connection, telepathy.CONNECTION_INTERFACE_REQUESTS,
             'Channels', reply_handler=self.NewChannels, error_handler=printer)
 
-    def NewChannel(self, object_path, channel_type, handle_type, handle, suppress_handler):
-        """
-        Callback for Connection.NewChannel. Currently doesn't do anything.
-        """
-        assert not suppress_handler # We shouldn't be creating any new channels.
-        print "Currently only accepting channels using Requests.NewChannels."
-
     #@shiny.debug_exceptions
     def NewChannels(self, Channels):
         """
diff --git a/ashes/tools/file_transfer.py b/ashes/tools/file_transfer.py
index 1fb1c24..4841202 100644
--- a/ashes/tools/file_transfer.py
+++ b/ashes/tools/file_transfer.py
@@ -11,7 +11,7 @@ class FileTransferEchoer(ChannelListener):
     """
     channel_type = 'org.freedesktop.Telepathy.Channel.Type.FileTransfer'
     handle_type = telepathy.HANDLE_TYPE_CONTACT
-    capabilities_flag = 3 # send and receive
+    capability_flags = 3 # send and receive
 
     def __init__(self, connection, channel, properties):
         ChannelListener.__init__(self, connection, channel, properties)
diff --git a/ashes/tools/groups.py b/ashes/tools/groups.py
index cd37e72..16225ac 100644
--- a/ashes/tools/groups.py
+++ b/ashes/tools/groups.py
@@ -97,6 +97,7 @@ class ContactAcceptor(MemberAcceptor):
     """
     channel_type = 'org.freedesktop.Telepathy.Channel.Type.ContactList'
     handle_type = telepathy.HANDLE_TYPE_LIST
+    capability_flags = 3 # Create and join: defaults to silence ChannelDispatcher.
 
     def __init__(self, *args, **kwargs):
         super(ContactAcceptor, self).__init__(*args, **kwargs)
diff --git a/ashes/tools/media_echoer.py b/ashes/tools/media_echoer.py
index 39a9741..46a39af 100644
--- a/ashes/tools/media_echoer.py
+++ b/ashes/tools/media_echoer.py
@@ -27,7 +27,7 @@ class MediaChannelEchoer(MemberAcceptor):
 
     channel_type = 'org.freedesktop.Telepathy.Channel.Type.StreamedMedia'
     handle_type = telepathy.HANDLE_TYPE_CONTACT
-    capabilities_flag = 0xff
+    capability_flags = int('011111', 2) # Everything but Immutable_Streams
 
     def __init__(self, connection, channel, properties):
         MemberAcceptor.__init__(self, connection, channel, properties)
diff --git a/ashes/tools/text.py b/ashes/tools/text.py
index 05a26c7..609db74 100644
--- a/ashes/tools/text.py
+++ b/ashes/tools/text.py
@@ -14,6 +14,7 @@ class TextChannelEchoer(ChannelListener):
     """
     channel_type = 'org.freedesktop.Telepathy.Channel.Type.Text'
     handle_type = telepathy.HANDLE_TYPE_CONTACT
+    capability_flags = 3 # Create and join.
 
     def __init__(self, connection, channel, properties):
         ChannelListener.__init__(self, connection, channel, properties)
-- 
1.5.6.5




More information about the telepathy-commits mailing list