Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for stable #2493

Merged
merged 6 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## 2.4.4

### Bugs fixed
* Fix Rfcom plugin dbus signature
* Set an initial selected device in blueman-sendto
* AutoConnect: Store bluetooth address instead of object path

### Changes
* Add Galic and Esperanto translations
* AutoConnect: Automatically convert path to address

## 2.4.3

### Bugs fixed
Expand Down
8 changes: 7 additions & 1 deletion blueman/gui/DeviceSelectorDialog.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@


class DeviceSelectorDialog(Gtk.Dialog):
selection: Optional[Tuple[str, Optional[Device]]]

def __init__(self, title: str = _("Select Device"), parent: Optional[Gtk.Container] = None, discover: bool = True,
adapter_name: Optional[str] = None) -> None:
super().__init__(title=title, name="DeviceSelectorDialog", parent=parent, icon_name="blueman", resizable=False)
Expand All @@ -25,7 +27,11 @@ def __init__(self, title: str = _("Select Device"), parent: Optional[Gtk.Contain
self.selector = DeviceSelectorWidget(adapter_name=adapter_name, visible=True)
self.vbox.pack_start(self.selector, True, True, 0)

self.selection: Optional[Tuple[str, Optional[Device]]] = None
selected_device = self.selector.List.get_selected_device()
if selected_device is not None:
self.selection = selected_device["Adapter"], selected_device
else:
self.selection = None

self.selector.List.connect("device-selected", self.on_device_selected)
self.selector.List.connect("adapter-changed", self.on_adapter_changed)
Expand Down
3 changes: 2 additions & 1 deletion blueman/gui/manager/ManagerDeviceMenu.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,14 +327,15 @@ def generate(self) -> None:
config = AutoConnectConfig()
generic_service = ServiceUUID("00000000-0000-0000-0000-000000000000")
object_path = self.SelectedDevice.get_object_path()
btaddress = self.SelectedDevice["Address"]
generic_autoconnect = (object_path, str(generic_service)) in set(config["services"])

if row["connected"] or generic_autoconnect or autoconnect_items:
self.append(self._create_header(_("<b>Auto-connect:</b>")))

if row["connected"] or generic_autoconnect:
item = Gtk.CheckMenuItem(label=generic_service.name)
config.bind_to_menuitem(item, (object_path, str(generic_service)))
config.bind_to_menuitem(item, (btaddress, str(generic_service)))
item.show()
self.append(item)

Expand Down
21 changes: 19 additions & 2 deletions blueman/plugins/applet/AutoConnect.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

from blueman.Sdp import ServiceUUID
from blueman.bluez.Device import Device
from blueman.config.AutoConnectConfig import AutoConnectConfig
from blueman.gui.Notification import Notification
from blueman.plugins.AppletPlugin import AppletPlugin

Expand Down Expand Up @@ -39,9 +40,25 @@ def on_adapter_property_changed(self, path: str, key: str, value: Any) -> None:
if key == "Powered" and value:
self._run()

@staticmethod
def __fix_settings(path: str, uuid: str) -> str:
config = AutoConnectConfig()
address = path.replace("_", ":")[-17:]

data = set(config["services"])
data.remove((path, uuid))
data.add((address, uuid))
config["services"] = data

return address

def _run(self) -> bool:
for address, uuid in self.get_option('services'):
device = self.parent.Manager.find_device(address)
for btaddress, uuid in self.get_option('services'):
# We accidentally stored the dbus object path in 2.4
if btaddress.startswith("/org/bluez"):
btaddress = self.__fix_settings(btaddress, uuid)

device = self.parent.Manager.find_device(btaddress)
if device is None or device.get("Connected"):
continue

Expand Down
6 changes: 3 additions & 3 deletions blueman/plugins/manager/Services.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ def on_request_menu_items(
items.append(DeviceMenuItem(item, DeviceMenuItem.Group.DISCONNECT, service.priority + 100))
item.show()

object_path = device.get_object_path()
btaddress = device["Address"]
if services:
config = AutoConnectConfig()
autoconnect_services = set(config["services"])
for service in services:
if service.connected_instances or (object_path, service.uuid) in autoconnect_services:
if service.connected_instances or (btaddress, service.uuid) in autoconnect_services:
item = Gtk.CheckMenuItem(label=service.name)
config.bind_to_menuitem(item, (object_path, service.uuid))
config.bind_to_menuitem(item, (btaddress, service.uuid))
item.show()
items.append(DeviceMenuItem(item, DeviceMenuItem.Group.AUTOCONNECT, service.priority))

Expand Down
4 changes: 2 additions & 2 deletions blueman/plugins/mechanism/Rfcomm.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@

class Rfcomm(MechanismPlugin):
def on_load(self) -> None:
self.parent.add_method("OpenRFCOMM", ("d",), "", self._open_rfcomm)
self.parent.add_method("CloseRFCOMM", ("d",), "", self._close_rfcomm)
self.parent.add_method("OpenRFCOMM", ("n",), "", self._open_rfcomm)
self.parent.add_method("CloseRFCOMM", ("n",), "", self._close_rfcomm)

def _open_rfcomm(self, port_id: int) -> None:
subprocess.Popen([RFCOMM_WATCHER_PATH, f"/dev/rfcomm{port_id:d}"])
Expand Down
6 changes: 3 additions & 3 deletions blueman/services/meta/SerialService.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def try_replace_root_watcher(self, monitor: Gio.FileMonitor, path: str, port: in

logging.info(f'User was granted access to {path}')
logging.info('Replacing root watcher')
Mechanism().CloseRFCOMM('(d)', port)
Mechanism().CloseRFCOMM('(n)', port)
subprocess.Popen([RFCOMM_WATCHER_PATH, path])
if port in self._handlerids:
handler_id = self._handlerids.pop(port)
Expand Down Expand Up @@ -101,7 +101,7 @@ def connect(
channel)
filename = f"/dev/rfcomm{port_id:d}"
logging.info('Starting rfcomm watcher as root')
Mechanism().OpenRFCOMM('(d)', port_id)
Mechanism().OpenRFCOMM('(n)', port_id)
mon = Gio.File.new_for_path(filename).monitor_file(Gio.FileMonitorFlags.NONE)
self._handlerids[port_id] = mon.connect('changed', self.on_file_changed, port_id)
self.try_replace_root_watcher(mon, filename, port_id)
Expand All @@ -122,7 +122,7 @@ def disconnect(
error_handler: Optional[Callable[[str], None]] = None
) -> None:
try:
Mechanism().CloseRFCOMM('(d)', port_id)
Mechanism().CloseRFCOMM('(n)', port_id)
except GLib.Error as e:
if error_handler:
error_handler(e.message)
Expand Down
2 changes: 2 additions & 0 deletions po/LINGUAS
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,14 @@ de
el
en_AU
en_GB
eo
es
et
eu
fa
fi
fr
ga
gl
he
hi
Expand Down
Loading