Maksim Melnikau aka “max_posedon” - Telepathy protocol example

419 views

Published on

Доклад Максима Мельникова на январской линуксовке MLUG 2013

0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
419
On SlideShare
0
From Embeds
0
Number of Embeds
2
Actions
Shares
0
Downloads
4
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Maksim Melnikau aka “max_posedon” - Telepathy protocol example

  1. 1. Telepathy Echo Protocol Example Maksim Melnikau (max posedon) Linux Mobile hobbyist World of Tanks developer January 26, 2013
  2. 2. Let’s start python gobject telepathy telepathy-python telepathy-foo DBusGMainLoop(set_as_default=True) FooConnectionManager() MainLoop().run()
  3. 3. org.freedesktop.Telepathy.Protocol Properties EnglishName Parameters VCardField Icon
  4. 4. 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)
  5. 5. org.freedesktop.Telepathy.ConnectionManager Methods GetParameters ListProtocols RequestConnection Signals NewConnections Properties Protocols Interfaceds
  6. 6. class FooConnectionManager foo/connection manager.py class FooConnectionManager: def __init__(self): self._implement_protocol(PROTOCOL, FooProtocol)
  7. 7. org.freedesktop.Telepathy.Connection Methods Connect Disconnect Properties Status Interfaces Signals StatusChanged
  8. 8. org.freedesktop.Telepathy.Connection.Interface.Contacts Methods GetContactAttributes Properties ContactAttributeInterfaces
  9. 9. org.freedesktop.Telepathy.Connection.Interface.Requests Methods CreateChannel Properties Channels RequestableChannelClasses
  10. 10. 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
  11. 11. org.freedesktop.Telepathy.Channel Properties ChannelType Interfaces
  12. 12. 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)
  13. 13. org.freedesktop.Telepathy.Channel.Type.Text Methods AcknowledgePendingMessages
  14. 14. org.freedesktop.Telepathy.Channel.Interface.Messages Methods SendMessage Signals MessageSent MessageReceived Properties SupportedContentType PendingMessages
  15. 15. 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)
  16. 16. Contact List
  17. 17. Chat
  18. 18. More Info email: maxposedon@gmail.com https://github.com/max-posedon/telepathy-foo https://github.com/max-posedon/telepathy-python https://github.com/max-posedon/talk-telepathy-echo

×