Skip to content

Commit

Permalink
refactor(systemvolume): don't send requestSinks command at connect
Browse files Browse the repository at this point in the history
  • Loading branch information
andyholmes committed Dec 5, 2024
1 parent 749e153 commit d98cf25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
31 changes: 20 additions & 11 deletions src/plugins/systemvolume/valent-systemvolume-device.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand All @@ -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
{
Expand Down
2 changes: 1 addition & 1 deletion tests/extra/cppcheck.supp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 0 additions & 12 deletions tests/plugins/systemvolume/test-systemvolume-plugin.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit d98cf25

Please sign in to comment.