• No results found

Writing a IM/Voip client in 20 lines of python. Raphaël Slinckx

N/A
N/A
Protected

Academic year: 2021

Share "Writing a IM/Voip client in 20 lines of python. Raphaël Slinckx"

Copied!
84
0
0

Loading.... (view fulltext now)

Full text

(1)

Raphaël Slinckx

(2)
(3)
(4)

A good client only needs...

(5)

Link Local

A good client only needs...

(6)

Link Local

A good client only needs...

...a few simple things

File Transfer

(7)

Link Local

A good client only needs...

...a few simple things

File Transfer

Video Calls

(8)

Link Local

A good client only needs...

...a few simple things

File Transfer

Video Calls

(9)

Link Local

MSN

A good client only needs...

...a few simple things

OSCAR/AIM

File Transfer

Video Calls

(10)

Link Local

MSN

A good client only needs...

...a few simple things

Contact List

Presence

Smileys

OSCAR/AIM

File Transfer

Video Calls

NAT Traversal

(11)

Link Local

MSN

A good client only needs...

...a few simple things

Contact List

Presence

Smileys

OSCAR/AIM

File Transfer

SIP

Yahoo!

Video Calls

Voice Calls

NAT Traversal

Jabber

(12)

Link Local

MSN

A good client only needs...

...a few simple things

Contact List

Presence

Smileys

OSCAR/AIM

File Transfer

SIP

Yahoo!

Video Calls

Voice Calls

NAT Traversal

Jabber

Nudges!!

(13)

Each project

(14)

Each client

(15)

Telepathy

(16)
(17)
(18)
(19)

D-Bus

Chat UI

Logger

VoIP UI

SIP

Backend

Backend

XMPP

(20)

Telepathy

Chat UI

Logger

VoIP UI

SIP

Backend

Backend

XMPP

(21)
(22)
(23)

DBus

Connection

[email protected]

Desktop

Connections are shared

Abiword

Chat

(24)

Do one thing and do it well

Unix

(25)

Language independence

Keeps the programmers happy

(26)

Language independence

Keeps the programmers happy

License independence

Keeps the lawyers happy

(27)
(28)
(29)

XMPP

CM

CM

SIP

user@

gmail.com

contact@

jabber.org

+3212345

Connection

Managers

Connections

Channels

with foo@

Text

gmail.com

Text

with bar@

gmail.com

StreamedMedia

with

sip:[email protected]

Object hierarchy

(30)
(31)

Connection

(32)

Presence Interface

(33)

Capabilities Interface

(34)

Channels

(35)

Contact List Channel

Group Interface

(36)

Text Channel

Password Interface

(37)

StreamedMedia Channel

DTMF Interface

(38)
(39)

Connection Managers

Gabble

Salut

SIP

Idle

Jabber

XMPP

Link Local

XMPP

(bonjour)

(40)

Stream Engine

StreamedMedia Channel

Signalling

NAT Traversal

RTP Streaming

(41)

Libraries

telepathy-python

Implement CM and clients in python

libtelepathy

Implement clients in C+glib

telepathy-glib

Implement CM in C+glib

libempathy

Higher level objects to build clients

(42)
(43)

Desktop integration

(44)

XMPP

CM

CM

SIP

user@

gmail.com

contact@

jabber.org

+3212345

Connection

Managers

Connections

Channels

Text

with foo@

gmail.com

Text

with bar@

gmail.com

StreamedMedia

with

sip:[email protected]

(45)

XMPP

CM

CM

SIP

user@

gmail.com

contact@

jabber.org

+3212345

Connection

Managers

Connections

Channels

Text

with foo@

gmail.com

Text

with bar@

gmail.com

StreamedMedia

with

sip:[email protected]

Mission

Control

Mission

Control

(46)

Connection aggregation

(47)

Account management

Store account credentials centrally.

(48)

Channel dispatch

(49)

Desktop integration

(50)

Jabber-only

Gossip

(51)
(52)

Any Telepathy protocol

Gossip Telepathy

Monolithic

(53)
(54)
(55)

Any Telepathy protocol

Empathy

(56)
(57)

Same great UI.

(58)

Desktop integration

(59)

Jokosher Integration

Contacts as instruments

Live radio interviews with VoIP

(60)
(61)

VoIP/Video Widgets

Augment libempathy(-gtk) with

VoIP related widgets

(62)

File Transfer

Add link-local file transfer to empathy

(63)
(64)
(65)
(66)

Collaborative applications

(67)

If I can chat with a contact,

why can’t applications?

(68)

What’s a tube?

Arbitrary data exchange

Perform NAT traversal

(69)

D-Bus Tubes

Abiword

Abiword

Abiword

Abiword

“Virtual” D-Bus

Internet

GetText() GetText() GetText() GetText()
(70)

D-Bus Tubes

Abiword

Abiword

Abiword

Abiword

“Virtual” D-Bus

CM

CM

CM

CM

Protocol

Connections

P2P

D-Bus

P2P

D-Bus

P2P

D-Bus

P2P

D-Bus

(71)

Stream Tubes

VNC

Server

VNC

Viewer

VNC

Viewer

VNC

Viewer

“Virtual” TCP/UDP Connection

Internet

Socket

Socket

Socket

(72)

Stream Tubes

VNC

Server

VNC

Viewer

VNC

Viewer

VNC

Viewer

“Virtual” TCP/UDP Connection

