# Path: bluezero/tools.py
# def int_to_uint16(value_in):
# def sint16_to_int(byte_array):
# def bytes_to_xyz(byte_array):
# def int_to_uint32(value_in):
# def bitwise_or_2lists(list1, list2):
# def bitwise_and_2lists(list1, list2):
# def bitwise_xor_2lists(list1, list2):
# def url_to_advert(url, frame_type, tx_power):
# def get_fn_parameters(fn):
# def create_module_logger(module_name):
# 
# Path: bluezero/gio_dbus.py
# class BluezMethod:
# class BluezProperty:
# class BluezSignal:
#     class BluezProxy:
# class BluezDBusClient:
# class DbusService:
# class DBusProperty:
# class DBusManager(GObject.GObject):
#     def __init__(self, method_name, method_proxy, in_args, out_args):
#     def __call__(self, *args, **kwargs):
#     def _unpack_result(result):
#     def __init__(self, property_name, property_proxy,
#                  property_info, bluez_iface):
#     def __get__(self, instance, owner=None):
#     def __set__(self, instance, value):
#     def __init__(self, connection, signal_name, object_path):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
# def delete_me(arg1, arg2, arg3):
# def BluezDBusObject(object_path, bluez_iface):
# def introspection(_intro_proxy):
# def _build_variant(iface, name, signature, py_value):
# def get_managed_objects():
# def _get_dbus_path2(objects, parent_path, iface_in, prop, value):
# def get_dbus_path(adapter=None,
#                   device=None,
#                   service=None,
#                   characteristic=None,
#                   descriptor=None):
#     def __init__(self):
#     def get_proxy(self, dbus_object, iface):
#     def _on_object_added(self,
#                          dbus_obj_mngr: Gio.DBusObjectManager,
#                          dbus_object: Gio.DBusObject) -> None:
#     def _on_object_removed(self,
#                            dbus_obj_mngr: Gio.DBusObjectManager,
#                            dbus_object: Gio.DBusObject) -> None:
#     def _on_properties_changed(
#             self,
#             dbus_client: Gio.DBusObjectManagerClient,
#             object_proxy: Gio.DBusObjectProxy,
#             interface_proxy: Gio.DBusProxy,
#             changed_properties: GLib.Variant,
#             invalidated_properties: list):
#     def __init__(self, introspection_xml, publish_path):
#     def handle_method_call(self,
#                            connection: Gio.DBusConnection,
#                            sender: str,
#                            object_path: str,
#                            interface_name: str,
#                            method_name: str,
#                            params: GLib.Variant,
#                            invocation: Gio.DBusMethodInvocation
#                            ):
#     def prop_getter(self,
#                     connection: Gio.DBusConnection,
#                     sender: str,
#                     object: str,
#                     iface: str,
#                     name: str):
#     def prop_setter(self,
#                     connection: Gio.DBusConnection,
#                     sender: str,
#                     object: str,
#                     iface: str,
#                     name: str,
#                     value: GLib.Variant):
# def _from_dict(dict_value):
# def build_dict_variant(dict_value, value_type):
#     def __init__(self, signature, init_value):
#     def __get__(self, instance, owner=None):
#     def __set__(self, instance, value):
# def get_device_address_from_dbus_path(path):
# def get_adapter_address_from_dbus_path(path):
#     def __new__(cls, *args, **kwargs):
#     def __init__(self):
#     def _on_object_added(self,
#                          _object_manager: Gio.DBusObjectManager,
#                          dbus_object: Gio.DBusObject) -> None:
#     def _on_object_removed(self, _object_manager: Gio.DBusObjectManager, dbus_object: Gio.DBusObject) -> None:
#     def get_iface_proxy(self, dbus_object_path, dbus_iface):
#     def get_prop_proxy(self, dbus_object_path):
#     def get_adapters(self):
#     def get_adapter(self, address):
#     def get_devices(self, adapter_address=None):
#     def get_device(self, adapter_address, devce_address):


from gi.repository import Gio, GLib
from bluezero import tools, gio_dbus
class EventLoop:
    """Facade class to help with using GLib event loop"""
    # def generic_error_cb(self, error):
    #     """Generic Error Callback function."""
    #     logger.error('D-Bus call failed: ' + str(error))
    #     self.mainloop.quit()

    # def __new__(cls):
    #     return object.__new__(cls)

    def __init__(self):
        self.mainloop = GLib.MainLoop()

    def run(self):
        """Run event loop"""
        self.mainloop.run()

    def quit(self):
        """Stop event loop"""
        self.mainloop.quit()

    def is_running(self):
        """Check if event loop is running"""
        self.mainloop.is_running()


class BluezeroRunner:
    def __init__(self):
        print('BluezeroRunner init')
        self.mainloop = GLib.MainLoop()

