From d695c8f4b0466bdd2eec1c629d6a22eec1f81c5e Mon Sep 17 00:00:00 2001 From: Andy Holmes Date: Wed, 4 Dec 2024 16:42:51 -0800 Subject: [PATCH] refactor(systemvolume): don't send `requestSinks` command at connect Sinks are sent at connect time and updated as necessary, so drop the request command. See: - https://invent.kde.org/network/kdeconnect-android/-/merge_requests/500 - https://invent.kde.org/network/kdeconnect-kde/-/merge_requests/756 - https://github.com/GSConnect/gnome-shell-extension-gsconnect/pull/1890 --- .../systemvolume/valent-systemvolume-device.c | 31 ++++++++++++------- tests/extra/cppcheck.supp | 2 +- .../systemvolume/test-systemvolume-plugin.c | 12 ------- 3 files changed, 21 insertions(+), 24 deletions(-) diff --git a/src/plugins/systemvolume/valent-systemvolume-device.c b/src/plugins/systemvolume/valent-systemvolume-device.c index 464538b107..b3c9b54df5 100644 --- a/src/plugins/systemvolume/valent-systemvolume-device.c +++ b/src/plugins/systemvolume/valent-systemvolume-device.c @@ -222,6 +222,26 @@ struct _ValentSystemvolumeDevice G_DEFINE_FINAL_TYPE (ValentSystemvolumeDevice, valent_systemvolume_device, VALENT_TYPE_MIXER_ADAPTER) +#if 0 +static void +valent_systemvolume_device_request_sinks (ValentSystemvolumeDevice *self) +{ + g_autoptr (JsonBuilder) builder = NULL; + g_autoptr (JsonNode) packet = NULL; + + valent_packet_init (&builder, "kdeconnect.systemvolume.request"); + json_builder_set_member_name (builder, "requestSinks"); + json_builder_add_boolean_value (builder, TRUE); + packet = valent_packet_end (&builder); + + valent_device_send_packet (self->device, + packet, + self->cancellable, + (GAsyncReadyCallback) valent_device_send_packet_cb, + NULL); +} +#endif + /* * ValentMixerAdapter */ @@ -248,17 +268,6 @@ on_device_state_changed (ValentDevice *device, cancellable = g_cancellable_new (); self->cancellable = valent_object_chain_cancellable (VALENT_OBJECT (self), cancellable); - - valent_packet_init (&builder, "kdeconnect.systemvolume.request"); - json_builder_set_member_name (builder, "requestSinks"); - json_builder_add_boolean_value (builder, TRUE); - packet = valent_packet_end (&builder); - - valent_device_send_packet (self->device, - packet, - self->cancellable, - (GAsyncReadyCallback) valent_device_send_packet_cb, - NULL); } else { diff --git a/tests/extra/cppcheck.supp b/tests/extra/cppcheck.supp index f71f97a0af..0b9abf4bce 100644 --- a/tests/extra/cppcheck.supp +++ b/tests/extra/cppcheck.supp @@ -5,7 +5,7 @@ preprocessorErrorDirective:src/libvalent/core/valent-global.c:35 # src/libvalent/device/ -memleak:src/libvalent/device/valent-channel.c:325 +memleak:src/libvalent/device/valent-channel.c:315 # src/libvalent/notifications/ leakNoVarFunctionCall:src/libvalent/notifications/valent-notification.c:89 diff --git a/tests/plugins/systemvolume/test-systemvolume-plugin.c b/tests/plugins/systemvolume/test-systemvolume-plugin.c index 4fddf94ec5..238ee7eb56 100644 --- a/tests/plugins/systemvolume/test-systemvolume-plugin.c +++ b/tests/plugins/systemvolume/test-systemvolume-plugin.c @@ -82,12 +82,6 @@ test_systemvolume_plugin_handle_request (ValentTestFixture *fixture, g_assert_cmpstr (json_object_get_string_member (sink_info, "name"), ==, "test_sink1"); json_node_unref (packet); - VALENT_TEST_CHECK ("Plugin requests the sink list on connect"); - packet = valent_test_fixture_expect_packet (fixture); - v_assert_packet_type (packet, "kdeconnect.systemvolume.request"); - v_assert_packet_true (packet, "requestSinks"); - json_node_unref (packet); - VALENT_TEST_CHECK ("Plugin sends the sink list when requested"); packet = valent_test_fixture_lookup_packet (fixture, "request-sinks"); valent_test_fixture_handle_packet (fixture, packet); @@ -250,12 +244,6 @@ test_systemvolume_plugin_handle_sinks (ValentTestFixture *fixture, g_assert_cmpuint (json_array_get_length (sink_list), ==, 0); json_node_unref (packet); - VALENT_TEST_CHECK ("Plugin requests the sink list on connect"); - packet = valent_test_fixture_expect_packet (fixture); - v_assert_packet_type (packet, "kdeconnect.systemvolume.request"); - v_assert_packet_true (packet, "requestSinks"); - json_node_unref (packet); - VALENT_TEST_CHECK ("Plugin handles the sink list"); packet = valent_test_fixture_lookup_packet (fixture, "sinklist-1"); valent_test_fixture_handle_packet (fixture, packet);