1
from __future__ import print_function
2
from __future__ import division
3
from __future__ import absolute_import
4
from __future__ import unicode_literals
6
from blueman.Functions import dprint
7
from blueman.bluez.obex.Base import Base
8
from gi.repository import GObject
11
class ObjectPush(Base):
13
str('transfer-started'): (GObject.SignalFlags.NO_HOOKS, None, (GObject.TYPE_PYOBJECT, GObject.TYPE_PYOBJECT,)),
14
str('transfer-failed'): (GObject.SignalFlags.NO_HOOKS, None, (GObject.TYPE_PYOBJECT,)),
17
def __init__(self, session_path):
18
if self.__class__.get_interface_version()[0] < 5:
19
super(ObjectPush, self).__init__('org.bluez.obex.ObjectPush', session_path, True)
21
super(ObjectPush, self).__init__('org.bluez.obex.ObjectPush1', session_path)
23
def send_file(self, file_path):
24
def on_transfer_started(*params):
25
transfer_path, props = params[0] if self.__class__.get_interface_version()[0] < 5 else params
26
dprint(self.object_path, file_path, transfer_path)
27
self.emit('transfer-started', transfer_path, props['Filename'])
29
def on_transfer_error(error):
30
dprint(file_path, error)
31
self.emit('transfer-failed', error)
33
self._interface.SendFile(file_path, reply_handler=on_transfer_started, error_handler=on_transfer_error)
35
def get_session_path(self):
36
return self.object_path