All pastes #68509 Raw Edit

Miscellany

public text v1 · immutable
#68509 ·published 2006-06-21 18:17 UTC
rendered paste body
[badger ChannelHandler (PEP-8 age, try to make StreamedMedia channels work)
dafydd.harries@collabora.co.uk**20060531232719] {
hunk ./cohoba/telepathy/ChannelHandler.py 5
-from cohoba.telepathy.Constants import CONNECTION_HANDLE_TYPE_LIST, CONNECTION_HANDLE_TYPE_CONTACT, CONNECTION_HANDLE_TYPE_NONE
+from cohoba.telepathy.Constants import (
+       CONNECTION_HANDLE_TYPE_LIST, CONNECTION_HANDLE_TYPE_CONTACT,
+       CONNECTION_HANDLE_TYPE_NONE)
hunk ./cohoba/telepathy/ChannelHandler.py 11
+CT_CONTACT_LIST = "org.freedesktop.Telepathy.Channel.Type.ContactList"
+CT_STREAMED_MEDIA = "org.freedesktop.Telepathy.Channel.Type.StreamedMedia"
+CT_TEXT = "org.freedesktop.Telepathy.Channel.Type.Text"
+
hunk ./cohoba/telepathy/ChannelHandler.py 18
-^I$
+
hunk ./cohoba/telepathy/ChannelHandler.py 30
-               #get_proxy_provider().create_proxy("org.freedesktop.Telepathy.VoipEngine", "/org/freedesktop/Telepathy/VoipEngine")
-               #self.voip_engine_iface = get_proxy_provider().get_iface("/org/freedesktop/Telepathy/VoipEngine", "org.freedesktop.Telepathy.ChannelHandler")
+               #get_proxy_provider().create_proxy(
+               #       "org.freedesktop.Telepathy.VoipEngine",
+               #       "/org/freedesktop/Telepathy/VoipEngine")
+               #self.voip_engine_iface = get_proxy_provider().get_iface(
+               #       "/org/freedesktop/Telepathy/VoipEngine",
+               #       "org.freedesktop.Telepathy.ChannelHandler")
hunk ./cohoba/telepathy/ChannelHandler.py 40
-^I^I^I$
+
+       def request_channel(self, conn_path, type, handle_type, handle,
+                       suppress_handler, **args):
+
+               if 'reply_handler' not in args:
+                       args['reply_handler'] = lambda *args: None
+
+               if 'error_handler' not in args:
+                       args['error_handler'] = global_error_handler
+
+               conn_iface = get_proxy_provider().get_iface(conn_path,
+                       'org.freedesktop.Telepathy.Connection')
+               return conn_iface.RequestChannel(type, handle_type, handle,
+                       suppress_handler, **args)
+
hunk ./cohoba/telepathy/ChannelHandler.py 57
-                       get_conversation_window_manager().show_existing(contact.conn_path, contact.handle)
+                       get_conversation_window_manager().show_existing(contact.conn_path,
+                               contact.handle)
hunk ./cohoba/telepathy/ChannelHandler.py 60
-                       conn_iface = get_proxy_provider().get_iface(contact.conn_path, 'org.freedesktop.Telepathy.Connection')
-                       conn_iface.RequestChannel("org.freedesktop.Telepathy.Channel.Type.Text", CONNECTION_HANDLE_TYPE_CONTACT, contact.handle, False,
-                               reply_handler=lambda *args: None, error_handler=global_error_handler)
-^I$
-       def start_media(self, contact):
-               #conn_iface = get_proxy_provider().get_iface(contact.conn_path, 'org.freedesktop.Telepathy.Connection')
-               #conn_iface.RequestChannel("org.freedesktop.Telepathy.Channel.Type.StreamedMedia", CONNECTION_HANDLE_TYPE_CONTACT, contact.handle, False,
-               #               reply_handler=lambda *args: None, error_handler=global_error_handler)
-               conn_iface = get_proxy_provider().get_iface(contact.conn_path, 'org.freedesktop.Telepathy.Connection')
-               obj = conn_iface.RequestChannel("org.freedesktop.Telepathy.Channel.Type.StreamedMedia", CONNECTION_HANDLE_TYPE_CONTACT, contact.handle, True)
-^I$
-               window = get_conversation_window_manager().show_existing(contact.handle)
-               media = TelepathyGroup(contact.conn_path, obj, 0)
+                       self.request_channel(
+                               contact.conn_path, CT_TEXT, CONNECTION_HANDLE_TYPE_CONTACT,
+                               contact.handle, False)
+
+       def _media_badger(self, channel, contact):
+               print channel
+               window = get_conversation_window_manager().show_existing(
+                       contact.conn_path, contact.handle)
+               print (contact.conn_path, channel)
+               media = TelepathyGroup(contact.conn_path, channel, 0)
hunk ./cohoba/telepathy/ChannelHandler.py 71
-^I^I^I$
-^I^I^I^I$
+
+       def start_media(self, contact):
+               #conn_iface = get_proxy_provider().get_iface(contact.conn_path,
+               #       'org.freedesktop.Telepathy.Connection')
+               #conn_iface.RequestChannel(
+               #       "org.freedesktop.Telepathy.Channel.Type.StreamedMedia",
+               #       CONNECTION_HANDLE_TYPE_CONTACT, contact.handle, False,
+               #       reply_handler=lambda *args: None, error_handler=global_error_handler)
+               print self, 'start_media!'
+               obj = self.request_channel(
+                       contact.conn_path, CT_STREAMED_MEDIA,
+                       CONNECTION_HANDLE_TYPE_CONTACT, contact.handle, True,
+                       reply_handler=lambda channel: self._media_badger(channel, contact))
+
+
hunk ./cohoba/telepathy/ChannelHandler.py 88
-^I^I$
+
hunk ./cohoba/telepathy/ChannelHandler.py 92
-^I^I$
+
hunk ./cohoba/telepathy/ChannelHandler.py 96
-^I^I^I$
+
hunk ./cohoba/telepathy/ChannelHandler.py 98
-                       account.conn_iface.connect_to_signal('NewChannel', lambda *args: self.on_new_channel(account, *args))
-                       account.conn_iface.ListChannels(reply_handler=lambda *args: self.on_list_channels(account, *args), error_handler=global_error_handler)
+                       account.conn_iface.connect_to_signal('NewChannel',
+                               lambda *args: self.on_new_channel(account, *args))
+                       account.conn_iface.ListChannels(reply_handler=
+                               lambda *args: self.on_list_channels(account, *args),
+                                       error_handler=global_error_handler)
hunk ./cohoba/telepathy/ChannelHandler.py 108
-^I^I^I$
-       def on_new_channel(self, account, chan_obj, chan_type, handle_type, handle, suppress_handler=False):
-               print 'New Channel: ', chan_obj, chan_type, handle_type, handle, suppress_handler
+
+       def on_new_channel(self, account, chan_obj, chan_type, handle_type,
+                       handle, suppress_handler=False):
+               print ('New Channel: ', chan_obj, chan_type, handle_type, handle,
+                       suppress_handler)
+
hunk ./cohoba/telepathy/ChannelHandler.py 115
-                       print '** Handler suppressed:', chan_obj, chan_type, handle_type, handle, suppress_handler
-                       return
-^I^I^I^I^I^I^I$
+                       print ('** Handler suppressed:', chan_obj, chan_type, handle_type,
+                               handle, suppress_handler)
+                       #return
+
hunk ./cohoba/telepathy/ChannelHandler.py 120
-^I^I$
-               name = None
+
hunk ./cohoba/telepathy/ChannelHandler.py 123
-^I^I^I$
-               if chan_type == 'org.freedesktop.Telepathy.Channel.Type.ContactList'and handle_type == CONNECTION_HANDLE_TYPE_LIST and name == "subscribe":
-                       get_contact_list().add_group(account.conn_obj_path, chan_obj, handle)
+               else:
+                       name = None
+
+               if (chan_type == CT_CONTACT_LIST and
+                               handle_type == CONNECTION_HANDLE_TYPE_LIST and
+                               name == "subscribe"):
+                       get_contact_list().add_group(account.conn_obj_path, chan_obj,
+                               handle)
hunk ./cohoba/telepathy/ChannelHandler.py 132
-^I^I^I$
-               elif chan_type == 'org.freedesktop.Telepathy.Channel.Type.Text' and handle_type == CONNECTION_HANDLE_TYPE_CONTACT:
-                       get_conversation_window_manager().show(account.conn_obj_path, chan_obj, handle)
+
+               elif (chan_type == CT_TEXT and
+                               handle_type == CONNECTION_HANDLE_TYPE_CONTACT):
+                       get_conversation_window_manager().show(
+                               account.conn_obj_path, chan_obj, handle)
hunk ./cohoba/telepathy/ChannelHandler.py 138
-^I^I$
-               elif chan_type == "org.freedesktop.Telepathy.Channel.Type.StreamedMedia":
-                       #window = get_conversation_window_manager().show_existing(handle)
-                       #media = TelepathyGroup(account.conn_obj_path, chan_obj, handle)
-                       #window.start_media(media)
-^I^I$
-                       #self.voip_engine_iface.HandleChannel(
-                       #       get_proxy_provider().get_service(account.conn_obj_path), account.conn_obj_path,
-                       #       chan_type, chan_obj,
-                       #       handle_type, handle,
-                       #       reply_handler=lambda: None, error_handler=global_error_handler)
-^I^I^I$
-                       #handled = True
-                       pass
-^I^I^I^I^I  $
+
+               elif chan_type == CT_STREAMED_MEDIA:
+                       window = get_conversation_window_manager().show_existing(
+                               account.conn_obj_path, handle)
+                       print (account.conn_obj_path, chan_obj, handle)
+                       media = TelepathyGroup(account.conn_obj_path, chan_obj, handle)
+                       window.start_media(media)
+
+                       self.voip_engine_iface.HandleChannel(
+                               get_proxy_provider().get_service(account.conn_obj_path),
+                                       account.conn_obj_path, chan_type, chan_obj, handle_type,
+                                       handle, reply_handler=lambda: None,
+                                       error_handler=global_error_handler)
+
+                       handled = True
+
hunk ./cohoba/telepathy/ChannelHandler.py 155
-                       print '** New Channel Not handled', chan_obj, chan_type, handle_type, handle, suppress_handler
+                       print ('** New Channel Not handled', chan_obj, chan_type,
+                               handle_type, handle, suppress_handler)
}