diff --git a/src/calls-call.c b/src/calls-call.c index d8a6fa4..313b936 100644 --- a/src/calls-call.c +++ b/src/calls-call.c @@ -47,8 +47,6 @@ */ -G_DEFINE_ABSTRACT_TYPE (CallsCall, calls_call, G_TYPE_OBJECT) - enum { PROP_0, PROP_INBOUND, @@ -56,6 +54,7 @@ enum { PROP_NAME, PROP_STATE, PROP_PROTOCOL, + PROP_SILENCED, N_PROPS, }; @@ -67,6 +66,13 @@ enum { static GParamSpec *properties[N_PROPS]; 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 * 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)); break; + case PROP_SILENCED: + g_value_set_boolean (value, calls_call_get_silenced (self)); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec); } @@ -201,6 +211,13 @@ calls_call_class_init (CallsCallClass *klass) NULL, 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); /** @@ -397,6 +414,43 @@ calls_call_get_contact (CallsCall *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 calls_call_state_to_string (GString *string, CallsCallState state) diff --git a/src/calls-call.h b/src/calls-call.h index 00184a2..ea8f369 100644 --- a/src/calls-call.h +++ b/src/calls-call.h @@ -72,6 +72,8 @@ gboolean calls_call_can_dtmf (CallsCall *self); void calls_call_send_dtmf_tone (CallsCall *self, char key); 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, CallsCallState state);