summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2011-03-26 21:12:27 +0200
committerLouis-Francis Ratté-Boulianne <louis-francis.ratte-boulianne@collabora.co.uk>2011-03-26 21:12:27 +0200
commit29b88200dff23c37e829b31d86142092841100fa (patch)
treed32fee01c9922f28403a0faac427bcf0644c9296
parentd48a2acec9af5dbe8c80325861fa16588ded793d (diff)
Revert "p2p: TLPv1 chunk size field might be 0 if chunk contains all blob data"
-rw-r--r--abin2041 -> 0 bytes
-rw-r--r--fbin2041 -> 0 bytes
-rw-r--r--lbin2041 -> 0 bytes
-rw-r--r--papyon/msnp2p/transport/TLPv1.py8
-rw-r--r--papyon/msnp2p/transport/default.py81
-rw-r--r--papyon/msnp2p/transport/nat_traversal.py123
-rw-r--r--papyon/tests/__init__.py0
-rw-r--r--papyon/tests/base.py151
-rw-r--r--papyon/tests/test_content_roaming.py59
-rw-r--r--papyon/tests/test_conversation.py129
-rw-r--r--papyon/tests/test_echo_server.py74
-rw-r--r--papyon/tests/test_file_transfer.py114
-rw-r--r--papyon/tests/test_ice.py259
-rw-r--r--papyon/tests/test_msn_object.py92
-rw-r--r--papyon/tests/test_offline_message_box.py93
-rw-r--r--papyon/tests/test_sdp.py168
-rw-r--r--papyon/tests/test_sip.py113
-rw-r--r--papyon/tests/test_sip_client.py95
-rw-r--r--papyon/tests/test_webcam.py144
-rw-r--r--test.gifbin5521 -> 0 bytes
20 files changed, 2 insertions, 1701 deletions
diff --git a/a b/a
deleted file mode 100644
index 9f4c892..0000000
--- a/a
+++ /dev/null
Binary files differ
diff --git a/f b/f
deleted file mode 100644
index 9f4c892..0000000
--- a/f
+++ /dev/null
Binary files differ
diff --git a/l b/l
deleted file mode 100644
index 9f4c892..0000000
--- a/l
+++ /dev/null
Binary files differ
diff --git a/papyon/msnp2p/transport/TLPv1.py b/papyon/msnp2p/transport/TLPv1.py
index e63caca..60cff0a 100644
--- a/papyon/msnp2p/transport/TLPv1.py
+++ b/papyon/msnp2p/transport/TLPv1.py
@@ -79,7 +79,7 @@ class TLPHeader(object):
self.dw2,
self.qw1)
- def parse(self, data, chunk_size):
+ def parse(self, data):
header = debug.hexify_string(data[:48])
try:
@@ -97,10 +97,6 @@ class TLPHeader(object):
self.dw2 = fields[7]
self.qw1 = fields[8]
- # if chunk is containing all blob data, chunk_size field might be 0
- if self.blob_size == chunk_size and self.chunk_size == 0:
- self.chunk_size = chunk_size
-
if self.blob_offset + self.chunk_size > self.blob_size:
raise TLPParseError(1, "chunk end exceeds blob size", header)
if self.blob_size >= 0 and self.chunk_size == 0:
@@ -254,7 +250,7 @@ class MessageChunk(object):
raise TLPParseError(1, "chunk should be at least 48 bytes")
header = TLPHeader()
- header.parse(data[:48], len(data) - 48)
+ header.parse(data[:48])
body = data[48:]
return MessageChunk(header, body)
diff --git a/papyon/msnp2p/transport/default.py b/papyon/msnp2p/transport/default.py
deleted file mode 100644
index b4bce5f..0000000
--- a/papyon/msnp2p/transport/default.py
+++ /dev/null
@@ -1,81 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from papyon.msnp2p.transport.base import BaseP2PTransport
-
-import gobject
-import logging
-
-__all__ = ['DefaultP2PTransport']
-
-logger = logging.getLogger('papyon.msnp2p.transport.default')
-
-
-class DefaultP2PTransport(BaseP2PTransport):
-
- def __init__(self, client, peer, peer_guid, transport_manager):
- self._peer = peer
- self._peer_guid = peer_guid
- BaseP2PTransport.__init__(self, transport_manager)
-
- @staticmethod
- def handle_peer(client, peer, peer_guid, transport_manager, **kwargs):
- return DefaultP2PTransport(client, peer, peer_guid, transport_manager)
-
- @property
- def name(self):
- return "default"
-
- @property
- def protocol(self):
- return "None"
-
- @property
- def peer(self):
- return self._peer
-
- @property
- def peer_guid(self):
- return self._peer_guid
-
- @property
- def connected(self):
- return True
-
- @property
- def rating(self):
- return 0
-
- @property
- def max_chunk_size(self):
- return 0
-
- def can_send(self, peer, peer_guid, blob):
- return (self._peer == peer and self._peer_guid == peer_guid)
-
- def _ready_to_send(self):
- return False
-
- def _send_chunk(self, peer, peer_guid, chunk):
- pass
-
- def __repr__(self):
- return '<DefaultP2PTransport peer="%s" guid="%s">' % \
- (self.peer.account, self.peer_guid)
diff --git a/papyon/msnp2p/transport/nat_traversal.py b/papyon/msnp2p/transport/nat_traversal.py
deleted file mode 100644
index 6dbe333..0000000
--- a/papyon/msnp2p/transport/nat_traversal.py
+++ /dev/null
@@ -1,123 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import socket
-
-class NATTraversal(object):
-
- def __init__(self):
- pass
-
- def _map_port(self):
- self._request_echo_server((self._on_echo_server_answered,),
- (self._on_echo_server_failed,))
-
- def _request_echo_server(self, callback, errback):
- transport = TCPClient("64.4.35.253", 7001)
- transport.connect("notify::status", self._on_echo_transport_status_changed)
- transport.connect("error", self._on_echo_transport_error)
- transport.connect("received", self._on_echo_transport_received)
- self._echo_transports[transport] = ([], callback, errback)
- transport.open()
-
- def _listen(self, local_ip, local_port):
- s = socket.socket()
- s.setblocking(False)
- s.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
- s.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
- s.bind(("", local_port))
- s.listen(1)
- channel = gobject.IOChannel(s.fileno())
- channel.set_flags(channel.get_flags() | gobject.IO_FLAG_NONBLOCK)
- channel.add_watch(gobject.IO_IN, self._on_listener)
- channel.add_watch(gobject.IO_HUP | gobject.IO_ERR, self._on_not_listener)
- self.t_s = s
- self.t_c = channel
-
- def _on_listener(self, channel, pspec):
- print "Punching listener connected"
- sock = self.t_s.accept()[0]
- sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
- print sock.getsockname()
- print sock.getpeername()
-
- def _on_not_listener(self, channel, condition):
- print condition
- print "Punching listener failed"
-
- def _on_echo_server_answered(self, local_ip, local_port, extern_ip,
- extern_port):
- self._transport_manager._update_transport_addresses(self,
- local_ip, local_port, extern_ip, extern_port)
- self.start_timeout("test", 1, local_ip, local_port, extern_ip,
- extern_port)
-
- def on_test_timeout(self, local_ip, local_port, extern_ip, extern_port):
- logger.info("Bind to port %i" % (local_port))
- self._transport.bind("", local_port)
- logger.info("Listen on %s:%i" % (local_ip, local_port))
- self._listen(local_ip, local_port)
- logger.info("Connect to %s(%i)" % (self._ip, self._port))
- self._transport._open(self._ip, self._port)
-
- def _on_echo_server_failed(self):
- logger.info("Connect to %s(%i)" % (self._ip, self._port))
- self._transport.open()
-
- def _on_echo_transport_status_changed(self, transport, param):
- status = transport.get_property("status")
- if status == IoStatus.OPEN:
- local_addr = transport.sockname
- logger.info("Sending echo server request (%s:%i)" % local_addr)
- tr_id = 12
- self._echo_requests[tr_id] = local_addr
- request = "\x02\x01\x41\x31\x41\x31\x41\x31\x00\x00\x00\x00\x00\x00\x00\x00\x5d\x00\x00\x00"
- transport.send(request)
-
- def _on_echo_transport_error(self, transport, error):
- pass #FIXME
-
- def _on_echo_transport_received(self, transport, data, length):
- if length != 20:
- print "length != 20"
- return
- fields = struct.unpack("!BBHIHHII", data)
- ver, code, port, ip, discard_port, test_port, test_ip, tr_id = fields
- port ^= 0x4131
- ip = socket.inet_ntoa(struct.pack("!I", ip ^ 0x41314131))
- logger.info("Received echo server answer (%s:%i)" % (ip, port))
- local_ip, local_port = self._echo_requests[12]
- handles, callback, errback = self._echo_transports[transport]
- for handle in handles:
- transport.disconnect(handle)
- del self._echo_requests[12]
- del self._echo_transports[transport]
- transport.close()
- gobject.idle_add(self._dispose_faulty_transport, transport)
- callback[0](local_ip, local_port, ip, port, *callback[1:])
-
-class NATDetectionService(NATTraversalService):
-
- def __init__(self):
- NATTraversalService.__init__(self)
-
- def detect_nat_type(self):
- #http://miranda.googlecode.com/svn/trunk/miranda/protocols/MSN/msn_natdetect.cpp
- pass
diff --git a/papyon/tests/__init__.py b/papyon/tests/__init__.py
deleted file mode 100644
index e69de29..0000000
--- a/papyon/tests/__init__.py
+++ /dev/null
diff --git a/papyon/tests/base.py b/papyon/tests/base.py
deleted file mode 100644
index 32fb5aa..0000000
--- a/papyon/tests/base.py
+++ /dev/null
@@ -1,151 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import getpass
-import gobject
-import logging
-import optparse
-import signal
-import sys
-import time
-import unittest
-
-sys.path.insert(0, "")
-
-import papyon
-
-def parse_args(opts, args):
- usage = "%prog [options] " + " ".join(map(lambda x: x[0], args))
- version = "%prog " + ".".join(map(lambda x: str(x), papyon.version))
-
- parser = optparse.OptionParser(usage, version=version)
- for short_name, long_name, kwargs in opts:
- parser.add_option(short_name, long_name, **kwargs)
- (options, arguments) = parser.parse_args()
-
- values = {}
- for i in range(len(args)):
- name, type = args[i]
- display_name = name.capitalize() + ': '
- if len(arguments) <= i:
- if type == "pass":
- value = getpass.getpass(display_name)
- elif type == "string":
- value = raw_input(display_name)
- elif type == "list":
- value = raw_input(display_name).split()
- else:
- value = input(display_name)
- else:
- value = arguments[i]
- if type == "list":
- value = arguments[i:]
- elif type not in ("pass", "string"):
- value = eval(value)
- values[name] = value
-
- return options, values
-
-
-def get_proxies():
- import urllib
- proxies = urllib.getproxies()
- result = {}
- if 'https' not in proxies and \
- 'http' in proxies:
- url = proxies['http'].replace("http://", "https://")
- result['https'] = papyon.Proxy(url)
- for type, url in proxies.items():
- if type == 'no': continue
- if type == 'https' and url.startswith('http://'):
- url = url.replace('http://', 'https://', 1)
- result[type] = papyon.Proxy(url)
- return result
-
-
-class TestClientEvents(papyon.event.ClientEventInterface,
- papyon.event.InviteEventInterface):
-
- def __init__(self, client):
- papyon.event.ClientEventInterface.__init__(self, client)
- papyon.event.InviteEventInterface.__init__(self, client)
-
- def on_client_state_changed(self, state):
- if state == papyon.event.ClientState.CLOSED:
- self._client.quit()
- elif state == papyon.event.ClientState.OPEN:
- self._client.connected()
-
- def on_client_error(self, type, error):
- print "ERROR %s -> %s" % (type, error)
-
-
-class TestClient(papyon.Client):
-
- def __init__(self, name, opts, args, event_handler_class=TestClientEvents):
- base_opts = [('-m', '--procotol', {'type': 'int', 'default': 18,
- 'dest': 'version',
- 'help': 'protocol version to use'}),
- ('-l', '--level', {'type': 'int', 'default': 0,
- 'help': 'logging level'}),
- ('-s', '--server', {'default': 'messenger.hotmail.com',
- 'help': 'live messenger server'}),
- ('-p', '--port', {'type': 'int', 'default': 1863,
- 'help': 'server port'}),
- ('-t', '--transport', {'type': 'choice', 'default': 'direct',
- 'choices': ('direct', 'http'),
- 'help': 'connection (direct or http)'})
- ]
- base_args = [('account', 'string'),
- ('password', 'pass')]
-
- self.name = name
- self.options, self.arguments = parse_args(base_opts + opts, base_args + args)
-
- logging.basicConfig(level=self.options.level)
-
- self.mainloop = gobject.MainLoop(is_running=True)
- signal.signal(signal.SIGTERM,
- lambda *args: gobject.idle_add(self.mainloop.quit()))
-
- transport_class = papyon.transport.DirectConnection
- if self.options.transport == 'http':
- transport_class = papyon.transport.HTTPPollConnection
-
- papyon.Client.__init__(self, (self.options.server, self.options.port),
- proxies=get_proxies(), transport_class=transport_class,
- version=self.options.version)
- self.event_handler = event_handler_class(self)
- gobject.idle_add(self.login, self.arguments['account'],
- self.arguments['password'])
-
- def run(self):
- while self.mainloop.is_running():
- try:
- self.mainloop.run()
- except KeyboardInterrupt:
- self.mainloop.quit()
-
- def quit(self):
- self.mainloop.quit()
-
- def connected(self):
- self.profile.display_name = "Paypon (%s)" % self.name
- self.profile.presence = papyon.Presence.ONLINE
diff --git a/papyon/tests/test_content_roaming.py b/papyon/tests/test_content_roaming.py
deleted file mode 100644
index 43d9eb1..0000000
--- a/papyon/tests/test_content_roaming.py
+++ /dev/null
@@ -1,59 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from base import *
-
-sys.path.insert(0, "")
-
-import papyon
-from papyon.service.ContentRoaming import *
-
-class ContentRoamingClient(TestClient):
-
- def __init__(self):
- opts = [("-a", "--action", {'type': 'choice', 'choices': ('get', 'put'),
- 'help': 'action: get or put',
- 'default': 'get'})]
- args = [("nickname", "string"),
- ("message", "string"),
- ("path", "string")]
- TestClient.__init__(self, "Content Roaming", opts, args)
-
- def connected(self):
- self._roaming.connect("notify::state",
- self.on_content_roaming_state_changed)
- self._roaming.sync()
-
- def on_content_roaming_state_changed(self, cr, pspec):
- if cr.state == ContentRoamingState.SYNCHRONIZED:
- path = self.arguments['path']
- if self.options.action == 'get':
- type, data = cr.display_picture
- f = open(path, 'w')
- f.write(data)
- elif self.options.action == 'put':
- f = open(path, 'r')
- cr.store(self.arguments['nickname'], self.arguments['message'],
- f.read())
-
-
-if __name__ == "__main__":
- client = ContentRoamingClient()
- client.run()
diff --git a/papyon/tests/test_conversation.py b/papyon/tests/test_conversation.py
deleted file mode 100644
index b40bdef..0000000
--- a/papyon/tests/test_conversation.py
+++ /dev/null
@@ -1,129 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from base import *
-
-sys.path.insert(0, "")
-
-import os
-import papyon
-
-class ConversationClient(TestClient):
-
- def __init__(self):
- opts = [('-S', '--send', {'type': 'string', 'default': '',
- 'help': 'send message to invited contacts'}),
- ('-n', '--nudge', {'action': 'store_true', 'default': False,
- 'help': 'send nudge to invited contacts'}),
- ('-e', '--echo', {'action': 'store_true', 'default': False,
- 'help': 'echo received messages'}),
- ('-r', '--repeat', {'action': 'store_true', 'default': False,
- 'help': 'repeat sent message every 2s'})
- ]
- args = [("participants", "list")]
- TestClient.__init__(self, "Conversation", opts, args,
- ConversationClientEvents)
-
- def connected(self):
- self.profile.presence = papyon.profile.Presence.ONLINE
-
- # parse and search participants for conversation
- contacts = []
- for account in self.arguments["participants"]:
- network = papyon.profile.NetworkID.MSN
- if ':' in account:
- account, network = account.split(":")
- network = int(network)
- contact = self.address_book.search_or_build_contact(account, network)
- contacts.append(contact)
-
- self._conversation = papyon.Conversation(self, contacts)
- self._conversation_handler = ConversationHandler(self, self._conversation)
- if self.options.send:
- gobject.timeout_add_seconds(2, self.send)
- if self.options.nudge:
- gobject.timeout_add_seconds(2, self.nudge)
-
- def send(self):
- message = papyon.ConversationMessage(self.options.send)
- self._conversation.send_text_message(message)
- return self.options.repeat
-
- def nudge(self):
- self._conversation.send_nudge()
- return self.options.repeat
-
-
-class ConversationClientEvents(TestClientEvents):
-
- def __init__(self, client):
- TestClientEvents.__init__(self, client)
-
- def on_invite_conversation(self, conversation):
- print "*** Received invite for conversation"
- self._conversation_handler = ConversationHandler(self._client,
- conversation)
-
-
-class ConversationHandler(papyon.event.ConversationEventInterface):
-
- def __init__(self, client, conversation):
- papyon.event.ConversationEventInterface.__init__(self, conversation)
- self._msn_client = client
-
- def on_conversation_state_changed(self, state):
- print "*** Conversation state changed to %s" % state
-
- def on_conversation_error(self, type, error):
- print "*** Conversation error: %s" % error
-
- def on_conversation_user_joined(self, contact):
- print "*** User %s joined conversation" % contact.account
-
- def on_conversation_user_left(self, contact):
- print "*** User %s left conversation" % contact.account
-
- def on_conversation_user_typing(self, contact):
- print "*** User %s is typing" % contact.account
-
- def on_conversation_message_received(self, sender, message):
- print "*** Received message from %s: %s" % (sender.account,
- message.content)
- if self._msn_client.options.echo:
- self._client.send_text_message(message)
-
- def on_conversation_nudge_received(self, sender):
- print "*** Received nudge from %s" % (sender.account)
- if self._msn_client.options.echo:
- self._client.send_nudge()
-
- def on_conversation_message_sent(self, message):
- print "*** Message has been sent"
-
- def on_conversation_nudge_sent(self):
- print "*** Nudge has been sent"
-
- def on_conversation_closed(self):
- print "*** Conversation has been closed"
-
-
-if __name__ == "__main__":
- client = ConversationClient()
- client.run()
diff --git a/papyon/tests/test_echo_server.py b/papyon/tests/test_echo_server.py
deleted file mode 100644
index fc62a8e..0000000
--- a/papyon/tests/test_echo_server.py
+++ /dev/null
@@ -1,74 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import gobject
-import logging
-import socket
-import struct
-import sys
-import time
-
-sys.path.insert(0, "")
-
-import papyon
-from papyon.transport import DirectConnection, HTTPPollConnection
-from papyon.gnet.constants import *
-from papyon.gnet.io.tcp import TCPClient
-
-class EchoClient(object):
-
- def __init__(self):
- self.transport = TCPClient("64.4.35.253", 7001)
- self.transport.connect("notify::status", self.on_status_changed)
- self.transport.connect("error", self.on_error)
- self.transport.connect("received", self.on_received)
- gobject.idle_add(self.open)
-
- def open(self):
- self.transport.open()
-
- def on_status_changed(self, transport, param):
- status = transport.get_property("status")
- print status
- if status == IoStatus.OPEN:
- print self.transport.sockname
- request = "\x02\x01\x41\x31\x41\x31\x41\x31\x00\x00\x00\x00\x00\x00\x00\x00\x5d\x00\x00\x00"
- self.transport.send(request)
-
- def on_error(self, transport, error):
- print "error", error
-
- def on_received(self, transport, data, lenght):
- fields = struct.unpack("!BBHIHHII", data)
- ver, code, port, ip, discard_port, test_port, test_ip, tr_id = fields
- port ^= 0x4131
- print repr(data)
- print ip
- ip ^= 0x41314131
- ip = socket.inet_ntoa(struct.pack("!I", ip))
- print ip, port
-
-if __name__ == "__main__":
-
- logging.basicConfig(level=0)
-
- mainloop = gobject.MainLoop(is_running=True)
- client = EchoClient()
- mainloop.run()
diff --git a/papyon/tests/test_file_transfer.py b/papyon/tests/test_file_transfer.py
deleted file mode 100644
index 78aaf2a..0000000
--- a/papyon/tests/test_file_transfer.py
+++ /dev/null
@@ -1,114 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from base import *
-
-sys.path.insert(0, "")
-
-import os
-import papyon
-
-class FileTransferClient(TestClient):
-
- def __init__(self):
- opts = [('-a', '--answer', {'type': 'choice', 'default': 'ignore',
- 'choices': ('ignore', 'accept', 'reject'),
- 'help': 'what to do on incoming file'}),
- ('-w', '--write', {'type': 'string', 'default': '',
- 'help': 'path to write received file'}),
- ('-S', '--send', {'type': 'string', 'nargs': 2,
- 'help': 'send file [recipient path]'})
- ]
- args = []
- TestClient.__init__(self, "File Transfer", opts, args,
- FileTransferClientEvents)
-
- def connected(self):
- self.profile.presence = papyon.profile.Presence.ONLINE
- if self.options.send:
- gobject.timeout_add_seconds(2, self.send)
-
- def send(self):
- recipient, path = self.options.send
-
- # get recipient
- contact = self.address_book.search_or_build_contact(recipient,
- papyon.profile.NetworkID.MSN)
-
- # get file details
- filename = os.path.basename(path)
- data = file(path, 'r')
- data.seek(0, os.SEEK_END)
- size = data.tell()
- data.seek(0, os.SEEK_SET)
-
- self._session = self.ft_manager.send(contact, filename, size, data)
- self._session_handler = FileTransferHandler(self._session)
-
- def accept(self, session):
- self._session = session
- self._session_handler = FileTransferHandler(session)
- buffer = None
- if self.options.write:
- buffer = file(self.options.write, 'w')
- session.accept(buffer)
-
-class FileTransferClientEvents(TestClientEvents):
-
- def __init__(self, client):
- TestClientEvents.__init__(self, client)
-
- def on_invite_file_transfer(self, session):
- print "** Invite for \"%s\" (%i bytes)" % (session.filename, session.size)
- if self._client.options.answer == 'accept':
- gobject.timeout_add_seconds(2, self._client.accept, session)
- elif self._client.options.answer == 'reject':
- session.reject()
-
-
-class FileTransferHandler(papyon.event.P2PSessionEventInterface):
-
- def __init__(self, session):
- papyon.event.P2PSessionEventInterface.__init__(self, session)
- self._transferred = 0
-
- def on_session_accepted(self):
- print "** Session has been accepted"
-
- def on_session_rejected(self):
- print "** Session has been rejected"
-
- def on_session_completed(self, data):
- print "** Session has been completed"
-
- def on_session_canceled(self):
- print "** Session has been canceled"
-
- def on_session_disposed(self):
- print "** Session has been disposed"
-
- def on_session_progressed(self, size):
- self._transferred += size
- print "** Received %i / %i" % (self._transferred, self._client.size)
-
-
-if __name__ == "__main__":
- client = FileTransferClient()
- client.run()
diff --git a/papyon/tests/test_ice.py b/papyon/tests/test_ice.py
deleted file mode 100644
index e3218a3..0000000
--- a/papyon/tests/test_ice.py
+++ /dev/null
@@ -1,259 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2009 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import sys
-import unittest
-
-audio_candidates19 = [
-(("1", 1, "UDP", 2013266431, "192.168.1.107", 54751, "host", None, None),
-"1 1 UDP 2013266431 192.168.1.107 54751 typ host"),
-(("3", 1, "UDP", 1677721855, "70.25.46.249", 54751, "srflx", "192.168.1.107", 54751),
-"3 1 UDP 1677721855 70.25.46.249 54751 typ srflx raddr 192.168.1.107 rport 54751"),
-(("4", 1, "UDP", 1006633215, "64.4.35.48", 30797, "relay", "192.168.1.107", 54751),
-"4 1 UDP 1006633215 64.4.35.48 30797 typ relay raddr 192.168.1.107 rport 54751"),
-(("1", 2, "UDP", 2013266430, "192.168.1.107", 49259, "host", None, None),
-"1 2 UDP 2013266430 192.168.1.107 49259 typ host"),
-(("3", 2, "UDP", 1677721854, "70.25.46.249", 49259, "srflx", "192.168.1.107", 49259),
-"3 2 UDP 1677721854 70.25.46.249 49259 typ srflx raddr 192.168.1.107 rport 49259"),
-(("4", 2, "UDP", 1006633214, "64.4.35.48", 45694, "relay", "192.168.1.107", 49259),
-"4 2 UDP 1006633214 64.4.35.48 45694 typ relay raddr 192.168.1.107 rport 49259")]
-
-video_candidates19 = [
-(("2", 1, "UDP", 2013266431, "192.168.1.116", 52826, "host", None, None),
-"2 1 UDP 2013266431 192.168.1.116 52826 typ host"),
-(("5", 1, "UDP", 1677721855, "69.70.191.106", 52826, "srflx", "192.168.1.116", 52826),
-"5 1 UDP 1677721855 69.70.191.106 52826 typ srflx raddr 192.168.1.116 rport 52826"),
-(("2", 2, "UDP", 2013266430, "192.168.1.116", 37649, "host", None, None),
-"2 2 UDP 2013266430 192.168.1.116 37649 typ host"),
-(("5", 2, "UDP", 1677721854, "69.70.191.106", 37649, "srflx", "192.168.1.116", 37649),
-"5 2 UDP 1677721854 69.70.191.106 37649 typ srflx raddr 192.168.1.116 rport 37649")]
-
-audio_candidates6 = [
-(("gAH6Rj7UAhyhL37x1myyRCEe0s90i/okTPPlQ8q9Ufg=", 1,
- "AT6jQtrWTfVi7S1Ko4pBxA==", "UDP", 0.830, "192.168.1.107", 54183),
-"gAH6Rj7UAhyhL37x1myyRCEe0s90i/okTPPlQ8q9Ufg= 1 AT6jQtrWTfVi7S1Ko4pBxA== UDP 0.830 192.168.1.107 54183"),
-(("wknsOPNTNLvDhc7jX+qIKK/1YwcG+8uifjfo21ridEM=", 1,
- "wWRgVlW33BSPYwEZrsFwFg==", "UDP", 0.550, "70.25.46.249", 54183),
-"wknsOPNTNLvDhc7jX+qIKK/1YwcG+8uifjfo21ridEM= 1 wWRgVlW33BSPYwEZrsFwFg== UDP 0.550 70.25.46.249 54183"),
-(("AHx6YkMxxV4F4diHF2o/wi6PF3hK8UPg/veO1nkC8CY=", 1,
- "iVxzBYjmxFxOHI4e3ZMq6A==", "UDP", 0.450, "64.4.34.204", 32594),
-"AHx6YkMxxV4F4diHF2o/wi6PF3hK8UPg/veO1nkC8CY= 1 iVxzBYjmxFxOHI4e3ZMq6A== UDP 0.450 64.4.34.204 32594"),
-(("gAH6Rj7UAhyhL37x1myyRCEe0s90i/okTPPlQ8q9Ufg=", 2,
- "AT6jQtrWTfVi7S1Ko4pBxA==", "UDP", 0.830, "192.168.1.107", 43701),
-"gAH6Rj7UAhyhL37x1myyRCEe0s90i/okTPPlQ8q9Ufg= 2 AT6jQtrWTfVi7S1Ko4pBxA== UDP 0.830 192.168.1.107 43701"),
-(("wknsOPNTNLvDhc7jX+qIKK/1YwcG+8uifjfo21ridEM=", 2,
- "wWRgVlW33BSPYwEZrsFwFg==", "UDP", 0.550, "70.25.46.249", 43701),
-"wknsOPNTNLvDhc7jX+qIKK/1YwcG+8uifjfo21ridEM= 2 wWRgVlW33BSPYwEZrsFwFg== UDP 0.550 70.25.46.249 43701"),
-(("AHx6YkMxxV4F4diHF2o/wi6PF3hK8UPg/veO1nkC8CY=", 2,
- "iVxzBYjmxFxOHI4e3ZMq6A==", "UDP", 0.450, "64.4.34.204", 56585),
-"AHx6YkMxxV4F4diHF2o/wi6PF3hK8UPg/veO1nkC8CY= 2 iVxzBYjmxFxOHI4e3ZMq6A== UDP 0.450 64.4.34.204 56585")]
-
-audio_codecs = [((8, "PCMA", 8000, None), "8 PCMA/8000", ""),
- ((0, "PCMU", 8000, None), "0 PCMU/8000", ""),
- ((101, "telephone-event", 8000, "0-16"),
- "101 telephone-event/8000", "101 0-16")]
-
-video_codecs = [((34, "H263", 90000, None), "34 H263/90000", "")]
-
-audio_msg19 = """v=0
-o=- 0 0 IN IP4 64.4.34.205
-s=session
-b=CT:99980
-t=0 0
-m=audio 42821 RTP/AVP 8 0 101
-c=IN IP4 64.4.34.205
-a=ice-ufrag:kZ+J
-a=ice-pwd:LFlH+neJ0CmUG/Vm1inOCJ
-a=candidate:1 1 UDP 2013266431 192.168.1.107 54751 typ host
-a=candidate:3 1 UDP 1677721855 70.25.46.249 54751 typ srflx raddr 192.168.1.107 rport 54751
-a=candidate:4 1 UDP 1006633215 64.4.35.48 30797 typ relay raddr 192.168.1.107 rport 54751
-a=candidate:1 2 UDP 2013266430 192.168.1.107 49259 typ host
-a=candidate:3 2 UDP 1677721854 70.25.46.249 49259 typ srflx raddr 192.168.1.107 rport 49259
-a=candidate:4 2 UDP 1006633214 64.4.35.48 45694 typ relay raddr 192.168.1.107 rport 49259
-a=rtcp:41965
-a=rtpmap:8 PCMA/8000
-a=rtpmap:0 PCMU/8000
-a=rtpmap:101 telephone-event/8000
-a=fmtp:101 0-16
-a=encryption:rejected"""
-
-video_msg19 = """m=video 52826 RTP/AVP 34
-c=IN IP4 192.168.1.116
-a=x-caps:34 65537:352:288:15.0:256000:1;131074:176:144:15.0:180000:1
-a=ice-ufrag:JjzZ
-a=ice-pwd:lfQttyfZ3SicOvs1WC2del
-a=candidate:2 1 UDP 2013266431 192.168.1.116 52826 typ host
-a=candidate:5 1 UDP 1677721855 69.70.191.106 52826 typ srflx raddr 192.168.1.116 rport 52826
-a=candidate:2 2 UDP 2013266430 192.168.1.116 37649 typ host
-a=candidate:5 2 UDP 1677721854 69.70.191.106 37649 typ srflx raddr 192.168.1.116 rport 37649
-a=rtcp:37649
-a=rtpmap:34 H263/90000
-a=encryption:rejected"""
-
-
-def createCandidate19(args):
- return ICECandidate(draft=19,
- foundation=args[0],
- component_id=args[1],
- transport=args[2],
- priority=args[3],
- ip=args[4],
- port=args[5],
- type=args[6],
- base_ip=args[7],
- base_port=args[8])
-
-def createCandidate6(args):
- return ICECandidate(draft=6,
- foundation=args[0][0:31],
- username=args[0],
- component_id=args[1],
- password=args[2],
- transport=args[3],
- priority=args[4],
- ip=args[5],
- port=args[6])
-
-class CandidateTestCase(unittest.TestCase):
-
- def testParse19(self):
- for args, line in audio_candidates19:
- candidate = ICECandidate(draft=19)
- candidate.parse(line)
- self.assertEqual(candidate, createCandidate19(args))
-
- def testBuildLocal19(self):
- for args, line in audio_candidates19:
- candidate = createCandidate19(args)
- print str(candidate)
-
- def testBuildParse19(self):
- for args, line in audio_candidates19:
- candidate = createCandidate19(args)
- line = str(candidate)
- candidate = ICECandidate(draft=19)
- candidate.parse(line)
- self.assertEqual(candidate, createCandidate19(args))
-
- def testParse6(self):
- for args, line in audio_candidates6:
- candidate = ICECandidate(draft=6)
- candidate.parse(line)
- self.assertEqual(candidate, createCandidate6(args))
-
- def testBuildLocal6(self):
- for args, line in audio_candidates6:
- candidate = createCandidate6(args)
- self.assertEqual(str(candidate), line)
-
- def testBuildParse6(self):
- for args, line in audio_candidates6:
- candidate = createCandidate6(args)
- line = str(candidate)
- candidate = ICECandidate(draft=6)
- candidate.parse(line)
- self.assertEqual(candidate, createCandidate6(args))
-
-
-class Session19TestCase(unittest.TestCase):
-
- def setUp(self):
- self.session = ICESession(draft=19)
- self.audio_candidates = []
- for args, line in audio_candidates19:
- candidate = createCandidate19(args)
- candidate.username = "kZ+J"
- candidate.password = "LFlH+neJ0CmUG/Vm1inOCJ"
- self.audio_candidates.append(candidate)
- self.video_candidates = []
- for args, line in video_candidates19:
- candidate = createCandidate19(args)
- candidate.username = "JjzZ"
- candidate.password = "lfQttyfZ3SicOvs1WC2del"
- self.video_candidates.append(candidate)
-
- self.audio_codecs = []
- for args, rtpmap, fmtp in audio_codecs:
- self.audio_codecs.append(SDPCodec(*args))
- self.video_codecs = []
- for args, rtpmap, fmtp in video_codecs:
- self.video_codecs.append(SDPCodec(*args))
-
- def testGetAudioRelay(self):
- self.session.set_local_candidates("audio", self.audio_candidates)
- relay = self.session.search_relay("audio")
- self.assertEqual(relay.foundation, '4')
-
- def testGetVideoRelay(self):
- self.session.set_local_candidates("video", self.video_candidates)
- relay = self.session.search_relay("video")
- self.assertEqual(relay.foundation, '5')
-
- def testParseSdpA(self):
- self.session.parse_sdp(audio_msg19)
- self.assertEqual(self.session.get_remote_codecs("audio"),
- self.audio_codecs)
- self.assertEqual(self.session.get_remote_candidates("audio"),
- self.audio_candidates)
-
- def testParseSdpAV(self):
- self.session.parse_sdp(audio_msg19 + "\r\n" + video_msg19)
- self.assertEqual(self.session.get_remote_codecs("audio"),
- self.audio_codecs)
- self.assertEqual(self.session.get_remote_candidates("audio"),
- self.audio_candidates)
- self.assertEqual(self.session.get_remote_codecs("video"),
- self.video_codecs)
- self.assertEqual(self.session.get_remote_candidates("video"),
- self.video_candidates)
-
- def testBuildParseSdpA(self):
- self.session.set_local_codecs("audio", self.audio_codecs)
- self.session.set_local_candidates("audio", self.audio_candidates)
- msg = self.session.build_sdp()
- self.session.parse_sdp(msg)
- self.assertEqual(self.session.get_remote_codecs("audio"),
- self.audio_codecs)
- self.assertEqual(self.session.get_remote_candidates("audio"),
- self.audio_candidates)
- self.assertEqual(self.session.get_remote_codecs("video"), [])
- self.assertEqual(self.session.get_remote_candidates("video"), [])
-
- def testBuildParseSdpAV(self):
- self.session.set_local_codecs("audio", self.audio_codecs)
- self.session.set_local_candidates("audio", self.audio_candidates)
- self.session.set_local_codecs("video", self.video_codecs)
- self.session.set_local_candidates("video", self.video_candidates)
- msg = self.session.build_sdp()
- self.session.parse_sdp(msg)
- self.assertEqual(self.session.get_remote_codecs("audio"),
- self.audio_codecs)
- self.assertEqual(self.session.get_remote_candidates("audio"),
- self.audio_candidates)
- self.assertEqual(self.session.get_remote_codecs("video"),
- self.video_codecs)
- self.assertEqual(self.session.get_remote_candidates("video"),
- self.video_candidates)
-
-
-if __name__ == "__main__":
- sys.path.insert(0, "")
- from papyon.sip.ice import *
- unittest.main()
diff --git a/papyon/tests/test_msn_object.py b/papyon/tests/test_msn_object.py
deleted file mode 100644
index 93d2cb9..0000000
--- a/papyon/tests/test_msn_object.py
+++ /dev/null
@@ -1,92 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from base import *
-
-sys.path.insert(0, "")
-
-import os
-import papyon
-import papyon.util.string_io as StringIO
-
-class MSNObjectClient(TestClient):
-
- def __init__(self):
- opts = [('-a', '--auto', {'action': 'store_true', 'default': False,
- 'help': 'auto-request new display pictures'}),
- ('-c', '--change', {'type': 'string', 'default': '',
- 'help': 'path for new display picture'}),
- ('-r', '--request', {'type': 'string', 'default': '',
- 'help': 'request display picture'}),
- ('-w', '--write', {'type': 'string', 'default': '',
- 'help': 'path to write received object'})
- ]
- args = []
- TestClient.__init__(self, "MSN Object", opts, args,
- MSNObjectClientEvents)
-
- def connected(self):
- self.profile.presence = papyon.profile.Presence.ONLINE
- self.profile.display_name = "Collabora1"
- if self.options.change:
- self.change()
- if self.options.request:
- gobject.timeout_add_seconds(2, self.request)
-
- def change(self):
- filename = os.path.basename(self.options.change)
- self._data = file(self.options.change, 'r').read()
- msn_object = papyon.p2p.MSNObject(self.profile, len(self._data),
- papyon.p2p.MSNObjectType.DISPLAY_PICTURE,
- filename, "", data=StringIO.StringIO(self._data))
- self.profile.msn_object = msn_object
-
- def request(self):
- recipient = self.options.request
- contact = self.address_book.search_or_build_contact(recipient,
- papyon.profile.NetworkID.MSN)
- self.msn_object_store.request(contact.msn_object, (self.retrieved,),
- peer=contact)
-
- def retrieved(self, msn_object):
- print "*** MSN Object has been retrieved"
- if self.options.write:
- f = file(self.options.write, 'w')
- f.write(msn_object._data)
- f.close()
-
-
-class MSNObjectClientEvents(TestClientEvents):
-
- def __init__(self, client):
- TestClientEvents.__init__(self, client)
-
- def on_profile_msn_object_changed(self):
- self.on_contact_msn_object_changed(self._client.profile)
-
- def on_contact_msn_object_changed(self, contact):
- if self._client.options.auto:
- self._client.msn_object_store.request(contact.msn_object, None,
- peer=contact)
-
-
-if __name__ == "__main__":
- client = MSNObjectClient()
- client.run()
diff --git a/papyon/tests/test_offline_message_box.py b/papyon/tests/test_offline_message_box.py
deleted file mode 100644
index 9d77815..0000000
--- a/papyon/tests/test_offline_message_box.py
+++ /dev/null
@@ -1,93 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from base import *
-
-sys.path.insert(0, "")
-
-import papyon
-
-class OIMClient(TestClient):
-
- def __init__(self):
- opts = [('-f', '--fetch', {'action': 'store_true', 'default': False,
- 'help': 'fetch message when receiving'}),
- ('-d', '--delete', {'action': 'store_true', 'default': False,
- 'help': 'delete message after fetching'}),
- ('-S', '--send', {'type': 'string', 'nargs': 2,
- 'help': 'send message [recipient message]'})
- ]
- args = []
- TestClient.__init__(self, "OIM", opts, args, OIMClientEvents)
-
- def connected(self):
- self.profile.presence = papyon.profile.Presence.ONLINE
-
- if self.options.send:
- gobject.timeout_add_seconds(2, self.send)
-
- def send(self):
- recipient, message = self.options.send
-
- contact = self.address_book.search_or_build_contact(recipient,
- papyon.profile.NetworkID.MSN)
- self.oim_box.send_message(contact, message)
-
-
-class OIMClientEvents(TestClientEvents,
- papyon.event.OfflineMessagesEventInterface):
-
- def __init__(self, client):
- TestClientEvents.__init__(self, client)
- papyon.event.OfflineMessagesEventInterface.__init__(self, client)
-
- def on_oim_messages_received(self, messages):
- for message in messages:
- if message.sender is None:
- continue
- print 'Received offline message from %s (%s)' % \
- (message.display_name, message.sender.account)
-
- if self._client.options.fetch:
- self._client.oim_box.fetch_messages(messages)
-
- def on_oim_messages_fetched(self, messages):
- for message in messages:
- if message.sender is None:
- continue
- print 'Fetched offline message from %s (%s)' % \
- (message.display_name, message.sender.account)
- print message.text
-
- if self._client.options.delete:
- self._client.oim_box.delete_messages(messages)
-
- def on_oim_messages_deleted(self, messages):
- for message in messages:
- if message.sender is None:
- continue
- print 'Deleted offline message from %s (%s)' % \
- (message.display_name, message.sender.account)
-
-
-if __name__ == "__main__":
- client = OIMClient()
- client.run()
-
diff --git a/papyon/tests/test_sdp.py b/papyon/tests/test_sdp.py
deleted file mode 100644
index 774fbd5..0000000
--- a/papyon/tests/test_sdp.py
+++ /dev/null
@@ -1,168 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2009 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import unittest
-import sys
-
-audio_definitions = [((8, "PCMA", 8000, None), "8 PCMA/8000", ""),
- ((0, "PCMU", 8000, None), "0 PCMU/8000", ""),
- ((101, "telephone-event", 8000, "0-16"),
- "101 telephone-event/8000", "101 0-16")]
-
-video_definitions = [((34, "H263", 90000, None), "34 H263/90000", "")]
-
-attributes = { "rtcp" : [42],
- "rtpmap" : ["8 PCMA/8000",
- "0 PCMU/8000",
- "101 telephone-event/8000"],
- "fmtp" : ["101 0-16"] }
-
-msg_audio = """v=0
-o=- 0 0 IN IP4 64.4.34.205
-s=session
-b=CT:99980
-t=0 0
-m=audio 42821 RTP/AVP 8 0 101
-c=IN IP4 64.4.34.205
-a=rtcp:41965
-a=rtpmap:8 PCMA/8000
-a=rtpmap:0 PCMU/8000
-a=rtpmap:101 telephone-event/8000
-a=fmtp:101 0-16
-a=encryption:rejected"""
-
-msg_video = """m=video 52826 RTP/AVP 34
-c=IN IP4 192.168.1.116
-a=x-caps:34 65537:352:288:15.0:256000:1;131074:176:144:15.0:180000:1
-a=rtcp:37649
-a=rtpmap:34 H263/90000
-a=encryption:rejected"""
-
-class CodecTestCase(unittest.TestCase):
-
- def testBuilding(self):
- for args, rtpmap, fmtp in audio_definitions:
- codec = SDPCodec(*args)
- self.assertEqual(codec.build_rtpmap(), rtpmap)
-
- def testParsing(self):
- for args, rtpmap, fmtp in audio_definitions:
- codec = SDPCodec()
- codec.parse_rtpmap(rtpmap)
- self.assertEqual(codec.payload, args[0])
- self.assertEqual(codec.encoding, args[1])
- self.assertEqual(codec.bitrate, args[2])
-
-class MediaTestCase(unittest.TestCase):
-
- def setUp(self):
- self.media = SDPMedia("audio")
- self.codecs = []
- for args, rtpmap, fmtp in audio_definitions:
- self.codecs.append(SDPCodec(*args))
-
- def testRtcpAssigned(self):
- self.media.rtcp = 42
- self.assertEqual(self.media.rtcp, 42)
-
- def testRtcpAssignedTwice(self):
- self.media.rtcp = 10
- self.media.rtcp = 11
- self.assertEqual(self.media.rtcp, 11)
-
- def testAttributeGetter(self):
- self.media.set_attribute("attr", "value")
- self.assertEqual(self.media.get_attribute("attr"), "value")
-
- def testAttributesGetter(self):
- self.media.add_attribute("list", 1)
- self.media.add_attribute("list", 2)
- self.assertEqual(self.media.get_attributes("list"), [1, 2])
-
- def testUnexistingAttribute(self):
- self.assertEqual(self.media.get_attribute("foo"), None)
-
- def testSetCodecs(self):
- self.media.codecs = self.codecs
- self.assertEqual(self.media.get_attributes("rtpmap"),
- attributes["rtpmap"])
- self.assertEqual(self.media.get_attributes("fmtp"),
- attributes["fmtp"])
-
- def testParseAttributes(self):
- self.media.payload_types = ['8', '0', '101']
- for key, values in attributes.iteritems():
- for value in values:
- self.media.parse_attribute(key, value)
- self.assertEqual(self.media.rtcp, 42)
- self.assertEqual(self.media.codecs, self.codecs)
-
- def testListPayloadTypes(self):
- self.media.codecs = self.codecs
- self.assertEqual(self.media.payload_types, ['8', '0', '101'])
-
-class MessageTestCase(unittest.TestCase):
-
- def setUp(self):
- self.message = SDPMessage()
- audio_codecs = []
- video_codecs = []
- for args, rtpmap, fmtp in audio_definitions:
- audio_codecs.append(SDPCodec(*args))
- for args, rtpmap, fmtp in video_definitions:
- video_codecs.append(SDPCodec(*args))
- self.audio = SDPMedia("audio", "64.4.34.205", 42821, 41965)
- self.audio.codecs = audio_codecs
- self.video = SDPMedia("video", "192.168.1.116", 52826, 37649)
- self.video.codecs = video_codecs
-
- def testParseMessageA(self):
- self.message.parse(msg_audio)
- medias = self.message.medias
- self.assertEqual(len(medias), 1)
- self.assertEqual(medias["audio"].ip, "64.4.34.205")
- self.assertEqual(medias["audio"].port, 42821)
- self.assertEqual(medias["audio"].rtcp, 41965)
-
- def testParseMessageAV(self):
- self.message.parse(msg_audio + "\r\n" + msg_video)
- medias = self.message.medias
- self.assertEqual(len(medias), 2)
- self.assertEqual(medias["audio"].ip, "64.4.34.205")
- self.assertEqual(medias["audio"].port, 42821)
- self.assertEqual(medias["audio"].rtcp, 41965)
- self.assertEqual(medias["video"].ip, "192.168.1.116")
- self.assertEqual(medias["video"].port, 52826)
- self.assertEqual(medias["video"].rtcp, 37649)
-
- def testBuildMessageA(self):
- self.message.medias["audio"] = self.audio
- print self.message
-
- def testBuildMessageAV(self):
- self.message.medias["audio"] = self.audio
- self.message.medias["video"] = self.video
- print self.message
-
-
-if __name__ == "__main__":
- sys.path.insert(0, "")
- from papyon.sip.sdp import *
- unittest.main()
diff --git a/papyon/tests/test_sip.py b/papyon/tests/test_sip.py
deleted file mode 100644
index 9d60781..0000000
--- a/papyon/tests/test_sip.py
+++ /dev/null
@@ -1,113 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2009 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import gobject
-import sys
-import unittest
-
-bye_request = """BYE sip:207.46.112.110:32829;transport=tls;ms-received-cid=B650C000 SIP/2.0
-Via: SIP/2.0/TLS 207.46.112.24:444;branch=z9hG4bK0E3C558B.765619AD;branched=TRUE;ms-internal-info="coETyDQoWCwZHL6jTa6sVdrgaboSl2VhmtzHQ35gAA"
-Max-Forwards: 69
-Content-Length: 0
-Via: SIP/2.0/TLS 127.0.0.1:50390;received=70.25.46.249;ms-received-port=46649;ms-received-cid=B650C600
-From: "0" <sip:louisfrancis.rb@gmail.com;wl-type=1>;tag=3df589cc60
-To: "0" <sip:louis-francis.ratte-boulianne@collabora.co.uk;wl-type=1>;tag=1c583a7f95;epid=0f33c63844
-Call-ID: d6c677ef1c9bcb62edf4cb7cd16d7780
-CSeq: 3 BYE
-User-Agent: aTSC/0.1
-Supported: ms-dialog-route-set-update
-
-"""
-
-bye_response = """SIP/2.0 200 OK
-v: SIP/2.0/TLS 207.46.112.24:444;branch=z9hG4bK0E3C558B.765619AD;branched=TRUE;ms-internal-info="coETyDQoWCwZHL6jTa6sVdrgaboSl2VhmtzHQ35gAA"
-v: SIP/2.0/TLS 127.0.0.1:50390;received=70.25.46.249;ms-received-port=46649;ms-received-cid=B650C600
-Max-Forwards: 70
-f: "0" <sip:louis-francis.ratte-boulianne@collabora.co.uk;wl-type=1>;tag=1c583a7f95;epid=0f33c63844
-t: "0" <sip:louisfrancis.rb@gmail.com>;tag=3df589cc60
-i: d6c677ef1c9bcb62edf4cb7cd16d7780
-CSeq: 1 BYE
-User-Agent: aTSC/0.1
-l: 0
-
-"""
-
-class MessageTestCase(unittest.TestCase):
-
- def setUp(self):
- self.ttl = Transport()
- self.parser = SIPMessageParser()
- self.message = None
- self.ttl.connect("line-received", self.parser.on_line_received)
-
- def testParseRequest(self):
- def verify(parser, msg, case):
- case.assertEqual(type(msg), SIPRequest)
- case.assertEqual(msg.code, "BYE")
- case.assertEqual(msg.get_header("User-Agent"), "aTSC/0.1")
-
- self.parser.connect("message-received", verify, self)
- self.ttl.receive(bye_request)
-
- def testParseResponse(self):
- def verify(parser, msg, case):
- case.assertEqual(type(msg), SIPResponse)
- case.assertEqual(msg.code, "BYE")
- case.assertEqual(msg.status, 200)
- case.assertEqual(msg.get_header("User-Agent"), "aTSC/0.1")
-
- self.parser.connect("message-received", verify, self)
- self.ttl.receive(bye_response)
-
- def testBuildParseRequest(self):
- def verify(parser, msg, case):
- case.assertEqual(type(msg), SIPRequest)
- case.assertEqual(msg.code, "BYE")
- case.assertEqual(msg.uri, "test@example.com")
- case.assertEqual(msg.get_header("User-Agent"), "aTSC/0.1")
-
- message = SIPRequest("BYE", "test@example.com")
- message.add_header("User-Agent", "aTSC/0.1")
- self.parser.connect("message-received", verify, self)
- self.ttl.receive(str(message))
-
-class Transport(gobject.GObject):
-
- __gsignals__ = {
- "line-sent": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ([object])),
- "line-received": (gobject.SIGNAL_RUN_LAST, gobject.TYPE_NONE, ([object]))
- }
-
- def __init__(self):
- gobject.GObject.__init__(self)
-
- def send(self, message):
- for line in message.splitlines():
- self.emit("line-sent", line)
-
- def receive(self, message):
- for line in message.splitlines():
- self.emit("line-received", line)
-
-
-if __name__ == "__main__":
- sys.path.insert(0, "")
- from papyon.sip.sip import *
- unittest.main()
diff --git a/papyon/tests/test_sip_client.py b/papyon/tests/test_sip_client.py
deleted file mode 100644
index bf09887..0000000
--- a/papyon/tests/test_sip_client.py
+++ /dev/null
@@ -1,95 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-from base import *
-
-sys.path.insert(0, "")
-
-import papyon
-from papyon.media.conference import *
-from papyon.media.constants import *
-
-class SIPClient(TestClient):
-
- def __init__(self):
- opts = [('-a', '--answer', {'type': 'choice', 'default': 'ignore',
- 'choices': ('ignore', 'accept', 'reject'),
- 'help': 'what to do on incoming call'}),
- ('-i', '--invite', {'type': 'string', 'default': '',
- 'help': 'peer to send call invite to'})
- ]
- args = []
- TestClient.__init__(self, "SIP Call", opts, args, SIPClientEvents)
-
- def connected(self):
- self.profile.presence = papyon.profile.Presence.ONLINE
- self.profile.client_capabilities.has_webcam = True
- self.profile.client_capabilities.supports_rtc_video = True
-
- if self.options.invite:
- gobject.timeout_add_seconds(2, self.invite)
-
- def invite(self):
- contact = self.address_book.search_contact(self.options.invite,
- papyon.profile.NetworkID.MSN)
-
- if contact is None:
- print 'Unknown contact: %s' % self.options.invite
- return False
-
- call = self.call_manager.create_call(contact)
- self.call_handler = CallEvents(call)
- self.session_handler = MediaSessionHandler(call.media_session)
- stream = call.media_session.create_stream("audio",
- MediaStreamDirection.BOTH, True)
- call.media_session.add_stream(stream)
- stream = call.media_session.create_stream("video",
- MediaStreamDirection.BOTH, True)
- call.media_session.add_stream(stream)
- call.invite()
-
- return False
-
-
-class SIPClientEvents(TestClientEvents):
-
- def __init__(self, client):
- TestClientEvents.__init__(self, client)
-
- def on_invite_conference(self, call):
- print "INVITED : call-id = %s" % call.id
- self.call_handler = CallEvents(call)
- self.session_handler = MediaSessionHandler(call.media_session)
- call.ring()
- if self._client.options.answer == 'accept':
- call.accept()
- elif self._client.options.answer == 'reject':
- call.reject()
-
-
-class CallEvents(papyon.event.CallEventInterface):
-
- def __init__(self, call):
- papyon.event.CallEventInterface.__init__(self, call)
-
-
-if __name__ == "__main__":
- client = SIPClient()
- client.run()
diff --git a/papyon/tests/test_webcam.py b/papyon/tests/test_webcam.py
deleted file mode 100644
index 13c133e..0000000
--- a/papyon/tests/test_webcam.py
+++ /dev/null
@@ -1,144 +0,0 @@
-# -*- coding: utf-8 -*-
-#
-# papyon - a python client library for Msn
-#
-# Copyright (C) 2010 Collabora Ltd.
-#
-# This program is free software; you can redistribute it and/or modify
-# it under the terms of the GNU General Public License as published by
-# the Free Software Foundation; either version 2 of the License, or
-# (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software
-# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
-
-import getpass
-import gobject
-import logging
-import sys
-import time
-import unittest
-
-sys.path.insert(0, "")
-
-import papyon
-from papyon.media.conference import *
-from papyon.media.constants import *
-from papyon.transport import HTTPPollConnection
-
-def get_proxies():
- import urllib
- proxies = urllib.getproxies()
- result = {}
- if 'https' not in proxies and \
- 'http' in proxies:
- url = proxies['http'].replace("http://", "https://")
- result['https'] = papyon.Proxy(url)
- for type, url in proxies.items():
- if type == 'no': continue
- if type == 'https' and url.startswith('http://'):
- url = url.replace('http://', 'https://', 1)
- result[type] = papyon.Proxy(url)
- return result
-
-class SIPClient(papyon.Client):
-
- def __init__(self, account, password, peer, producer, version):
- server = ('messenger.hotmail.com', 1863)
- papyon.Client.__init__(self, server, proxies = get_proxies(),
- version=version)
-
- self.peer = peer
- self.producer = producer
- self._event_handler = ClientEvents(self)
- gobject.idle_add(self.login, account, password)
-
- def invite(self):
- contact = self.address_book.contacts.search_by_account(self.peer)[0]
- call = self.webcam_handler.invite(contact, self.producer,
- (self.on_call_accepted,))
- return False
-
- def on_call_accepted(self, call):
- if producer:
- direction = MediaStreamDirection.SENDING
- else:
- direction = MediaStreamDirection.RECEIVING
-
- self.call_handler = CallEvents(call)
- self.session_handler = MediaSessionHandler(call.media_session)
- stream = call.media_session.create_stream("video", direction, True)
- call.media_session.add_stream(stream)
-
-
-class ClientEvents(papyon.event.ClientEventInterface,
- papyon.event.InviteEventInterface):
-
- def __init__(self, client):
- papyon.event.ClientEventInterface.__init__(self, client)
- papyon.event.InviteEventInterface.__init__(self, client)
-
- def on_client_state_changed(self, state):
- if state == papyon.event.ClientState.CLOSED:
- self._client.quit()
- elif state == papyon.event.ClientState.OPEN:
- self._client.profile.display_name = "Papyon (Webcam test)"
- self._client.profile.presence = papyon.Presence.ONLINE
- for contact in self._client.address_book.contacts:
- print contact
- gobject.timeout_add_seconds(2, self._client.invite)
-
- def on_invite_webcam(self, call, producer):
- self.call_handler = CallEvents(call)
- self.session_handler = MediaSessionHandler(call.media_session)
-
- def on_client_error(self, error_type, error):
- print "ERROR :", error_type, " ->", error
-
-
-class CallEvents(papyon.event.CallEventInterface):
-
- def __init__(self, call):
- papyon.event.CallEventInterface.__init__(self, call)
-
- def on_call_incoming(self):
- self._client.accept()
-
-if __name__ == "__main__":
-
- if len(sys.argv) < 2:
- version = int(raw_input('Version: '))
- else:
- version = int(sys.argv[1])
-
- if len(sys.argv) < 3:
- account = raw_input('Account: ')
- else:
- account = sys.argv[2]
-
- if len(sys.argv) < 4:
- password = getpass.getpass('Password: ')
- else:
- password = sys.argv[3]
-
- if len(sys.argv) < 5:
- invite = raw_input('Invite: ')
- else:
- invite = sys.argv[4]
-
- if len(sys.argv) < 6:
- producer = bool(raw_input('Producer [yes/no]: ') == 'yes')
- else:
- producer = bool(sys.argv[5] == 'yes')
-
- logging.basicConfig(level=0)
-
- mainloop = gobject.MainLoop(is_running=True)
- client = SIPClient(account, password, invite, producer, version)
- mainloop.run()
diff --git a/test.gif b/test.gif
deleted file mode 100644
index 5db98d9..0000000
--- a/test.gif
+++ /dev/null
Binary files differ