CM

CM

CM

CM

Protocol

Connections

Socket Socket Socket Socket
(73)

Where to use Tubes?

(74)

Where to use Tubes?

If an application can be used through a D-Bus API

It can be shared by exposing the API on a D-Tube

(75)

Where to use Tubes?

If an application can be used through a D-Bus API

It can be shared by exposing the API on a D-Tube

(76)
(77)

Code Samples

libempathy

import gtk, empathy

def on_contact_notify(contact):

print "Alias:", contact.get_name()

print "Presence:", contact.get_status()

def on_contact_added(manager, contact):

contact.connect('notify', on_contact_notify)

manager = empathy.ContactManager() manager.setup()

manager.connect("contact-added", on_contact_added) contacts = manager.get_members()

for contact in contacts:

on_contact_added(manager, contact) gtk.main()

(78)

Code Samples

libempathy-gtk

import gtk, empathy, gtkempathy manager = empathy.ContactManager() manager.setup() store = gtkempathy.ContactListStore(manager) view = gtkempathy.ContactListView(store) view.show() w = gtk.Window() w.add(view) w.show() gtk.main()

(79)

Code Samples

libmission-control / Presence applet

import telepathy, dbus bus = dbus.Bus() mc = bus.get_object( 'org.freedesktop.Telepathy.MissionControl', '/org/freedesktop/Telepathy/MissionControl') mc_presence = dbus.Interface(mc, 'org.freedesktop.Telepathy.MissionControl') def on_presence_changed(presence):

print "Presence changed to:", presence

mc_presence.connect_to_signal("PresenceStatusActual",presence_changed) mc_presence.SetPresence(PRESENCE_AVAILABLE, "At GUADEC")

(80)

Code Samples

telepathy-python / VoIP and Video call

import telepathy, dbus bus = dbus.Bus()

reg = telepathy.client.ManagerRegistry() reg.LoadManagers()

mgr = reg.GetManager("gabble")

name, path = mgr[CONN_MGR_INTERFACE].RequestConnection(

"jabber", "[email protected]")

connection = telepathy.client.Connection(name, path) connection[CONN_INTERFACE].Connect()

contact = connection[CONN_INTERFACE].RequestHandles(

(81)

telepathy-python / VoIP and Video call

path = connection[CONN_INTERFACE].RequestChannel(

CHANNEL_TYPE_STREAMED_MEDIA, CONNECTION_HANDLE_TYPE_NONE, 0, True) channel = Channel(conn.service_name, path)

se = bus.get_object( 'org.freedesktop.Telepathy.StreamEngine', '/org/freedesktop/Telepathy/StreamEngine') se_handler = dbus.Interface(se, 'org.freedesktop.Telepathy.ChannelHandler' se_handler.HandleChannel( connection.service_name, connection.object_path, CHANNEL_TYPE_STREAMED_MEDIA, channel.object_path, CONNECTION_HANDLE_TYPE_NONE, 0) channel[CHANNEL_INTERFACE_GROUP].AddMembers([contact], "") channel[CHANNEL_TYPE_STREAMED_MEDIA].RequestStreams(

(82)

telepathy-python / VoIP and Video call

# When connected

connection[CONN_INTERFACE_CAPABILITIES].AdvertiseCapabilities(

[(CHANNEL_TYPE_STREAMED_MEDIA, CREATE|INVITE)], []) # On incoming channel of type StreamedMedia

pending = channel[CHANNEL_INTERFACE_GROUP].GetLocalPendingMembers() channel[CHANNEL_INTERFACE_GROUP].AddMembers(pending, "")

(83)

room = conn.RequestHandles( CONNECTION_HANDLE_TYPE_ROOM, ["[email protected]"])[0] tube = conn.request_channel( CHANNEL_TYPE_TUBES, CONNECTION_HANDLE_TYPE_ROOM, room, True) id = tube[CHANNEL_TYPE_TUBES].OfferTube( TUBE_TYPE_DBUS, "org.freedesktop.Telepathy.Tube.Connect4", {}) addr = tube[CHANNEL_TYPE_TUBES].GetDBusServerAddress(id) p2pbus = _dbus_bindings.Connection(addr)

Code Samples

telepathy-python / Tubes

(84)

References

Related documents

Keywords: Compact almost automorphic, mild solutions, semigroups of linear operators, semilinear differential equations, deviating argument, iterated deviating

The building materials used in chengam, Tiruvannamalidistrict has been measured for natural radioactivity concentration analysis using a NaI (Tl) detector based gamma

After background removal detection phase feature extraction has SIFT feature to detect the cars by using keypoint classification to eliminate more points from the list of

In this system, the Business logic layer is separated from other modules which are Data access layer and user interface (or presentation layer).. As a consequence, the

In the case of highly leveraged company ( i.e., having higher % of fixed cost to total cost ), the operating profit will increase at a faster rate for any

(Object based means; QTP Follows Test Object Model for Performing Testing operations. Based on either Test Objects or Automation Objects or Utility Objects only, we can automate

431787 431787 paizo com, Andrew Fields <neograyfox@gmail com>, Aug 13, 2009 ® ™ 683504 683504 431787 Conversion Guide paizo com, Andrew Fields <neograyfox@gmail com>, Aug 13, 2009

Considering the relatedness of the selected studies, as shown in the above table, each one of those studies are researched separately otherwise. First, the study on