From e45318809c74580a5dcdce4288f052c86f337211 Mon Sep 17 00:00:00 2001 From: Christopher Schramm Date: Wed, 22 Sep 2021 15:55:26 +0200 Subject: [PATCH] Remove unused stuff from _blueman --- module/Makefile.am | 4 ++-- module/_blueman.pyx | 22 -------------------- module/libblueman.c | 49 ++------------------------------------------- module/libblueman.h | 4 ---- stubs/_blueman.pyi | 1 - 5 files changed, 4 insertions(+), 76 deletions(-) diff --git a/module/Makefile.am b/module/Makefile.am index e9f4ea69f..38646b181 100644 --- a/module/Makefile.am +++ b/module/Makefile.am @@ -2,10 +2,10 @@ BUILT_SOURCES = _blueman.c bluemanlibdir = $(pyexecdir) bluemanlib_LTLIBRARIES = _blueman.la -_blueman_la_CFLAGS = $(BLUEZ_CFLAGS) $(PYGOBJECT_CFLAGS) $(PYTHON_CFLAGS) \ +_blueman_la_CFLAGS = $(BLUEZ_CFLAGS) $(PYTHON_CFLAGS) \ -DSN_API_NOT_YET_FROZEN _blueman_la_LDFLAGS = -module -avoid-version -fPIC -_blueman_la_LIBADD = $(BLUEZ_LIBS) $(PYGOBJECT_LIBS) $(PYTHON_LIBS) +_blueman_la_LIBADD = $(BLUEZ_LIBS) $(PYTHON_LIBS) _blueman_la_SOURCES = \ _blueman.c \ libblueman.c \ diff --git a/module/_blueman.pyx b/module/_blueman.pyx index 2f8bae169..428b75917 100644 --- a/module/_blueman.pyx +++ b/module/_blueman.pyx @@ -1,7 +1,6 @@ #!/usr/bin/env python3 # coding=utf-8 #cython: language_level=3 -import logging cdef extern from "malloc.h": cdef void free(void *ptr) @@ -14,7 +13,6 @@ cdef extern from "bluetooth/bluetooth.h": unsigned char b[6] int ba2str(bdaddr_t *ba, char *str) - int str2ba(char *str, bdaddr_t *ba) cdef extern from "bluetooth/hci.h": cdef struct hci_dev_stats: @@ -88,7 +86,6 @@ cdef extern from "libblueman.h": cdef int get_rfcomm_list(rfcomm_dev_list_req **ret) cdef int c_create_rfcomm_device "create_rfcomm_device" (char *local_address, char *remote_address, int channel) cdef int c_release_rfcomm_device "release_rfcomm_device" (int id) - cdef float get_page_timeout(int hdev) cdef int _create_bridge(char* name) cdef int _destroy_bridge(char* name) @@ -106,8 +103,6 @@ ERR = { -7:"Read Link quality failed", -8:"Getting rfcomm list failed", -9:"ERR_SOCKET_FAILED", - -10:"ERR_CANT_READ_PAGE_TIMEOUT", - -11:"ERR_READ_PAGE_TIMEOUT", -12: "Can't bind RFCOMM socket", -13: "Can't connect RFCOMM socket", -14: "Can't create RFCOMM TTY", @@ -269,17 +264,6 @@ cdef class conn_info: return tpl -def page_timeout(py_hci_name="hci0"): - py_bytes_hci_name = py_hci_name.encode("UTF-8") - cdef char* hci_name = py_bytes_hci_name - - dev_id = int(hci_name[3:]) - ret = get_page_timeout(dev_id) - if ret < 0: - raise Exception, ERR[ret] - else: - return ret - def device_info(py_hci_name="hci0"): py_bytes_hci_name = py_hci_name.encode("UTF-8") cdef char* hci_name = py_bytes_hci_name @@ -324,9 +308,3 @@ def device_info(py_hci_name="hci0"): ("stat", dict(x))] return dict(z) - -cdef extern from "glib-object.h": - ctypedef struct GObject - -cdef extern from "pygobject.h": - cdef GObject* pygobject_get(object) diff --git a/module/libblueman.c b/module/libblueman.c index 7f4ed03d6..69c1fbfeb 100644 --- a/module/libblueman.c +++ b/module/libblueman.c @@ -52,7 +52,7 @@ static inline unsigned long __tv_to_jiffies(const struct timeval *tv) return jif/10000; } - + int _create_bridge(const char* name) { int sock; sock = socket(AF_INET, SOCK_STREAM, 0); @@ -132,7 +132,7 @@ int _destroy_bridge(const char* name) { return 0; } -int find_conn(int s, int dev_id, long arg) +static int find_conn(int s, int dev_id, long arg) { struct hci_conn_list_req *cl; struct hci_conn_info *ci; @@ -431,48 +431,3 @@ int release_rfcomm_device(int id) { return 0; } } - -float get_page_timeout(int hdev) -{ - struct hci_request rq; - int s; - float ret; - - if ((s = hci_open_dev(hdev)) < 0) { - ret = ERR_HCI_DEV_OPEN_FAILED; - goto out; - } - - memset(&rq, 0, sizeof(rq)); - - uint16_t timeout; - read_page_timeout_rp rp; - - rq.ogf = OGF_HOST_CTL; - rq.ocf = OCF_READ_PAGE_TIMEOUT; - rq.rparam = &rp; - rq.rlen = READ_PAGE_TIMEOUT_RP_SIZE; - - if (hci_send_req(s, &rq, 1000) < 0) { - ret = ERR_CANT_READ_PAGE_TIMEOUT; - goto out; - } - if (rp.status) { - ret = ERR_READ_PAGE_TIMEOUT; - goto out; - } - - timeout = btohs(rp.timeout); - ret = ((float)timeout * 0.625); - -out: - if (s >= 0) - hci_close_dev(s); - return ret; -} - - - - - - diff --git a/module/libblueman.h b/module/libblueman.h index 48a5d7d3b..fd0f2f44b 100644 --- a/module/libblueman.h +++ b/module/libblueman.h @@ -8,8 +8,6 @@ #define ERR_READ_LQ_FAILED -7 #define ERR_GET_RFCOMM_LIST_FAILED -8 #define ERR_SOCKET_FAILED -9 -#define ERR_CANT_READ_PAGE_TIMEOUT -10 -#define ERR_READ_PAGE_TIMEOUT -11 #define ERR_BIND_FAILED -12 #define ERR_CONNECT_FAILED -13 #define ERR_CREATE_DEV_FAILED -14 @@ -20,7 +18,6 @@ struct conn_info_handles { int dd; }; -int find_conn(int s, int dev_id, long arg); int connection_init(int dev_id, char *addr, struct conn_info_handles *ci); int connection_get_rssi(struct conn_info_handles *ci, int8_t *ret_rssi); int connection_get_lq(struct conn_info_handles *ci, uint8_t *ret_lq); @@ -30,7 +27,6 @@ int get_rfcomm_channel(uint16_t uuid, char* btd_addr); int get_rfcomm_list(struct rfcomm_dev_list_req **result); int create_rfcomm_device(char *local_address, char *remote_address, int channel); int release_rfcomm_device(int id); -float get_page_timeout(int hdev); int _create_bridge(const char* name); int _destroy_bridge(const char* name); diff --git a/stubs/_blueman.pyi b/stubs/_blueman.pyi index a0313baa1..03a3ee711 100644 --- a/stubs/_blueman.pyi +++ b/stubs/_blueman.pyi @@ -52,7 +52,6 @@ def create_bridge(name: str = "pan1") -> None: ... def create_rfcomm_device(local_address: str, remote_address: str, channel: int) -> int: ... def destroy_bridge(name: str = "pan1") -> None: ... def device_info(hci_name: str = "hci0") -> _HciInfo: ... -def page_timeout(hci_name: str = "hci0") -> float: ... def get_rfcomm_channel(uuid: int, bdaddr: str) -> Optional[int]: ... def release_rfcomm_device(id: int) -> int: ... def rfcomm_list() -> List[_RfcommDev]: ...