1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-14 00:17:35 +00:00

call: Add API to silence ringing

This commit is contained in:
Evangelos Ribeiro Tzaras 2021-10-19 01:43:25 +02:00
parent f02d22150e
commit 1587e4c78c
2 changed files with 58 additions and 2 deletions

View file

@ -47,8 +47,6 @@
*/ */
G_DEFINE_ABSTRACT_TYPE (CallsCall, calls_call, G_TYPE_OBJECT)
enum { enum {
PROP_0, PROP_0,
PROP_INBOUND, PROP_INBOUND,
@ -56,6 +54,7 @@ enum {
PROP_NAME, PROP_NAME,
PROP_STATE, PROP_STATE,
PROP_PROTOCOL, PROP_PROTOCOL,
PROP_SILENCED,
N_PROPS, N_PROPS,
}; };
@ -67,6 +66,13 @@ enum {
static GParamSpec *properties[N_PROPS]; static GParamSpec *properties[N_PROPS];
static guint signals[N_SIGNALS]; static guint signals[N_SIGNALS];
typedef struct {
gboolean silenced;
} CallsCallPrivate;
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (CallsCall, calls_call, G_TYPE_OBJECT)
static const char * static const char *
calls_call_real_get_id (CallsCall *self) calls_call_real_get_id (CallsCall *self)
{ {
@ -144,6 +150,10 @@ calls_call_get_property (GObject *object,
g_value_set_string (value, calls_call_get_protocol (self)); g_value_set_string (value, calls_call_get_protocol (self));
break; break;
case PROP_SILENCED:
g_value_set_boolean (value, calls_call_get_silenced (self));
break;
default: default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
} }
@ -201,6 +211,13 @@ calls_call_class_init (CallsCallClass *klass)
NULL, NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS); G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
properties[PROP_SILENCED] =
g_param_spec_boolean ("silenced",
"Silenced",
"Whether the call ringing should be silenced",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_properties (object_class, N_PROPS, properties); g_object_class_install_properties (object_class, N_PROPS, properties);
/** /**
@ -397,6 +414,43 @@ calls_call_get_contact (CallsCall *self)
calls_call_get_id (self)); calls_call_get_id (self));
} }
/**
* calls_call_silence_ring:
* @self: a #CallsCall
*
* Inhibit ringing
*/
void
calls_call_silence_ring (CallsCall *self)
{
CallsCallPrivate *priv = calls_call_get_instance_private (self);
g_return_if_fail (CALLS_IS_CALL (self));
g_return_if_fail (calls_call_get_state (self) == CALLS_CALL_STATE_INCOMING);
if (priv->silenced)
return;
priv->silenced = TRUE;
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_SILENCED]);
}
/**
* calls_call_get_silenced:
* @self: a #CallsCall
*
* Returns: %TRUE if call has been silenced to not ring, %FALSE otherwise
*/
gboolean
calls_call_get_silenced (CallsCall *self)
{
CallsCallPrivate *priv = calls_call_get_instance_private (self);
g_return_val_if_fail (CALLS_IS_CALL (self), FALSE);
return priv->silenced;
}
void void
calls_call_state_to_string (GString *string, calls_call_state_to_string (GString *string,
CallsCallState state) CallsCallState state)

View file

@ -72,6 +72,8 @@ gboolean calls_call_can_dtmf (CallsCall *self);
void calls_call_send_dtmf_tone (CallsCall *self, void calls_call_send_dtmf_tone (CallsCall *self,
char key); char key);
CallsBestMatch *calls_call_get_contact (CallsCall *self); CallsBestMatch *calls_call_get_contact (CallsCall *self);
void calls_call_silence_ring (CallsCall *self);
gboolean calls_call_get_silenced (CallsCall *self);
void calls_call_state_to_string (GString *string, void calls_call_state_to_string (GString *string,
CallsCallState state); CallsCallState state);