mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
call: Move state property into base class
This let's us get rid of a lot of duplication in the derived classes. Additionally we set the initial state to CALLS_CALL_STATE_INCOMING if inbound is TRUE and CALLS_CALL_STATE_DIALING otherwise.
This commit is contained in:
parent
ddf1dd7349
commit
a048b4c83d
10 changed files with 100 additions and 243 deletions
|
@ -33,7 +33,6 @@ struct _CallsDummyCall
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
gchar *id;
|
gchar *id;
|
||||||
CallsCallState state;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
static void calls_dummy_call_message_source_interface_init (CallsMessageSourceInterface *iface);
|
static void calls_dummy_call_message_source_interface_init (CallsMessageSourceInterface *iface);
|
||||||
|
@ -49,25 +48,6 @@ enum {
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
static void
|
|
||||||
change_state (CallsDummyCall *self,
|
|
||||||
CallsCallState state)
|
|
||||||
{
|
|
||||||
CallsCallState old_state = self->state;
|
|
||||||
|
|
||||||
if (old_state == state)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->state = state;
|
|
||||||
g_object_notify (G_OBJECT (self), "state");
|
|
||||||
g_signal_emit_by_name (CALLS_CALL (self),
|
|
||||||
"state-changed",
|
|
||||||
state,
|
|
||||||
old_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
calls_dummy_call_get_id (CallsCall *call)
|
calls_dummy_call_get_id (CallsCall *call)
|
||||||
{
|
{
|
||||||
|
@ -76,14 +56,6 @@ calls_dummy_call_get_id (CallsCall *call)
|
||||||
return self->id;
|
return self->id;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CallsCallState
|
|
||||||
calls_dummy_call_get_state (CallsCall *call)
|
|
||||||
{
|
|
||||||
CallsDummyCall *self = CALLS_DUMMY_CALL (call);
|
|
||||||
|
|
||||||
return self->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char*
|
static const char*
|
||||||
calls_dummy_call_get_protocol (CallsCall *call)
|
calls_dummy_call_get_protocol (CallsCall *call)
|
||||||
{
|
{
|
||||||
|
@ -93,25 +65,18 @@ calls_dummy_call_get_protocol (CallsCall *call)
|
||||||
static void
|
static void
|
||||||
calls_dummy_call_answer (CallsCall *call)
|
calls_dummy_call_answer (CallsCall *call)
|
||||||
{
|
{
|
||||||
CallsDummyCall *self;
|
|
||||||
|
|
||||||
g_return_if_fail (CALLS_IS_DUMMY_CALL (call));
|
g_return_if_fail (CALLS_IS_DUMMY_CALL (call));
|
||||||
self = CALLS_DUMMY_CALL (call);
|
g_return_if_fail (calls_call_get_state (call) == CALLS_CALL_STATE_INCOMING);
|
||||||
|
|
||||||
g_return_if_fail (self->state == CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (call, CALLS_CALL_STATE_ACTIVE);
|
||||||
|
|
||||||
change_state (self, CALLS_CALL_STATE_ACTIVE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
calls_dummy_call_hang_up (CallsCall *call)
|
calls_dummy_call_hang_up (CallsCall *call)
|
||||||
{
|
{
|
||||||
CallsDummyCall *self;
|
|
||||||
|
|
||||||
g_return_if_fail (CALLS_IS_DUMMY_CALL (call));
|
g_return_if_fail (CALLS_IS_DUMMY_CALL (call));
|
||||||
self = CALLS_DUMMY_CALL (call);
|
|
||||||
|
|
||||||
change_state (self, CALLS_CALL_STATE_DISCONNECTED);
|
calls_call_set_state (call, CALLS_CALL_STATE_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -124,17 +89,21 @@ calls_dummy_call_send_dtmf_tone (CallsCall *call,
|
||||||
static gboolean
|
static gboolean
|
||||||
outbound_timeout_cb (CallsDummyCall *self)
|
outbound_timeout_cb (CallsDummyCall *self)
|
||||||
{
|
{
|
||||||
switch (self->state) {
|
CallsCall *call;
|
||||||
|
|
||||||
|
g_assert (CALLS_IS_DUMMY_CALL (self));
|
||||||
|
|
||||||
|
call = CALLS_CALL (self);
|
||||||
|
|
||||||
|
switch (calls_call_get_state (call)) {
|
||||||
case CALLS_CALL_STATE_DIALING:
|
case CALLS_CALL_STATE_DIALING:
|
||||||
change_state (self,
|
calls_call_set_state (call, CALLS_CALL_STATE_ALERTING);
|
||||||
CALLS_CALL_STATE_ALERTING);
|
|
||||||
g_timeout_add_seconds
|
g_timeout_add_seconds
|
||||||
(3, (GSourceFunc)outbound_timeout_cb, self);
|
(3, (GSourceFunc)outbound_timeout_cb, self);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case CALLS_CALL_STATE_ALERTING:
|
case CALLS_CALL_STATE_ALERTING:
|
||||||
change_state (self,
|
calls_call_set_state (call, CALLS_CALL_STATE_ACTIVE);
|
||||||
CALLS_CALL_STATE_ACTIVE);
|
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -183,12 +152,8 @@ constructed (GObject *object)
|
||||||
{
|
{
|
||||||
CallsDummyCall *self = CALLS_DUMMY_CALL (object);
|
CallsDummyCall *self = CALLS_DUMMY_CALL (object);
|
||||||
|
|
||||||
if (calls_call_get_inbound (CALLS_CALL (object))) {
|
if (!calls_call_get_inbound (CALLS_CALL (object)))
|
||||||
self->state = CALLS_CALL_STATE_INCOMING;
|
|
||||||
} else {
|
|
||||||
self->state = CALLS_CALL_STATE_DIALING;
|
|
||||||
g_timeout_add_seconds (1, (GSourceFunc)outbound_timeout_cb, self);
|
g_timeout_add_seconds (1, (GSourceFunc)outbound_timeout_cb, self);
|
||||||
}
|
|
||||||
|
|
||||||
G_OBJECT_CLASS (calls_dummy_call_parent_class)->constructed (object);
|
G_OBJECT_CLASS (calls_dummy_call_parent_class)->constructed (object);
|
||||||
}
|
}
|
||||||
|
@ -215,7 +180,6 @@ calls_dummy_call_class_init (CallsDummyCallClass *klass)
|
||||||
object_class->finalize = finalize;
|
object_class->finalize = finalize;
|
||||||
|
|
||||||
call_class->get_id = calls_dummy_call_get_id;
|
call_class->get_id = calls_dummy_call_get_id;
|
||||||
call_class->get_state = calls_dummy_call_get_state;
|
|
||||||
call_class->get_protocol = calls_dummy_call_get_protocol;
|
call_class->get_protocol = calls_dummy_call_get_protocol;
|
||||||
call_class->answer = calls_dummy_call_answer;
|
call_class->answer = calls_dummy_call_answer;
|
||||||
call_class->hang_up = calls_dummy_call_hang_up;
|
call_class->hang_up = calls_dummy_call_hang_up;
|
||||||
|
|
|
@ -38,7 +38,6 @@ struct _CallsMMCall
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
MMCall *mm_call;
|
MMCall *mm_call;
|
||||||
GString *id;
|
GString *id;
|
||||||
CallsCallState state;
|
|
||||||
gchar *disconnect_reason;
|
gchar *disconnect_reason;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -55,26 +54,6 @@ enum {
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
static void
|
|
||||||
change_state (CallsMMCall *self,
|
|
||||||
CallsCallState state)
|
|
||||||
{
|
|
||||||
CallsCallState old_state = self->state;
|
|
||||||
|
|
||||||
if (old_state == state)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->state = state;
|
|
||||||
g_object_notify (G_OBJECT (self), "state");
|
|
||||||
g_signal_emit_by_name (CALLS_CALL (self),
|
|
||||||
"state-changed",
|
|
||||||
state,
|
|
||||||
old_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
notify_id_cb (CallsMMCall *self,
|
notify_id_cb (CallsMMCall *self,
|
||||||
const gchar *id)
|
const gchar *id)
|
||||||
|
@ -185,7 +164,7 @@ state_changed_cb (CallsMMCall *self,
|
||||||
{
|
{
|
||||||
g_debug ("MM call state changed to `%s'",
|
g_debug ("MM call state changed to `%s'",
|
||||||
map_row->name);
|
map_row->name);
|
||||||
change_state (self, map_row->calls);
|
calls_call_set_state (CALLS_CALL (self), map_row->calls);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -199,14 +178,6 @@ calls_mm_call_get_id (CallsCall *call)
|
||||||
return self->id->str;
|
return self->id->str;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CallsCallState
|
|
||||||
calls_mm_call_get_state (CallsCall *call)
|
|
||||||
{
|
|
||||||
CallsMMCall *self = CALLS_MM_CALL (call);
|
|
||||||
|
|
||||||
return self->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
calls_mm_call_get_protocol (CallsCall *self)
|
calls_mm_call_get_protocol (CallsCall *self)
|
||||||
|
@ -369,7 +340,6 @@ calls_mm_call_class_init (CallsMMCallClass *klass)
|
||||||
object_class->finalize = finalize;
|
object_class->finalize = finalize;
|
||||||
|
|
||||||
call_class->get_id = calls_mm_call_get_id;
|
call_class->get_id = calls_mm_call_get_id;
|
||||||
call_class->get_state = calls_mm_call_get_state;
|
|
||||||
call_class->get_protocol = calls_mm_call_get_protocol;
|
call_class->get_protocol = calls_mm_call_get_protocol;
|
||||||
call_class->answer = calls_mm_call_answer;
|
call_class->answer = calls_mm_call_answer;
|
||||||
call_class->hang_up = calls_mm_call_hang_up;
|
call_class->hang_up = calls_mm_call_hang_up;
|
||||||
|
|
|
@ -37,7 +37,6 @@ struct _CallsOfonoCall
|
||||||
GDBOVoiceCall *voice_call;
|
GDBOVoiceCall *voice_call;
|
||||||
gchar *id;
|
gchar *id;
|
||||||
gchar *name;
|
gchar *name;
|
||||||
CallsCallState state;
|
|
||||||
gchar *disconnect_reason;
|
gchar *disconnect_reason;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -61,25 +60,6 @@ enum {
|
||||||
};
|
};
|
||||||
static guint signals [SIGNAL_LAST_SIGNAL];
|
static guint signals [SIGNAL_LAST_SIGNAL];
|
||||||
|
|
||||||
static void
|
|
||||||
change_state (CallsOfonoCall *self,
|
|
||||||
CallsCallState state)
|
|
||||||
{
|
|
||||||
CallsCallState old_state = self->state;
|
|
||||||
|
|
||||||
if (old_state == state)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->state = state;
|
|
||||||
g_object_notify (G_OBJECT (self), "state");
|
|
||||||
g_signal_emit_by_name (CALLS_CALL (self),
|
|
||||||
"state-changed",
|
|
||||||
state,
|
|
||||||
old_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
calls_ofono_call_get_id (CallsCall *call)
|
calls_ofono_call_get_id (CallsCall *call)
|
||||||
{
|
{
|
||||||
|
@ -96,14 +76,6 @@ calls_ofono_call_get_name (CallsCall *call)
|
||||||
return self->name;
|
return self->name;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CallsCallState
|
|
||||||
calls_ofono_call_get_state (CallsCall *call)
|
|
||||||
{
|
|
||||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
|
||||||
|
|
||||||
return self->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
calls_ofono_call_get_protocol (CallsCall *call)
|
calls_ofono_call_get_protocol (CallsCall *call)
|
||||||
{
|
{
|
||||||
|
@ -178,7 +150,7 @@ static void
|
||||||
calls_ofono_call_send_dtmf_tone (CallsCall *call, gchar key)
|
calls_ofono_call_send_dtmf_tone (CallsCall *call, gchar key)
|
||||||
{
|
{
|
||||||
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
CallsOfonoCall *self = CALLS_OFONO_CALL (call);
|
||||||
if (self->state != CALLS_CALL_STATE_ACTIVE) {
|
if (calls_call_get_state (call) != CALLS_CALL_STATE_ACTIVE) {
|
||||||
g_warning ("Tone start requested for non-active call to `%s'",
|
g_warning ("Tone start requested for non-active call to `%s'",
|
||||||
self->id);
|
self->id);
|
||||||
return;
|
return;
|
||||||
|
@ -192,6 +164,7 @@ static void
|
||||||
set_properties (CallsOfonoCall *self,
|
set_properties (CallsOfonoCall *self,
|
||||||
GVariant *call_props)
|
GVariant *call_props)
|
||||||
{
|
{
|
||||||
|
CallsCallState state;
|
||||||
const gchar *str = NULL;
|
const gchar *str = NULL;
|
||||||
|
|
||||||
g_return_if_fail (call_props != NULL);
|
g_return_if_fail (call_props != NULL);
|
||||||
|
@ -201,7 +174,8 @@ set_properties (CallsOfonoCall *self,
|
||||||
|
|
||||||
g_variant_lookup (call_props, "State", "&s", &str);
|
g_variant_lookup (call_props, "State", "&s", &str);
|
||||||
g_return_if_fail (str != NULL);
|
g_return_if_fail (str != NULL);
|
||||||
calls_call_state_parse_nick (&self->state, str);
|
if (calls_call_state_parse_nick (&state, str))
|
||||||
|
calls_call_set_state (CALLS_CALL (self), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -252,7 +226,7 @@ property_changed_cb (CallsOfonoCall *self,
|
||||||
|
|
||||||
ok = calls_call_state_parse_nick (&state, str);
|
ok = calls_call_state_parse_nick (&state, str);
|
||||||
if (ok)
|
if (ok)
|
||||||
change_state (self, state);
|
calls_call_set_state (CALLS_CALL (self), state);
|
||||||
else
|
else
|
||||||
g_warning ("Could not parse new state `%s'"
|
g_warning ("Could not parse new state `%s'"
|
||||||
" of oFono call to `%s'",
|
" of oFono call to `%s'",
|
||||||
|
@ -329,7 +303,6 @@ calls_ofono_call_class_init (CallsOfonoCallClass *klass)
|
||||||
|
|
||||||
call_class->get_id = calls_ofono_call_get_id;
|
call_class->get_id = calls_ofono_call_get_id;
|
||||||
call_class->get_name = calls_ofono_call_get_name;
|
call_class->get_name = calls_ofono_call_get_name;
|
||||||
call_class->get_state = calls_ofono_call_get_state;
|
|
||||||
call_class->get_protocol = calls_ofono_call_get_protocol;
|
call_class->get_protocol = calls_ofono_call_get_protocol;
|
||||||
call_class->answer = calls_ofono_call_answer;
|
call_class->answer = calls_ofono_call_answer;
|
||||||
call_class->hang_up = calls_ofono_call_hang_up;
|
call_class->hang_up = calls_ofono_call_hang_up;
|
||||||
|
@ -407,7 +380,7 @@ calls_ofono_call_new (GDBOVoiceCall *voice_call,
|
||||||
//"id", id,
|
//"id", id,
|
||||||
//"name", name,
|
//"name", name,
|
||||||
"inbound", inbound,
|
"inbound", inbound,
|
||||||
//"state", state,
|
"state", state,
|
||||||
NULL);
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -58,7 +58,6 @@ struct _CallsSipCall
|
||||||
{
|
{
|
||||||
GObject parent_instance;
|
GObject parent_instance;
|
||||||
gchar *id;
|
gchar *id;
|
||||||
CallsCallState state;
|
|
||||||
|
|
||||||
CallsSipMediaManager *manager;
|
CallsSipMediaManager *manager;
|
||||||
CallsSipMediaPipeline *pipeline;
|
CallsSipMediaPipeline *pipeline;
|
||||||
|
@ -125,15 +124,6 @@ calls_sip_call_get_id (CallsCall *call)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CallsCallState
|
|
||||||
calls_sip_call_get_state (CallsCall *call)
|
|
||||||
{
|
|
||||||
CallsSipCall *self = CALLS_SIP_CALL (call);
|
|
||||||
|
|
||||||
return self->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
calls_sip_call_get_protocol (CallsCall *call)
|
calls_sip_call_get_protocol (CallsCall *call)
|
||||||
{
|
{
|
||||||
|
@ -157,7 +147,7 @@ calls_sip_call_answer (CallsCall *call)
|
||||||
|
|
||||||
g_assert (self->nh);
|
g_assert (self->nh);
|
||||||
|
|
||||||
if (self->state != CALLS_CALL_STATE_INCOMING) {
|
if (calls_call_get_state (CALLS_CALL (self)) != CALLS_CALL_STATE_INCOMING) {
|
||||||
g_warning ("Call must be in 'incoming' state in order to answer");
|
g_warning ("Call must be in 'incoming' state in order to answer");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -178,7 +168,7 @@ calls_sip_call_answer (CallsCall *call)
|
||||||
SOATAG_AF (SOA_AF_IP4_IP6),
|
SOATAG_AF (SOA_AF_IP4_IP6),
|
||||||
TAG_END ());
|
TAG_END ());
|
||||||
|
|
||||||
calls_sip_call_set_state (self, CALLS_CALL_STATE_ACTIVE);
|
calls_call_set_state (CALLS_CALL (self), CALLS_CALL_STATE_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -192,7 +182,7 @@ calls_sip_call_hang_up (CallsCall *call)
|
||||||
|
|
||||||
self = CALLS_SIP_CALL (call);
|
self = CALLS_SIP_CALL (call);
|
||||||
|
|
||||||
switch (self->state) {
|
switch (calls_call_get_state (call)) {
|
||||||
case CALLS_CALL_STATE_DIALING:
|
case CALLS_CALL_STATE_DIALING:
|
||||||
nua_cancel (self->nh, TAG_END ());
|
nua_cancel (self->nh, TAG_END ());
|
||||||
g_debug ("Hanging up on outgoing ringing call");
|
g_debug ("Hanging up on outgoing ringing call");
|
||||||
|
@ -214,7 +204,8 @@ calls_sip_call_hang_up (CallsCall *call)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_warning ("Hanging up not possible in state %d", self->state);
|
g_warning ("Hanging up not possible in state %d",
|
||||||
|
calls_call_get_state (call));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -288,7 +279,6 @@ calls_sip_call_class_init (CallsSipCallClass *klass)
|
||||||
object_class->finalize = calls_sip_call_finalize;
|
object_class->finalize = calls_sip_call_finalize;
|
||||||
|
|
||||||
call_class->get_id = calls_sip_call_get_id;
|
call_class->get_id = calls_sip_call_get_id;
|
||||||
call_class->get_state = calls_sip_call_get_state;
|
|
||||||
call_class->get_protocol = calls_sip_call_get_protocol;
|
call_class->get_protocol = calls_sip_call_get_protocol;
|
||||||
call_class->answer = calls_sip_call_answer;
|
call_class->answer = calls_sip_call_answer;
|
||||||
call_class->hang_up = calls_sip_call_hang_up;
|
call_class->hang_up = calls_sip_call_hang_up;
|
||||||
|
@ -394,48 +384,14 @@ calls_sip_call_new (const gchar *id,
|
||||||
call = g_object_new (CALLS_TYPE_SIP_CALL,
|
call = g_object_new (CALLS_TYPE_SIP_CALL,
|
||||||
"nua-handle", handle,
|
"nua-handle", handle,
|
||||||
"inbound", inbound,
|
"inbound", inbound,
|
||||||
|
"state", inbound ? CALLS_CALL_STATE_INCOMING : CALLS_CALL_STATE_DIALING,
|
||||||
NULL);
|
NULL);
|
||||||
|
|
||||||
call->id = g_strdup (id);
|
call->id = g_strdup (id);
|
||||||
|
|
||||||
if (inbound)
|
|
||||||
call->state = CALLS_CALL_STATE_INCOMING;
|
|
||||||
else
|
|
||||||
call->state = CALLS_CALL_STATE_DIALING;
|
|
||||||
|
|
||||||
return call;
|
return call;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* calls_sip_call_set_state:
|
|
||||||
* @self: A #CallsSipCall
|
|
||||||
* @state: The new #CallsCallState to set
|
|
||||||
*
|
|
||||||
* Sets the new call state and emits the state-changed signal
|
|
||||||
*/
|
|
||||||
void
|
|
||||||
calls_sip_call_set_state (CallsSipCall *self,
|
|
||||||
CallsCallState state)
|
|
||||||
{
|
|
||||||
CallsCallState old_state;
|
|
||||||
|
|
||||||
g_return_if_fail (CALLS_IS_CALL (self));
|
|
||||||
g_return_if_fail (CALLS_IS_SIP_CALL (self));
|
|
||||||
|
|
||||||
old_state = self->state;
|
|
||||||
|
|
||||||
if (old_state == state) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->state = state;
|
|
||||||
g_object_notify (G_OBJECT (self), "state");
|
|
||||||
g_signal_emit_by_name (CALLS_CALL (self),
|
|
||||||
"state-changed",
|
|
||||||
state,
|
|
||||||
old_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* calls_sip_call_set_codecs:
|
* calls_sip_call_set_codecs:
|
||||||
* @self: A #CallsSipCall
|
* @self: A #CallsSipCall
|
||||||
|
|
|
@ -575,7 +575,7 @@ sip_i_state (int status,
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
calls_sip_call_set_state (call, state);
|
calls_call_set_state (CALLS_CALL (call), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -67,6 +67,7 @@ static GParamSpec *properties[N_PROPS];
|
||||||
static guint signals[N_SIGNALS];
|
static guint signals[N_SIGNALS];
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
CallsCallState state;
|
||||||
gboolean inbound;
|
gboolean inbound;
|
||||||
gboolean silenced;
|
gboolean silenced;
|
||||||
} CallsCallPrivate;
|
} CallsCallPrivate;
|
||||||
|
@ -86,12 +87,6 @@ calls_call_real_get_name (CallsCall *self)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static CallsCallState
|
|
||||||
calls_call_real_get_state (CallsCall *self)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static const char *
|
static const char *
|
||||||
calls_call_real_get_protocol (CallsCall *self)
|
calls_call_real_get_protocol (CallsCall *self)
|
||||||
{
|
{
|
||||||
|
@ -127,6 +122,14 @@ calls_call_set_property (GObject *object,
|
||||||
switch (prop_id) {
|
switch (prop_id) {
|
||||||
case PROP_INBOUND:
|
case PROP_INBOUND:
|
||||||
priv->inbound = g_value_get_boolean (value);
|
priv->inbound = g_value_get_boolean (value);
|
||||||
|
if (priv->inbound)
|
||||||
|
calls_call_set_state (self, CALLS_CALL_STATE_INCOMING);
|
||||||
|
else
|
||||||
|
calls_call_set_state (self, CALLS_CALL_STATE_DIALING);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case PROP_STATE:
|
||||||
|
calls_call_set_state (self, g_value_get_enum (value));
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -183,7 +186,6 @@ calls_call_class_init (CallsCallClass *klass)
|
||||||
|
|
||||||
klass->get_id = calls_call_real_get_id;
|
klass->get_id = calls_call_real_get_id;
|
||||||
klass->get_name = calls_call_real_get_name;
|
klass->get_name = calls_call_real_get_name;
|
||||||
klass->get_state = calls_call_real_get_state;
|
|
||||||
klass->get_protocol = calls_call_real_get_protocol;
|
klass->get_protocol = calls_call_real_get_protocol;
|
||||||
klass->answer = calls_call_real_answer;
|
klass->answer = calls_call_real_answer;
|
||||||
klass->hang_up = calls_call_real_hang_up;
|
klass->hang_up = calls_call_real_hang_up;
|
||||||
|
@ -216,7 +218,9 @@ calls_call_class_init (CallsCallClass *klass)
|
||||||
"The current state of the call",
|
"The current state of the call",
|
||||||
CALLS_TYPE_CALL_STATE,
|
CALLS_TYPE_CALL_STATE,
|
||||||
CALLS_CALL_STATE_UNKNOWN,
|
CALLS_CALL_STATE_UNKNOWN,
|
||||||
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
|
G_PARAM_READWRITE |
|
||||||
|
G_PARAM_EXPLICIT_NOTIFY |
|
||||||
|
G_PARAM_STATIC_STRINGS);
|
||||||
|
|
||||||
properties[PROP_PROTOCOL] =
|
properties[PROP_PROTOCOL] =
|
||||||
g_param_spec_string ("protocol",
|
g_param_spec_string ("protocol",
|
||||||
|
@ -303,9 +307,42 @@ calls_call_get_name (CallsCall *self)
|
||||||
CallsCallState
|
CallsCallState
|
||||||
calls_call_get_state (CallsCall *self)
|
calls_call_get_state (CallsCall *self)
|
||||||
{
|
{
|
||||||
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
||||||
|
|
||||||
g_return_val_if_fail (CALLS_IS_CALL (self), 0);
|
g_return_val_if_fail (CALLS_IS_CALL (self), 0);
|
||||||
|
|
||||||
return CALLS_CALL_GET_CLASS (self)->get_state (self);
|
return priv->state;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* calls_call_set_state:
|
||||||
|
* @self: a #CallsCall
|
||||||
|
* @state: a #CallsCallState
|
||||||
|
*
|
||||||
|
* Set the current state of the call.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
calls_call_set_state (CallsCall *self,
|
||||||
|
CallsCallState state)
|
||||||
|
{
|
||||||
|
CallsCallPrivate *priv = calls_call_get_instance_private (self);
|
||||||
|
CallsCallState old_state;
|
||||||
|
|
||||||
|
g_return_if_fail (CALLS_IS_CALL (self));
|
||||||
|
|
||||||
|
old_state = priv->state;
|
||||||
|
|
||||||
|
if (old_state == state) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
priv->state = state;
|
||||||
|
|
||||||
|
g_object_notify_by_pspec (G_OBJECT (self), properties[PROP_STATE]);
|
||||||
|
g_signal_emit_by_name (CALLS_CALL (self),
|
||||||
|
"state-changed",
|
||||||
|
state,
|
||||||
|
old_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -53,7 +53,6 @@ struct _CallsCallClass
|
||||||
|
|
||||||
const char *(*get_id) (CallsCall *self);
|
const char *(*get_id) (CallsCall *self);
|
||||||
const char *(*get_name) (CallsCall *self);
|
const char *(*get_name) (CallsCall *self);
|
||||||
CallsCallState (*get_state) (CallsCall *self);
|
|
||||||
const char *(*get_protocol) (CallsCall *self);
|
const char *(*get_protocol) (CallsCall *self);
|
||||||
void (*answer) (CallsCall *self);
|
void (*answer) (CallsCall *self);
|
||||||
void (*hang_up) (CallsCall *self);
|
void (*hang_up) (CallsCall *self);
|
||||||
|
@ -61,19 +60,21 @@ struct _CallsCallClass
|
||||||
char key);
|
char key);
|
||||||
};
|
};
|
||||||
|
|
||||||
const char *calls_call_get_id (CallsCall *self);
|
const char *calls_call_get_id (CallsCall *self);
|
||||||
const char *calls_call_get_name (CallsCall *self);
|
const char *calls_call_get_name (CallsCall *self);
|
||||||
CallsCallState calls_call_get_state (CallsCall *self);
|
CallsCallState calls_call_get_state (CallsCall *self);
|
||||||
gboolean calls_call_get_inbound (CallsCall *self);
|
void calls_call_set_state (CallsCall *self,
|
||||||
const char *calls_call_get_protocol (CallsCall *self);
|
CallsCallState state);
|
||||||
void calls_call_answer (CallsCall *self);
|
gboolean calls_call_get_inbound (CallsCall *self);
|
||||||
void calls_call_hang_up (CallsCall *self);
|
const char *calls_call_get_protocol (CallsCall *self);
|
||||||
gboolean calls_call_can_dtmf (CallsCall *self);
|
void calls_call_answer (CallsCall *self);
|
||||||
void calls_call_send_dtmf_tone (CallsCall *self,
|
void calls_call_hang_up (CallsCall *self);
|
||||||
char key);
|
gboolean calls_call_can_dtmf (CallsCall *self);
|
||||||
CallsBestMatch *calls_call_get_contact (CallsCall *self);
|
void calls_call_send_dtmf_tone (CallsCall *self,
|
||||||
void calls_call_silence_ring (CallsCall *self);
|
char key);
|
||||||
gboolean calls_call_get_silenced (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);
|
||||||
|
|
|
@ -15,7 +15,6 @@ enum {
|
||||||
PROP_0,
|
PROP_0,
|
||||||
PROP_NAME,
|
PROP_NAME,
|
||||||
PROP_ID,
|
PROP_ID,
|
||||||
PROP_STATE,
|
|
||||||
PROP_LAST_PROP,
|
PROP_LAST_PROP,
|
||||||
};
|
};
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
@ -26,7 +25,6 @@ struct _CallsMockCall
|
||||||
|
|
||||||
char *id;
|
char *id;
|
||||||
char *display_name;
|
char *display_name;
|
||||||
CallsCallState state;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
G_DEFINE_TYPE (CallsMockCall, calls_mock_call, CALLS_TYPE_CALL)
|
G_DEFINE_TYPE (CallsMockCall, calls_mock_call, CALLS_TYPE_CALL)
|
||||||
|
@ -38,7 +36,7 @@ calls_mock_call_answer (CallsCall *call)
|
||||||
g_assert (CALLS_IS_MOCK_CALL (call));
|
g_assert (CALLS_IS_MOCK_CALL (call));
|
||||||
g_assert_cmpint (calls_call_get_state (call), ==, CALLS_CALL_STATE_INCOMING);
|
g_assert_cmpint (calls_call_get_state (call), ==, CALLS_CALL_STATE_INCOMING);
|
||||||
|
|
||||||
calls_mock_call_set_state (CALLS_MOCK_CALL (call), CALLS_CALL_STATE_ACTIVE);
|
calls_call_set_state (call, CALLS_CALL_STATE_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -48,18 +46,10 @@ calls_mock_call_hang_up (CallsCall *call)
|
||||||
g_assert (CALLS_IS_MOCK_CALL (call));
|
g_assert (CALLS_IS_MOCK_CALL (call));
|
||||||
g_assert_cmpint (calls_call_get_state (call), !=, CALLS_CALL_STATE_DISCONNECTED);
|
g_assert_cmpint (calls_call_get_state (call), !=, CALLS_CALL_STATE_DISCONNECTED);
|
||||||
|
|
||||||
calls_mock_call_set_state (CALLS_MOCK_CALL (call), CALLS_CALL_STATE_DISCONNECTED);
|
calls_call_set_state (call, CALLS_CALL_STATE_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static CallsCallState
|
|
||||||
calls_mock_call_get_state (CallsCall *call)
|
|
||||||
{
|
|
||||||
g_assert (CALLS_IS_MOCK_CALL (call));
|
|
||||||
|
|
||||||
return CALLS_MOCK_CALL (call)->state;
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
calls_mock_call_get_property (GObject *object,
|
calls_mock_call_get_property (GObject *object,
|
||||||
guint prop_id,
|
guint prop_id,
|
||||||
|
@ -75,9 +65,6 @@ calls_mock_call_get_property (GObject *object,
|
||||||
case PROP_NAME:
|
case PROP_NAME:
|
||||||
g_value_set_string (value, self->display_name);
|
g_value_set_string (value, self->display_name);
|
||||||
break;
|
break;
|
||||||
case PROP_STATE:
|
|
||||||
g_value_set_enum (value, self->state);
|
|
||||||
break;
|
|
||||||
default:
|
default:
|
||||||
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
|
||||||
}
|
}
|
||||||
|
@ -104,7 +91,6 @@ calls_mock_call_class_init (CallsMockCallClass *klass)
|
||||||
|
|
||||||
call_class->answer = calls_mock_call_answer;
|
call_class->answer = calls_mock_call_answer;
|
||||||
call_class->hang_up = calls_mock_call_hang_up;
|
call_class->hang_up = calls_mock_call_hang_up;
|
||||||
call_class->get_state = calls_mock_call_get_state;
|
|
||||||
|
|
||||||
object_class->get_property = calls_mock_call_get_property;
|
object_class->get_property = calls_mock_call_get_property;
|
||||||
object_class->finalize = calls_mock_call_finalize;
|
object_class->finalize = calls_mock_call_finalize;
|
||||||
|
@ -118,12 +104,6 @@ calls_mock_call_class_init (CallsMockCallClass *klass)
|
||||||
PROP_NAME,
|
PROP_NAME,
|
||||||
"name");
|
"name");
|
||||||
props[PROP_NAME] = g_object_class_find_property (object_class, "name");
|
props[PROP_NAME] = g_object_class_find_property (object_class, "name");
|
||||||
|
|
||||||
g_object_class_override_property (object_class,
|
|
||||||
PROP_STATE,
|
|
||||||
"state");
|
|
||||||
props[PROP_STATE] = g_object_class_find_property (object_class, "state");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -132,14 +112,15 @@ calls_mock_call_init (CallsMockCall *self)
|
||||||
{
|
{
|
||||||
self->display_name = g_strdup ("John Doe");
|
self->display_name = g_strdup ("John Doe");
|
||||||
self->id = g_strdup ("0800 1234");
|
self->id = g_strdup ("0800 1234");
|
||||||
self->state = CALLS_CALL_STATE_INCOMING;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
CallsMockCall *
|
CallsMockCall *
|
||||||
calls_mock_call_new (void)
|
calls_mock_call_new (void)
|
||||||
{
|
{
|
||||||
return g_object_new (CALLS_TYPE_MOCK_CALL, NULL);
|
return g_object_new (CALLS_TYPE_MOCK_CALL,
|
||||||
|
"inbound", TRUE,
|
||||||
|
NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -167,26 +148,3 @@ calls_mock_call_set_name (CallsMockCall *self,
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NAME]);
|
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_NAME]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void
|
|
||||||
calls_mock_call_set_state (CallsMockCall *self,
|
|
||||||
CallsCallState state)
|
|
||||||
{
|
|
||||||
CallsCallState old_state;
|
|
||||||
|
|
||||||
g_return_if_fail (CALLS_IS_MOCK_CALL (self));
|
|
||||||
|
|
||||||
old_state = self->state;
|
|
||||||
if (old_state == state)
|
|
||||||
return;
|
|
||||||
|
|
||||||
self->state = state;
|
|
||||||
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_STATE]);
|
|
||||||
g_signal_emit_by_name (CALLS_CALL (self),
|
|
||||||
"state-changed",
|
|
||||||
state,
|
|
||||||
old_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -22,7 +22,5 @@ void calls_mock_call_set_id (CallsMockCall *self,
|
||||||
const char *id);
|
const char *id);
|
||||||
void calls_mock_call_set_name (CallsMockCall *self,
|
void calls_mock_call_set_name (CallsMockCall *self,
|
||||||
const char *name);
|
const char *name);
|
||||||
void calls_mock_call_set_state (CallsMockCall *self,
|
|
||||||
CallsCallState state);
|
|
||||||
|
|
||||||
G_END_DECLS
|
G_END_DECLS
|
||||||
|
|
|
@ -251,7 +251,7 @@ test_ringing_accept_call (void **state)
|
||||||
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
||||||
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
||||||
|
|
||||||
calls_mock_call_set_state (data->call_one, CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (CALLS_CALL (data->call_one), CALLS_CALL_STATE_INCOMING);
|
||||||
add_call (data->manager, data->call_one);
|
add_call (data->manager, data->call_one);
|
||||||
|
|
||||||
/* main loop will quit in callback of notify::ring */
|
/* main loop will quit in callback of notify::ring */
|
||||||
|
@ -302,7 +302,7 @@ test_ringing_hang_up_call (void **state)
|
||||||
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
||||||
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
||||||
|
|
||||||
calls_mock_call_set_state (data->call_one, CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (CALLS_CALL (data->call_one), CALLS_CALL_STATE_INCOMING);
|
||||||
add_call (data->manager, data->call_one);
|
add_call (data->manager, data->call_one);
|
||||||
|
|
||||||
/* main loop will quit in callback of notify::ring */
|
/* main loop will quit in callback of notify::ring */
|
||||||
|
@ -346,7 +346,7 @@ test_ringing_hang_up_call_ringer_cancelled (void **state)
|
||||||
/* delay before completion of __wrap_lfb_event_trigger_feedback_async() */
|
/* delay before completion of __wrap_lfb_event_trigger_feedback_async() */
|
||||||
will_return (__wrap_lfb_event_trigger_feedback_async, 50);
|
will_return (__wrap_lfb_event_trigger_feedback_async, 50);
|
||||||
|
|
||||||
calls_mock_call_set_state (data->call_one, CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (CALLS_CALL (data->call_one), CALLS_CALL_STATE_INCOMING);
|
||||||
add_call (data->manager, data->call_one);
|
add_call (data->manager, data->call_one);
|
||||||
|
|
||||||
g_timeout_add (10, G_SOURCE_FUNC (t3_on_ringer_timeout), data);
|
g_timeout_add (10, G_SOURCE_FUNC (t3_on_ringer_timeout), data);
|
||||||
|
@ -400,7 +400,7 @@ test_ringing_silence_call (void **state)
|
||||||
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
||||||
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
||||||
|
|
||||||
calls_mock_call_set_state (data->call_one, CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (CALLS_CALL (data->call_one), CALLS_CALL_STATE_INCOMING);
|
||||||
add_call (data->manager, data->call_one);
|
add_call (data->manager, data->call_one);
|
||||||
|
|
||||||
/* main loop will quit in callback of notify::ring */
|
/* main loop will quit in callback of notify::ring */
|
||||||
|
@ -472,7 +472,7 @@ test_ringing_multiple_calls (void **state)
|
||||||
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
||||||
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
will_return (__wrap_lfb_event_end_feedback_async, 10);
|
||||||
|
|
||||||
calls_mock_call_set_state (data->call_one, CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (CALLS_CALL (data->call_one), CALLS_CALL_STATE_INCOMING);
|
||||||
add_call (data->manager, data->call_one);
|
add_call (data->manager, data->call_one);
|
||||||
|
|
||||||
/* main loop will quit in callback of notify::ring */
|
/* main loop will quit in callback of notify::ring */
|
||||||
|
@ -537,9 +537,9 @@ test_ringing_multiple_calls_with_restart (void **state)
|
||||||
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
/* delay before completion of __wrap_lfb_event_end_feedback_async() */
|
||||||
will_return_always (__wrap_lfb_event_end_feedback_async, 10);
|
will_return_always (__wrap_lfb_event_end_feedback_async, 10);
|
||||||
|
|
||||||
calls_mock_call_set_state (data->call_one, CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (CALLS_CALL (data->call_one), CALLS_CALL_STATE_INCOMING);
|
||||||
add_call (data->manager, data->call_one);
|
add_call (data->manager, data->call_one);
|
||||||
calls_mock_call_set_state (data->call_two, CALLS_CALL_STATE_INCOMING);
|
calls_call_set_state (CALLS_CALL (data->call_two), CALLS_CALL_STATE_INCOMING);
|
||||||
add_call (data->manager, data->call_two);
|
add_call (data->manager, data->call_two);
|
||||||
|
|
||||||
/* main loop will quit in callback of notify::ring */
|
/* main loop will quit in callback of notify::ring */
|
||||||
|
|
Loading…
Reference in a new issue