# Path: bluezero/tools.py
# def int_to_uint16(value_in):
# def sint16_to_int(byte_array):
# def bytes_to_xyz(byte_array):
# def int_to_uint32(value_in):
# def bitwise_or_2lists(list1, list2):
# def bitwise_and_2lists(list1, list2):
# def bitwise_xor_2lists(list1, list2):
# def url_to_advert(url, frame_type, tx_power):
# def get_fn_parameters(fn):
# def create_module_logger(module_name):
# 
# Path: bluezero/gio_dbus.py
# class BluezMethod:
# class BluezProperty:
# class BluezSignal:
#     class BluezProxy:
# class BluezDBusClient:
# class DbusService:
# class DBusProperty:
# class DBusManager(GObject.GObject):
#     def __init__(self, method_name, method_proxy, in_args, out_args):
#     def __call__(self, *args, **kwargs):
#     def _unpack_result(result):
#     def __init__(self, property_name, property_proxy,
#                  property_info, bluez_iface):
#     def __get__(self, instance, owner=None):
#     def __set__(self, instance, value):
#     def __init__(self, connection, signal_name, object_path):
#     def __get__(self, instance, owner):
#     def __set__(self, instance, value):
# def delete_me(arg1, arg2, arg3):
# def BluezDBusObject(object_path, bluez_iface):
# def introspection(_intro_proxy):
# def _build_variant(iface, name, signature, py_value):
# def get_managed_objects():
# def _get_dbus_path2(objects, parent_path, iface_in, prop, value):
# def get_dbus_path(adapter=None,
#                   device=None,
#                   service=None,
#                   characteristic=None,
#                   descriptor=None):
#     def __init__(self):
#     def get_proxy(self, dbus_object, iface):
#     def _on_object_added(self,
#                          dbus_obj_mngr: Gio.DBusObjectManager,
#                          dbus_object: Gio.DBusObject) -> None:
#     def _on_object_removed(self,
#                            dbus_obj_mngr: Gio.DBusObjectManager,
#                            dbus_object: Gio.DBusObject) -> None:
#     def _on_properties_changed(
#             self,
#             dbus_client: Gio.DBusObjectManagerClient,
#             object_proxy: Gio.DBusObjectProxy,
#             interface_proxy: Gio.DBusProxy,
#             changed_properties: GLib.Variant,
#             invalidated_properties: list):
#     def __init__(self, introspection_xml, publish_path):
#     def handle_method_call(self,
#                            connection: Gio.DBusConnection,
#                            sender: str,
#                            object_path: str,
#                            interface_name: str,
#                            method_name: str,
#                            params: GLib.Variant,
#                            invocation: Gio.DBusMethodInvocation
#                            ):
#     def prop_getter(self,
#                     connection: Gio.DBusConnection,
#                     sender: str,
#                     object: str,
#                     iface: str,
#                     name: str):
#     def prop_setter(self,
#                     connection: Gio.DBusConnection,
#                     sender: str,
#                     object: str,
#                     iface: str,
#                     name: str,
#                     value: GLib.Variant):
# def _from_dict(dict_value):
# def build_dict_variant(dict_value, value_type):
#     def __init__(self, signature, init_value):
#     def __get__(self, instance, owner=None):
#     def __set__(self, instance, value):
# def get_device_address_from_dbus_path(path):
# def get_adapter_address_from_dbus_path(path):
#     def __new__(cls, *args, **kwargs):
#     def __init__(self):
#     def _on_object_added(self,
#                          _object_manager: Gio.DBusObjectManager,
#                          dbus_object: Gio.DBusObject) -> None:
#     def _on_object_removed(self, _object_manager: Gio.DBusObjectManager, dbus_object: Gio.DBusObject) -> None:
#     def get_iface_proxy(self, dbus_object_path, dbus_iface):
#     def get_prop_proxy(self, dbus_object_path):
#     def get_adapters(self):
#     def get_adapter(self, address):
#     def get_devices(self, adapter_address=None):
#     def get_device(self, adapter_address, devce_address):


# Path: bluezero/async_tools.py
from gi.repository import Gio, GLib
from bluezero import tools, gio_dbus

class EventLoop:
    """Facade class to help with using GLib event loop"""
    # def generic_error_cb(self, error):
    #     """Generic Error Callback function."""
    #     logger.error('D-Bus call failed: ' + str(error))
    #     self.mainloop.quit()

    # def __new__(cls):
    #     return object.__new__(cls)

    def __init__(self):
        self.mainloop = GLib.MainLoop()

    def run(self):
        """Run event loop"""
        self.mainloop.run()

    def quit(self):
        """Stop event loop"""
        self.mainloop.quit()

    def is_running(self):
        """Check if event loop is running"""
        self.mainloop.is_running()


class BluezeroRunner:
    def __init__(self):
        print('BluezeroRunner init')
        self.mainloop = GLib.MainLoop()

        self.bluez = gio_dbus.BluezDBusClient()