# Path: kano_settings/system/bt/dbus_tools.py
# BUS = dbus.SystemBus()
# 
# SERVICE_NAME = 'org.bluez'
# 
# DEVICE_IFACE_NAME = 'org.bluez.Device1'


import dbus
from kano.logging import logger
from kano.utils.dbus_interface import get_property, get_all_properties, \
    set_property, dbus_to_bool
from kano.decorators import retry
from kano_settings.system.bt.dbus_tools import BUS, SERVICE_NAME, \
    DEVICE_IFACE_NAME
# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# Interface to a bluetooth device
#





class BluetoothDevice(object):

    def __init__(self, dbus_dev_obj_path):
        super(BluetoothDevice, self).__init__()

        self.dbus_dev_obj_path = dbus_dev_obj_path
        self._dbus_proxy = self.get_dbus_proxy()
        self.interface = self.get_device_interface()

        props = self.get_properties()
        logger.debug(u"Properties: {}".format(props))

        self._name = props.get('Name', '')
        self._alias = props.get('Alias', '')
        self._addr = props.get('Address', '')
        self.icon = props.get('Icon', '')
        self.class_id = props.get('Class', '')

    def __unicode__(self):
        return u'{} ({})'.format(self.name, self.addr)


# Path: kano_settings/system/bt/dbus_tools.py
# BUS = dbus.SystemBus()
# 
# SERVICE_NAME = 'org.bluez'
# 
# DEVICE_IFACE_NAME = 'org.bluez.Device1'


# Path: kano_settings/system/bt/device.py
import dbus
from kano.logging import logger
from kano.utils.dbus_interface import get_property, get_all_properties, \
    set_property, dbus_to_bool
from kano.decorators import retry
from kano_settings.system.bt.dbus_tools import BUS, SERVICE_NAME, \
    DEVICE_IFACE_NAME

# License: http://www.gnu.org/licenses/gpl-2.0.txt GNU GPL v2
#
# Interface to a bluetooth device
#





class BluetoothDevice(object):

    def __init__(self, dbus_dev_obj_path):
        super(BluetoothDevice, self).__init__()

        self.dbus_dev_obj_path = dbus_dev_obj_path
        self._dbus_proxy = self.get_dbus_proxy()
        self.interface = self.get_device_interface()

        props = self.get_properties()
        logger.debug(u"Properties: {}".format(props))

        self._name = props.get('Name', '')
        self._alias = props.get('Alias', '')
        self._addr = props.get('Address', '')
        self.icon = props.get('Icon', '')
        self.class_id = props.get('Class', '')

    def __unicode__(self):
        return u'{} ({})'.format(self.name, self.addr)


    def __str__(self):