def on_transfer_started(self, session, filename, local_path, total_bytes):
     session.transfer["progress_dialog"] = BluetoothProgressDialog()
     session.transfer["progress_dialog"].set_keep_above(True)
     info = session.server.GetServerSessionInfo(session.object_path)
     try:
         dev = Device(
             Adapter(Manager().get_default_adapter()).create_device(
                 info["BluetoothAddress"]))
         name = dev.get_alias()
     except Exception, e:
         print e
         name = info["BluetoothAddress"]
Esempio n. 2
0
    def __init__(self,
                 adapter_removed_cb=None,
                 default_adapter_changed_cb=None,
                 device_found_cb=None):
        self.__adapter_removed_cb = adapter_removed_cb
        self.__default_adapter_changed_cb = default_adapter_changed_cb

        self.manager = Manager()
        if self.__adapter_removed_cb:
            self.manager.connect("adapter-removed", self.__adapter_removed)
        if self.__default_adapter_changed_cb:
            self.manager.connect("default-adapter-changed", self.__default_adapter_changed)
        self.adapter = None
        self.default_adapter = self.manager.get_default_adapter()

        if self.default_adapter != "None":
            self.adapter = Adapter(self.default_adapter)
            # self.adapter.set_powered(True)
            self.adapter.set_discoverable(False)
            self.adapter.set_pairable(True)
            if device_found_cb:
                self.adapter.connect("device-found", device_found_cb)
Esempio n. 3
0
    def __init__(self):
        """
        constructor
        """
        IWatchdog.__init__(self)
        self._eventloop = GObject.MainLoop()
        self.logger = Logger("bt.watchdog")
        self.logger.debug("initializing Bluetooth watchdog")
        self._events = WatchdogEvent(self.logger)
        self.bt_powered = False
        # global objects about DBus
        self._bus = dbus.SystemBus()
        self._dbus_obj = self._bus.get_object(Consts.Bt.SVC_NAME,
                                              Consts.DBus.OBJ_MNGR_PATH)
        try:
            self._dbus_manager = dbus.Interface(self._dbus_obj,
                                                Consts.DBus.OBJ_MNGR)
        except dbus.DBusException as E:
            self.logger.error("%s" % (E.get_dbus_message()))
            self._dbus_manager = None
        except:
            self.logger.error(
                "Unknown error while retrieving DBUS object manager")
            self._dbus_manager = None
        self._dbus_adapter_obj = None

        self._adapter = [Adapter(self.logger)]
        # identify it as the used adapter
        self._used_adapter = self._adapter[0]
        self.logger.debug("registering adapter")
        EXPOSED_OBJECTS["adapter"] = self._used_adapter
        self.logger.debug(EXPOSED_OBJECTS)

        # devices is expected to be a @MAC -> Device object mapping
        self._devices = self._used_adapter.get_devices()
        # map_devices is expected to be a path -> @MAC mapping
        self._map_devices = {}
Esempio n. 4
0
import os
import sys
import gtk
import dbus.mainloop.glib
from deepin_utils.file import get_parent_dir
sys.path.append(os.path.join(get_parent_dir(__file__, 4), "dss"))

from bt.agent import Agent
from bt.adapter import Adapter
from bt.manager import Manager
from bluetooth_transfer import BluetoothTransfer

dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

# gtk.gdk.threads_init()

bus = dbus.SystemBus()
path = "/com/deepin/bluetooth/agent"

agent = Agent(path, bus)

default_adapter = Manager().get_default_adapter()
if default_adapter != "None":
    adptr = Adapter(default_adapter)
    adptr.register_agent(path, "")
    
    transfer = BluetoothTransfer()
    transfer.create_server()
    
gtk.main()