[telepathy-ashes/master] Added auto-friend functionality. Broke the testsrc pipeline though.
David Laban (none)
dl325 at eee
Wed Sep 23 03:54:09 PDT 2009
---
ashes/tools/echo_bot.py | 73 +++++++++++++++++++++++++----------------------
1 files changed, 39 insertions(+), 34 deletions(-)
diff --git a/ashes/tools/echo_bot.py b/ashes/tools/echo_bot.py
index 608ef7d..26877c7 100644
--- a/ashes/tools/echo_bot.py
+++ b/ashes/tools/echo_bot.py
@@ -311,7 +311,7 @@ class PresenceEchoer(ConnectionListener):
new_message = self.identify(contact_string, message)
self.connection[self.PRESENCE].SetStatus({status: {'message': new_message}})
- at shiny.debug_class
+#@shiny.debug_class
class EchoBot( PresenceEchoer,
ChannelDispatcher,
Onlineifier,
@@ -392,7 +392,31 @@ class ChannelListener(ObjectListener):
@ChannelDispatcher.handler_for('org.freedesktop.Telepathy.Channel.Type.ContactList',
telepathy.HANDLE_TYPE_LIST)
class ContactAcceptor(ChannelListener):
- pass
+
+ def __init__(self, connection, channel, properties):
+ ChannelListener.__init__(self, connection, channel, properties)
+
+ channel_type = properties['org.freedesktop.Telepathy.Channel.ChannelType']
+ handle_type = properties['org.freedesktop.Telepathy.Channel.TargetHandleType']
+ handle = properties['org.freedesktop.Telepathy.Channel.TargetHandle']
+ requested = properties['org.freedesktop.Telepathy.Channel.Requested']
+ self.id = properties['org.freedesktop.Telepathy.Channel.TargetID']
+ print 'List Handled:', self.id
+
+ def MembersChanged(self, message, added, removed, local_pending, remote_pending,
+ actor, reason):
+ if added:
+ print "Members added to", self.id
+ if removed:
+ print "Members removed from", self.id
+ if local_pending:
+ print "Allowing members to join", self.id
+ self.channel[telepathy.CHANNEL_INTERFACE_GROUP].AddMembers(local_pending)
+ if remote_pending:
+ print 'members invited to', self.id
+
+ def MembersChangedDetailed(self, Added, Removed, Local_Pending, Remote_Pending, Details):
+ pass
@ChannelDispatcher.handler_for('org.freedesktop.Telepathy.Channel.Type.Text',
telepathy.HANDLE_TYPE_CONTACT)
@@ -404,6 +428,9 @@ class TextChannelEchoer(ChannelListener):
ChannelListener.__init__(self, connection, channel, properties)
self.contact_string = properties['org.freedesktop.Telepathy.Channel.TargetID']
print green('Text Channel Handled.')
+ messages = self.channel[telepathy.CHANNEL_TYPE_TEXT].ListPendingMessages(False)
+ for message in messages:
+ self.Received(*message)
#FIXME: uses a different signture to presenceechoer.identify.
@@ -417,8 +444,9 @@ class TextChannelEchoer(ChannelListener):
def Received(self, id, timestamp, sender, type, flags, text):
"""Handles Channel.Type.Text.Received() and sends it back."""
message = self.identify(timestamp, text)
+ print 'message received:', message
self.channel[telepathy.CHANNEL_TYPE_TEXT].Send(type, message)
-
+ self.channel[telepathy.CHANNEL_TYPE_TEXT].AcknowledgePendingMessages([id])
@ChannelDispatcher.handler_for('org.freedesktop.Telepathy.Channel.Type.StreamedMedia',
@@ -462,49 +490,26 @@ class MediaChannelEchoer(ChannelListener):
self.tfchannel.bus_message(message)
return True
- def src_pad_added(self, stream, pad, codec):
+ def src_pad_added(self, stream, srcpad, codec):
"""
- Connects up incoming media to the speakers/screen.
- Actually just hacked it to throw away all incoming data.
+ Connects up incoming media to the outgoing media pad.
"""
- type = stream.get_property ("media-type")
- if type == farsight.MEDIA_TYPE_AUDIO:
- sink = gst.parse_bin_from_description("audioconvert ! audioresample ! audioconvert ! autoaudiosink", True)
- elif type == farsight.MEDIA_TYPE_VIDEO:
- sink = gst.parse_bin_from_description("ffmpegcolorspace ! videoscale ! autovideosink", True)
+ sinkpad = stream.get_property("sink-pad")
+ print repr(srcpad)
+ print repr(sinkpad)
+ print dir(srcpad)
- self.pipeline.add(sink)
- pad.link(sink.get_pad("sink"))
- sink.set_state(gst.STATE_PLAYING)
+ srcpad.link(sinkpad)
+ sinkpad.set_state(gst.STATE_PLAYING)
def stream_created(self, channel, stream):
"""
connects (audio|video)testsrc to the input of the stream, and sets up
self.src_pad_added to handle incoming media pads.
- Note that there is a delay before adding the audio.
- This is to avoid a race condition in gabble.
"""
stream.connect("src-pad-added", self.src_pad_added)
- gobject.timeout_add(1000, self.do_test_sound, stream)
-
-
- def do_test_sound(self, stream):
print '#'*500
print green('Sending test sound/video')
- srcpad = stream.get_property("sink-pad")
-
- type = stream.get_property ("media-type")
-
- if type == farsight.MEDIA_TYPE_AUDIO:
- src = gst.element_factory_make("audiotestsrc")
- src.set_property("is-live", True)
- elif type == farsight.MEDIA_TYPE_VIDEO:
- src = gst.element_factory_make("videotestsrc")
- src.set_property("is-live", True)
-
- self.pipeline.add(src)
- src.get_pad("src").link(srcpad)
- src.set_state(gst.STATE_PLAYING)
def session_created(self, channel, conference, participant):
"""
--
1.5.6.5
More information about the telepathy-commits
mailing list