+ All Categories
Home > Technology > Maksim Melnikau aka “max_posedon” - Telepathy protocol example

Maksim Melnikau aka “max_posedon” - Telepathy protocol example

Date post: 05-Dec-2014
Category:
Upload: minsk-linux-user-group
View: 351 times
Download: 1 times
Share this document with a friend
Description:
Доклад Максима Мельникова на январской линуксовке MLUG 2013
18
Telepathy Echo Protocol Example Maksim Melnikau (max posedon) Linux Mobile hobbyist World of Tanks developer January 26, 2013
Transcript
Page 1: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

Telepathy Echo Protocol Example

Maksim Melnikau (max posedon)

Linux Mobile hobbyistWorld of Tanks developer

January 26, 2013

Page 2: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

Let’s start

I python

I gobject

I telepathy

I telepathy-python

telepathy-foo

DBusGMainLoop(set_as_default=True)

FooConnectionManager()

MainLoop().run()

Page 3: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.Protocol

Properties

I EnglishName

I Parameters

I VCardField

I Icon

Page 4: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

class Protocol

foo/protocol.py

class Protocol:

_proto = PROTOCOL

_english_name = PROTOCOL.capitalize()

_icon = "im-%s" % PROTOCOL

_vcard_field = "im-%s" % PROTOCOL

_mandatory_parameters = {’account’: ’s’}

def create_connection(self,

connection_manager, parameters):

return FooConnection(self,

connection_manager, parameters)

Page 5: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.ConnectionManager

Methods

I GetParameters

I ListProtocols

I RequestConnection

Signals

I NewConnections

Properties

I Protocols

I Interfaceds

Page 6: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

class FooConnectionManager

foo/connection manager.py

class FooConnectionManager:

def __init__(self):

self._implement_protocol(PROTOCOL, FooProtocol)

Page 7: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.Connection

Methods

I Connect

I Disconnect

Properties

I Status

I Interfaces

Signals

I StatusChanged

Page 8: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.Connection.Interface.Contacts

Methods

I GetContactAttributes

Properties

I ContactAttributeInterfaces

Page 9: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.Connection.Interface.Requests

Methods

I CreateChannel

Properties

I Channels

I RequestableChannelClasses

Page 10: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

class Connection

foo/connection.py

class FooConnection:

def Connect(self):

self.StatusChanged(CONNECTION_STATUS_CONNECTED,

CONNECTION_STATUS_REASON_REQUESTED)

def Disconnect(self):

self.StatusChanged(CONNECTION_STATUS_DISCONNECTED,

CONNECTION_STATUS_REASON_REQUESTED)

def GetContactListAttributes(self, interfaces, hold):

ret = Dictionary(signature=’ua{sv}’)

...

return ret

Page 11: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.Channel

Properties

I ChannelType

I Interfaces

Page 12: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

class FooChannelManager

foo/channel manager.py

class FooChannelManager:

def __init__(self, connection, protocol):

self.implement_channel_classes(CHANNEL_TYPE_TEXT,

self._get_text_channel)

def _get_text_channel(self, props):

self.__text_channel_id += 1

path = "TextChannel%d" % self.__text_channel_id

return FooTextChannel(self._conn,

self, props, object_path=path)

Page 13: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.Channel.Type.Text

Methods

I AcknowledgePendingMessages

Page 14: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

org.freedesktop.Telepathy.Channel.Interface.Messages

Methods

I SendMessage

Signals

I MessageSent

I MessageReceived

Properties

I SupportedContentType

I PendingMessages

Page 15: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

class FooTextChannel

foo/channel/text.py

class FooTextChannel:

def SendMessage(self, message, flags):

gobject.timeout_add(50, self._send_message,

message, flags, token)

def _send_message(self, message, flags, token):

self.MessageSent(message, flags, token)

gobject.timeout_add(50, self._message_received,

str(message[1][’content’]))

def _message_received(self, msg):

self.MessageReceived(message)

Page 16: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

Contact List

Page 17: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

Chat

Page 18: Maksim Melnikau aka “max_posedon” - Telepathy protocol example

More Info

I email: [email protected]

I https://github.com/max-posedon/telepathy-foo

I https://github.com/max-posedon/telepathy-python

I https://github.com/max-posedon/talk-telepathy-echo


Recommended