Plenty of HACKs to get my code to work with Requests
authorEd Page <eopage@byu.net>
Sun, 10 Jan 2010 03:17:14 +0000 (21:17 -0600)
committerEd Page <eopage@byu.net>
Sun, 10 Jan 2010 03:17:14 +0000 (21:17 -0600)
src/channel/call.py
src/channel/contact_list.py
src/channel/debug_prompt.py
src/channel/text.py
src/channel_manager.py

index c6fd368..09f704a 100644 (file)
@@ -22,6 +22,11 @@ class CallChannel(
                try:
                        # HACK Older python-telepathy way
                        telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, None)
+                       self._requested = props[telepathy.interfaces.CHANNEL_INTERFACE + '.Requested']
+                       self._implement_property_get(
+                               telepathy.interfaces.CHANNEL_INTERFACE,
+                               {"Requested": lambda: self._requested}
+                       )
                except TypeError:
                        # HACK Newer python-telepathy way
                        telepathy.server.ChannelTypeStreamedMedia.__init__(self, connection, manager, props)
@@ -42,6 +47,22 @@ class CallChannel(
        def initial_video(self):
                return False
 
+       def get_props(self):
+               # HACK Older python-telepathy doesn't provide this
+               _immutable_properties = {
+                       'ChannelType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandle': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Interfaces': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandleType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetID': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Requested': telepathy.server.interfaces.CHANNEL_INTERFACE
+               }
+               props = dict()
+               for prop, iface in _immutable_properties.items():
+                       props[iface + '.' + prop] = \
+                               self._prop_getters[iface][prop]()
+               return props
+
        @gtk_toolbox.log_exception(_moduleLogger)
        def Close(self):
                self.close()
index 78a0e01..8f38fbd 100644 (file)
@@ -22,6 +22,11 @@ class AllContactsListChannel(
                try:
                        # HACK Older python-telepathy way
                        telepathy.server.ChannelTypeContactList.__init__(self, connection, h)
+                       self._requested = props[telepathy.interfaces.CHANNEL_INTERFACE + '.Requested']
+                       self._implement_property_get(
+                               telepathy.interfaces.CHANNEL_INTERFACE,
+                               {"Requested": lambda: self._requested}
+                       )
                except TypeError:
                        # HACK Newer python-telepathy way
                        telepathy.server.ChannelTypeContactList.__init__(self, connection, manager, props)
@@ -46,6 +51,22 @@ class AllContactsListChannel(
                contacts = addressbook.get_contacts()
                self._process_refresh(addressbook, contacts, [])
 
+       def get_props(self):
+               # HACK Older python-telepathy doesn't provide this
+               _immutable_properties = {
+                       'ChannelType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandle': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Interfaces': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandleType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetID': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Requested': telepathy.server.interfaces.CHANNEL_INTERFACE
+               }
+               props = dict()
+               for prop, iface in _immutable_properties.items():
+                       props[iface + '.' + prop] = \
+                               self._prop_getters[iface][prop]()
+               return props
+
        @gtk_toolbox.log_exception(_moduleLogger)
        def Close(self):
                self.close()
index f7dcef1..ed7e2e3 100644 (file)
@@ -26,6 +26,11 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
                try:
                        # HACK Older python-telepathy way
                        telepathy.server.ChannelTypeText.__init__(self, connection, contactHandle)
+                       self._requested = props[telepathy.interfaces.CHANNEL_INTERFACE + '.Requested']
+                       self._implement_property_get(
+                               telepathy.interfaces.CHANNEL_INTERFACE,
+                               {"Requested": lambda: self._requested}
+                       )
                except TypeError:
                        # HACK Newer python-telepathy way
                        telepathy.server.ChannelTypeText.__init__(self, connection, manager, props)
@@ -34,6 +39,22 @@ class DebugPromptChannel(telepathy.server.ChannelTypeText, cmd.Cmd):
 
                self.__otherHandle = contactHandle
 
+       def get_props(self):
+               # HACK Older python-telepathy doesn't provide this
+               _immutable_properties = {
+                       'ChannelType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandle': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Interfaces': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandleType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetID': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Requested': telepathy.server.interfaces.CHANNEL_INTERFACE
+               }
+               props = dict()
+               for prop, iface in _immutable_properties.items():
+                       props[iface + '.' + prop] = \
+                               self._prop_getters[iface][prop]()
+               return props
+
        @gtk_toolbox.log_exception(_moduleLogger)
        def Send(self, messageType, text):
                if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
index f2b8af0..dfc1a49 100644 (file)
@@ -4,7 +4,6 @@ import logging
 
 import telepathy
 
-import util.go_utils as gobject_utils
 import util.coroutines as coroutines
 import gtk_toolbox
 
@@ -24,6 +23,11 @@ class TextChannel(telepathy.server.ChannelTypeText):
                try:
                        # HACK Older python-telepathy way
                        telepathy.server.ChannelTypeText.__init__(self, connection, contactHandle)
+                       self._requested = props[telepathy.interfaces.CHANNEL_INTERFACE + '.Requested']
+                       self._implement_property_get(
+                               telepathy.interfaces.CHANNEL_INTERFACE,
+                               {"Requested": lambda: self._requested}
+                       )
                except TypeError:
                        # HACK Newer python-telepathy way
                        telepathy.server.ChannelTypeText.__init__(self, connection, manager, props)
@@ -59,6 +63,22 @@ class TextChannel(telepathy.server.ChannelTypeText):
                else:
                        self._report_conversation(mergedConversations)
 
+       def get_props(self):
+               # HACK Older python-telepathy doesn't provide this
+               _immutable_properties = {
+                       'ChannelType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandle': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Interfaces': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetHandleType': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'TargetID': telepathy.server.interfaces.CHANNEL_INTERFACE,
+                       'Requested': telepathy.server.interfaces.CHANNEL_INTERFACE
+               }
+               props = dict()
+               for prop, iface in _immutable_properties.items():
+                       props[iface + '.' + prop] = \
+                               self._prop_getters[iface][prop]()
+               return props
+
        @gtk_toolbox.log_exception(_moduleLogger)
        def Send(self, messageType, text):
                if messageType != telepathy.CHANNEL_TEXT_MESSAGE_TYPE_NORMAL:
index 1f01726..18b682e 100644 (file)
@@ -70,6 +70,7 @@ class TelepathyChannelManager(object):
                        self._conn.add_channels([chan], signal=signal)
                elif hasattr(self._conn, "add_channel"):
                        # HACK Older python-telepathy
+                       self._conn.NewChannels([(chan._object_path, chan.get_props())])
                        self._conn.add_channel(chan, handle, suppress_handler)
                else:
                        raise RuntimeError("Uhh, what just happened with the connection")