From 3ac8cc1580325a3e12155e9c03d695da74c55392 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 17 Feb 2022 10:53:14 +0100 Subject: [PATCH] dummy-provider: Add new anonymous incoming call on SIGUSR2 --- plugins/dummy/calls-dummy-call.c | 2 -- plugins/dummy/calls-dummy-origin.c | 1 - plugins/dummy/calls-dummy-provider.c | 22 ++++++++++++++++++++++ 3 files changed, 22 insertions(+), 3 deletions(-) diff --git a/plugins/dummy/calls-dummy-call.c b/plugins/dummy/calls-dummy-call.c index fd40bd5..38db95c 100644 --- a/plugins/dummy/calls-dummy-call.c +++ b/plugins/dummy/calls-dummy-call.c @@ -102,8 +102,6 @@ CallsDummyCall * calls_dummy_call_new (const gchar *id, gboolean inbound) { - g_return_val_if_fail (id != NULL, NULL); - return g_object_new (CALLS_TYPE_DUMMY_CALL, "id", id, "inbound", inbound, diff --git a/plugins/dummy/calls-dummy-origin.c b/plugins/dummy/calls-dummy-origin.c index 820a7dc..25626d9 100644 --- a/plugins/dummy/calls-dummy-origin.c +++ b/plugins/dummy/calls-dummy-origin.c @@ -296,7 +296,6 @@ void calls_dummy_origin_create_inbound (CallsDummyOrigin *self, const gchar *number) { - g_return_if_fail (number != NULL); g_return_if_fail (CALLS_IS_DUMMY_ORIGIN (self)); add_call (self, number, TRUE); diff --git a/plugins/dummy/calls-dummy-provider.c b/plugins/dummy/calls-dummy-provider.c index 869d14e..fe9d05d 100644 --- a/plugins/dummy/calls-dummy-provider.c +++ b/plugins/dummy/calls-dummy-provider.c @@ -81,6 +81,25 @@ usr1_handler (CallsDummyProvider *self) return TRUE; } + +static gboolean +usr2_handler (CallsDummyProvider *self) +{ + GListModel *model; + g_autoptr(CallsDummyOrigin) origin = NULL; + + model = G_LIST_MODEL (self->origins); + g_return_val_if_fail (g_list_model_get_n_items (model) > 0, FALSE); + + g_debug ("Received SIGUSR2, adding new anonymous incoming call"); + + origin = g_list_model_get_item (model, 0); + calls_dummy_origin_create_inbound (origin, NULL); + + return TRUE; +} + + static const char * calls_dummy_provider_get_name (CallsProvider *provider) { @@ -123,6 +142,9 @@ constructed (GObject *object) g_unix_signal_add (SIGUSR1, (GSourceFunc)usr1_handler, self); + g_unix_signal_add (SIGUSR2, + (GSourceFunc) usr2_handler, + self); G_OBJECT_CLASS (calls_dummy_provider_parent_class)->constructed (object); }