Port to TelepathyGLib
Tested on Fedora 18.
James Cameron authored 5 years ago
Rahul Bothra committed 5 years ago
31 | 31 | import gi |
32 | 32 | gi.require_version('Gtk', '3.0') |
33 | 33 | gi.require_version('Gst', '1.0') |
34 | gi.require_version('TelepathyGLib', '0.12') | |
34 | 35 | |
35 | 36 | from gi.repository import GLib |
36 | 37 | from gi.repository import GObject |
37 | 38 | from gi.repository import Gtk |
38 | 39 | from gi.repository import Gdk |
39 | 40 | from gi.repository import Gio |
41 | from gi.repository import TelepathyGLib | |
40 | 42 | |
41 | 43 | GObject.threads_init() |
42 | ||
43 | import telepathy | |
44 | 44 | |
45 | 45 | from sugar3.activity import activity |
46 | 46 | from sugar3.graphics.toolbutton import ToolButton |
891 | 891 | def _get_connection_params(self, tube_id): |
892 | 892 | # return ip and port to download a file |
893 | 893 | chan = self.shared_activity.telepathy_tubes_chan |
894 | iface = chan[telepathy.CHANNEL_TYPE_TUBES] | |
894 | iface = chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES] | |
895 | 895 | addr = iface.AcceptStreamTube( |
896 | 896 | tube_id, |
897 | telepathy.SOCKET_ADDRESS_TYPE_IPV4, | |
898 | telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0, | |
897 | TelepathyGLib.SocketAddressType.IPV4, | |
898 | TelepathyGLib.SocketAccessControl.LOCALHOST, 0, | |
899 | 899 | utf8_strings=True) |
900 | 900 | _logger.debug('Accepted stream tube: listening address is %r', addr) |
901 | 901 | # SOCKET_ADDRESS_TYPE_IPV4 is defined to have addresses of type '(sq)' |
1085 | 1085 | |
1086 | 1086 | # Make a tube for it |
1087 | 1087 | chan = self.shared_activity.telepathy_tubes_chan |
1088 | iface = chan[telepathy.CHANNEL_TYPE_TUBES] | |
1088 | iface = chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES] | |
1089 | 1089 | self._fileserver_tube_id = iface.OfferStreamTube( |
1090 | 1090 | READ_STREAM_SERVICE, |
1091 | 1091 | {}, |
1092 | telepathy.SOCKET_ADDRESS_TYPE_IPV4, | |
1092 | TelepathyGLib.SocketAddressType.IPV4, | |
1093 | 1093 | ('127.0.0.1', dbus.UInt16(self.port)), |
1094 | telepathy.SOCKET_ACCESS_CONTROL_LOCALHOST, 0) | |
1094 | TelepathyGLib.SocketAccessControl.LOCALHOST, 0) | |
1095 | 1095 | |
1096 | 1096 | def create_metadata_file(self): |
1097 | 1097 | # store the metadata in a json file |
1111 | 1111 | """Watch for new tubes.""" |
1112 | 1112 | tubes_chan = self.shared_activity.telepathy_tubes_chan |
1113 | 1113 | |
1114 | tubes_chan[telepathy.CHANNEL_TYPE_TUBES].connect_to_signal( | |
1114 | tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].connect_to_signal( | |
1115 | 1115 | 'NewTube', self._new_tube_cb) |
1116 | tubes_chan[telepathy.CHANNEL_TYPE_TUBES].ListTubes( | |
1116 | tubes_chan[TelepathyGLib.IFACE_CHANNEL_TYPE_TUBES].ListTubes( | |
1117 | 1117 | reply_handler=self._list_tubes_reply_cb, |
1118 | 1118 | error_handler=self._list_tubes_error_cb) |
1119 | 1119 |