From 215877cc60587c1e91b8216dfef1367c7b4577f3 Mon Sep 17 00:00:00 2001 From: Bob Ham Date: Tue, 25 Jun 2019 11:14:16 +0100 Subject: [PATCH] calls-dummy-provider: Create an inbound call on SIGUSR1 This enables easy testing of inbound calls with just $ calls -p dummy & $ killall -USR1 calls --- plugins/dummy/calls-dummy-provider.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/plugins/dummy/calls-dummy-provider.c b/plugins/dummy/calls-dummy-provider.c index cce29ef..d5427af 100644 --- a/plugins/dummy/calls-dummy-provider.c +++ b/plugins/dummy/calls-dummy-provider.c @@ -28,6 +28,7 @@ #include "calls-dummy-origin.h" #include +#include struct _CallsDummyProvider @@ -82,6 +83,22 @@ get_origins (CallsProvider *iface) } +static gboolean +usr1_handler (CallsDummyProvider *self) +{ + CallsDummyOrigin *origin; + + g_return_val_if_fail (self->origins != NULL, FALSE); + + g_debug ("Received SIGUSR1, adding new incoming call"); + + origin = CALLS_DUMMY_ORIGIN (self->origins->data); + calls_dummy_origin_create_inbound (origin, "0987654321"); + + return TRUE; +} + + static void constructed (GObject *object) { @@ -90,6 +107,10 @@ constructed (GObject *object) calls_dummy_provider_add_origin (self, "Dummy origin"); + g_unix_signal_add (SIGUSR1, + (GSourceFunc)usr1_handler, + self); + parent_class->constructed (object); }