~ubuntu-branches/ubuntu/vivid/blueman/vivid-proposed

« back to all changes in this revision

Viewing changes to blueman/plugins/applet/DBusService.py

  • Committer: Package Import Robot
  • Author(s): Artur Rona
  • Date: 2014-12-24 18:33:36 UTC
  • mfrom: (2.3.8 sid)
  • Revision ID: package-import@ubuntu.com-20141224183336-cyb82ot0y8tz8flq
Tags: 1.99~alpha1-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - debian/patches/01_dont_autostart_lxde.patch:
    + Don't autostart the applet in LXDE.
  - debian/patches/03_filemanager_fix.patch:
    + Add support for more filemanagers.
* debian/patches/02_dont_crash_on_non-bluetooth_card.patch:
  - Dropped, no longer applicable.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
# Copyright (C) 2008 Valmantas Paliksa <walmis at balticum-tv dot lt>
2
 
# Copyright (C) 2008 Tadas Dailyda <tadas at dailyda dot com>
3
 
#
4
 
# Licensed under the GNU General Public License Version 3
5
 
#
6
 
# This program is free software: you can redistribute it and/or modify
7
 
# it under the terms of the GNU General Public License as published by
8
 
# the Free Software Foundation, either version 3 of the License, or
9
 
# (at your option) any later version.
10
 
#
11
 
# This program is distributed in the hope that it will be useful,
12
 
# but WITHOUT ANY WARRANTY; without even the implied warranty of
13
 
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14
 
# GNU General Public License for more details.
15
 
#
16
 
# You should have received a copy of the GNU General Public License
17
 
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
18
 
19
1
from blueman.Functions import *
20
2
import pickle
21
3
import base64
28
10
from blueman.main.Device import Device
29
11
from blueman.main.applet.BluezAgent import TempAgent
30
12
from blueman.bluez.Adapter import Adapter
 
13
from blueman.bluez.Serial import Serial
31
14
 
32
 
import gobject
33
 
import gtk
 
15
from gi.repository import GObject
 
16
from gi.repository import Gtk
34
17
import dbus
35
18
 
36
19
 
62
45
        self.add_dbus_method(self.DisconnectDevice, in_signature="o", out_signature="", async_callbacks=("ok", "err"))
63
46
 
64
47
    def RefreshServices(self, path, ok, err):
 
48
        # BlueZ 4 only!
65
49
        device = Device(path)
66
50
 
67
51
        def reply(svcs):
72
56
                pass
73
57
            ok()
74
58
 
75
 
        device.GetInterface().DiscoverServices("", reply_handler=reply, error_handler=err)
 
59
        device.get_interface().DiscoverServices("", reply_handler=reply, error_handler=err)
76
60
 
77
61
    def QueryPlugins(self):
78
62
        return self.Applet.Plugins.GetLoaded()
85
69
        def on_timeout():
86
70
            dev.Disconnect(reply_handler=ok, error_handler=err)
87
71
 
88
 
        gobject.timeout_add(1000, on_timeout)
 
72
        GObject.timeout_add(1000, on_timeout)
89
73
 
90
74
    def on_device_disconnect(self, device):
91
75
        pass
132
116
        pass
133
117
 
134
118
    def CreateDevice(self, adapter_path, address, pair, time, _ok, err):
 
119
        # BlueZ 4 only!
135
120
        def ok(device):
136
 
            _ok(device)
137
 
            self.RefreshServices(device, (lambda *args: None), (lambda *args: None))
 
121
            path = device.get_object_path()
 
122
            _ok(path)
 
123
            self.RefreshServices(path, (lambda *args: None), (lambda *args: None))
138
124
 
139
125
        if self.Applet.Manager:
140
126
            adapter = Adapter(adapter_path)
142
128
            if pair:
143
129
                agent_path = "/org/blueman/agent/temp/" + address.replace(":", "")
144
130
                agent = TempAgent(self.Applet.Plugins.StatusIcon, agent_path, time)
145
 
                adapter.GetInterface().CreatePairedDevice(address, agent_path, "DisplayYesNo", error_handler=err,
146
 
                                                          reply_handler=ok, timeout=120)
 
131
                adapter.create_paired_device(address, agent_path, "DisplayYesNo", error_handler=err,
 
132
                                             reply_handler=ok, timeout=120)
147
133
 
148
134
            else:
149
 
                adapter.GetInterface().CreateDevice(address, error_handler=err, reply_handler=ok, timeout=120)
 
135
                adapter.create_device(address, error_handler=err, reply_handler=ok, timeout=120)
150
136
 
151
137
        else:
152
138
            err()
153
139
 
154
140
    def CancelDeviceCreation(self, adapter_path, address, ok, err):
 
141
        # BlueZ 4 only!
155
142
        if self.Applet.Manager:
156
143
            adapter = Adapter(adapter_path)
157
144
 
158
 
            adapter.GetInterface().CancelDeviceCreation(address, error_handler=err, reply_handler=ok)
 
145
            adapter.get_interface().CancelDeviceCreation(address, error_handler=err, reply_handler=ok)
159
146
 
160
147
        else:
161
148
            err()
167
154
 
168
155
        dev = Device(device)
169
156
        try:
170
 
            self.Applet.Plugins.RecentConns.notify(dev.Copy(), "org.bluez.Serial", [uuid])
 
157
            self.Applet.Plugins.RecentConns.notify(dev.Copy(), Serial().get_interface_name(), [uuid])
171
158
        except KeyError:
172
159
            pass
173
160