~ubuntu-branches/ubuntu/wily/blueman/wily

« back to all changes in this revision

Viewing changes to blueman/bluez/obex/ObjectPush.py

  • Committer: Package Import Robot
  • Author(s): Sean Davis
  • Date: 2015-09-07 12:48:18 UTC
  • mfrom: (2.3.11 sid)
  • Revision ID: package-import@ubuntu.com-20150907124818-evulc0mhjotz8q29
Tags: 2.0-1ubuntu1
* Merge from Debian unstable (LP: #1482626). Remaining changes:
  - debian/patches/03_filemanage_fix.patch:
    + Dropped, no longer needed.
  - debian/patches/dhcpclient_priority
  - debian/patches/01_dont_autostart_lxde.patch
    + Refreshed patches

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
from __future__ import print_function
 
2
from __future__ import division
 
3
from __future__ import absolute_import
 
4
from __future__ import unicode_literals
 
5
 
 
6
from blueman.Functions import dprint
 
7
from blueman.bluez.obex.Base import Base
 
8
from gi.repository import GObject
 
9
 
 
10
 
 
11
class ObjectPush(Base):
 
12
    __gsignals__ = {
 
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,)),
 
15
    }
 
16
 
 
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)
 
20
        else:
 
21
            super(ObjectPush, self).__init__('org.bluez.obex.ObjectPush1', session_path)
 
22
 
 
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'])
 
28
 
 
29
        def on_transfer_error(error):
 
30
            dprint(file_path, error)
 
31
            self.emit('transfer-failed', error)
 
32
 
 
33
        self._interface.SendFile(file_path, reply_handler=on_transfer_started, error_handler=on_transfer_error)
 
34
 
 
35
    def get_session_path(self):
 
36
        return self.object_path