From bd14f03770f218803a3fd41676b4e75f406c4b77 Mon Sep 17 00:00:00 2001 From: Robert Tari Date: Wed, 8 Nov 2023 17:03:13 +0100 Subject: Fix AccountsService integration --- src/accounts-service-access.vala | 31 +++++++++++++++++++------------ src/accounts-service-sound-settings.vala | 4 ++++ src/media-player-list-greeter.vala | 18 +++++++++--------- src/volume-control-pulse.vala | 12 +++++++++++- 4 files changed, 43 insertions(+), 22 deletions(-) diff --git a/src/accounts-service-access.vala b/src/accounts-service-access.vala index 7f01b7c..1b66370 100644 --- a/src/accounts-service-access.vala +++ b/src/accounts-service-access.vala @@ -1,6 +1,6 @@ /* * Copyright 2016 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2023 Robert Tari * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -23,17 +23,17 @@ using PulseAudio; using Notify; using Gee; -[DBus (name="org.ayatana.Greeter.List")] -interface GreeterListInterfaceAccess : Object +[DBus (name="org.ayatana.greeter")] +interface GreeterInterfaceAccess : Object { - public abstract async string get_active_entry () throws GLib.DBusError, GLib.IOError; - public signal void entry_selected (string entry_name); + public abstract async string GetUser () throws GLib.DBusError, GLib.IOError; + public signal void UserChanged (string user); } public class AccountsServiceAccess : Object { private DBusProxy _user_proxy; - private GreeterListInterfaceAccess _greeter_proxy; + private GreeterInterfaceAccess _greeter_proxy; private double _volume = 0.0; private string _last_running_player = ""; private bool _mute = false; @@ -129,7 +129,7 @@ public class AccountsServiceAccess : Object { try { - username = yield _greeter_proxy.get_active_entry (); + username = yield _greeter_proxy.GetUser (); if (username == "" || username == null) { @@ -167,9 +167,16 @@ public class AccountsServiceAccess : Object if (user_path_variant.check_format_string ("(o)", true)) { user_path_variant.get ("(o)", out user_path); -#if LOMIRI_FEATURES_ENABLED - _user_proxy = yield new DBusProxy.for_bus (BusType.SYSTEM, DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, "org.freedesktop.Accounts", user_path, "com.lomiri.AccountsService.Sound"); -#endif + bool bLomiri = AyatanaCommon.utils_is_lomiri (); + + if (bLomiri) + { + _user_proxy = yield new DBusProxy.for_bus (BusType.SYSTEM, DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, "org.freedesktop.Accounts", user_path, "com.lomiri.AccountsService.Sound"); + } + else + { + _user_proxy = yield new DBusProxy.for_bus (BusType.SYSTEM, DBusProxyFlags.GET_INVALIDATED_PROPERTIES, null, "org.freedesktop.Accounts", user_path, "org.ayatana.indicator.sound.AccountsService"); + } } else { @@ -223,7 +230,7 @@ public class AccountsServiceAccess : Object { try { - _greeter_proxy = yield Bus.get_proxy (BusType.SESSION, "org.ayatana.Greeter", "/list"); + _greeter_proxy = yield Bus.get_proxy (BusType.SESSION, "org.ayatana.greeter", "/org/ayatana/greeter"); } catch (GLib.Error e) { @@ -232,7 +239,7 @@ public class AccountsServiceAccess : Object return; } - _greeter_proxy.entry_selected.connect (greeter_user_changed); + _greeter_proxy.UserChanged.connect (greeter_user_changed); yield setup_user_proxy (); } else diff --git a/src/accounts-service-sound-settings.vala b/src/accounts-service-sound-settings.vala index dcba7ea..54c6ad6 100644 --- a/src/accounts-service-sound-settings.vala +++ b/src/accounts-service-sound-settings.vala @@ -1,5 +1,6 @@ /* * Copyright 2014 Canonical Ltd. + * Copyright 2023 Robert Tari * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,6 +16,7 @@ * * Authors: * Ted Gould + * Robert Tari */ [DBus (name = "org.ayatana.indicator.sound.AccountsService")] @@ -29,4 +31,6 @@ public interface AccountsServiceSoundSettings : Object { public abstract string artist {owned get; set;} public abstract string album {owned get; set;} public abstract string art_url {owned get; set;} + public abstract double volume {owned get; set;} + public abstract bool mute {owned get; set;} } diff --git a/src/media-player-list-greeter.vala b/src/media-player-list-greeter.vala index 83e1d3f..8965cba 100644 --- a/src/media-player-list-greeter.vala +++ b/src/media-player-list-greeter.vala @@ -1,6 +1,6 @@ /* * Copyright 2014 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2023 Robert Tari * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -19,10 +19,10 @@ * Robert Tari */ -[DBus (name="org.ayatana.Greeter.List")] +[DBus (name="org.ayatana.greeter")] public interface AyatanaGreeterList : Object { - public abstract async string get_active_entry () throws GLib.DBusError, GLib.IOError; - public signal void entry_selected (string entry_name); + public abstract async string GetUser () throws GLib.DBusError, GLib.IOError; + public signal void UserChanged (string user); } public class MediaPlayerListGreeter : MediaPlayerList { @@ -33,8 +33,8 @@ public class MediaPlayerListGreeter : MediaPlayerList { public MediaPlayerListGreeter () { Bus.get_proxy.begin ( BusType.SESSION, - "org.ayatana.Greeter", - "/list", + "org.ayatana.greeter", + "/org/ayatana/greeter", DBusProxyFlags.NONE, null, new_proxy); @@ -44,14 +44,14 @@ public class MediaPlayerListGreeter : MediaPlayerList { try { this.proxy = Bus.get_proxy.end(res); - this.proxy.entry_selected.connect(active_user_changed); - this.proxy.get_active_entry.begin ((obj, res) => { + this.proxy.UserChanged.connect(active_user_changed); + this.proxy.GetUser.begin ((obj, res) => { try { var list = (obj as AyatanaGreeterList); if (list != null) { - var value = list.get_active_entry.end(res); + var value = list.GetUser.end(res); active_user_changed(value); } } catch (Error e) { diff --git a/src/volume-control-pulse.vala b/src/volume-control-pulse.vala index 706b0fe..460b098 100644 --- a/src/volume-control-pulse.vala +++ b/src/volume-control-pulse.vala @@ -1,6 +1,6 @@ /* * Copyright 2013 Canonical Ltd. - * Copyright 2021 Robert Tari + * Copyright 2021-2023 Robert Tari * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -78,6 +78,16 @@ public class VolumeControlPulse : VolumeControl start_account_service_volume_timer(); } }); + + this._accounts_service_access.notify["mute"].connect(() => { + + if (_mute != this._accounts_service_access.mute) + { + set_mute_internal (this._accounts_service_access.mute); + start_account_service_volume_timer(); + } + }); + this.reconnect_to_pulse (); } -- cgit v1.2.3