mirror of
https://gitlab.gnome.org/GNOME/calls.git
synced 2025-01-07 12:25:31 +00:00
sip: call: rework call state changes
This commit is contained in:
parent
706a667547
commit
3133f25c6b
2 changed files with 27 additions and 36 deletions
|
@ -68,30 +68,6 @@ enum {
|
||||||
static GParamSpec *props[PROP_LAST_PROP];
|
static GParamSpec *props[PROP_LAST_PROP];
|
||||||
|
|
||||||
|
|
||||||
static void
|
|
||||||
change_state (CallsSipCall *self,
|
|
||||||
CallsCallState state)
|
|
||||||
{
|
|
||||||
CallsCallState old_state;
|
|
||||||
|
|
||||||
g_assert (CALLS_IS_CALL (self));
|
|
||||||
g_assert (CALLS_IS_SIP_CALL (self));
|
|
||||||
|
|
||||||
old_state = self->state;
|
|
||||||
|
|
||||||
if (old_state == state)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
self->state = state;
|
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
|
|
||||||
g_signal_emit_by_name (CALLS_CALL (self),
|
|
||||||
"state-changed",
|
|
||||||
state,
|
|
||||||
old_state);
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
answer (CallsCall *call)
|
answer (CallsCall *call)
|
||||||
{
|
{
|
||||||
|
@ -125,7 +101,7 @@ answer (CallsCall *call)
|
||||||
SOATAG_AF (SOA_AF_IP4_IP6),
|
SOATAG_AF (SOA_AF_IP4_IP6),
|
||||||
TAG_END ());
|
TAG_END ());
|
||||||
|
|
||||||
change_state (self, CALLS_CALL_STATE_ACTIVE);
|
calls_sip_call_set_state (self, CALLS_CALL_STATE_ACTIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -157,13 +133,13 @@ hang_up (CallsCall *call)
|
||||||
|
|
||||||
case CALLS_CALL_STATE_DISCONNECTED:
|
case CALLS_CALL_STATE_DISCONNECTED:
|
||||||
g_warning ("Tried hanging up already disconnected call");
|
g_warning ("Tried hanging up already disconnected call");
|
||||||
return;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
g_warning ("Hanging up not possible in state %d", self->state);
|
g_warning ("Hanging up not possible in state %d", self->state);
|
||||||
}
|
}
|
||||||
|
|
||||||
change_state (self, CALLS_CALL_STATE_DISCONNECTED);
|
calls_sip_call_set_state (self, CALLS_CALL_STATE_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -383,12 +359,25 @@ calls_sip_call_new (const gchar *number,
|
||||||
|
|
||||||
|
|
||||||
void
|
void
|
||||||
calls_sip_call_set_state (CallsSipCall *self,
|
calls_sip_call_set_state (CallsSipCall *self,
|
||||||
CallsCallState state)
|
CallsCallState state)
|
||||||
{
|
{
|
||||||
|
CallsCallState old_state;
|
||||||
|
|
||||||
|
g_return_if_fail (CALLS_IS_CALL (self));
|
||||||
g_return_if_fail (CALLS_IS_SIP_CALL (self));
|
g_return_if_fail (CALLS_IS_SIP_CALL (self));
|
||||||
|
|
||||||
g_print ("Changed call state to %d\n", state);
|
old_state = self->state;
|
||||||
|
|
||||||
|
if (old_state == state) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
self->state = state;
|
self->state = state;
|
||||||
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
|
g_object_notify_by_pspec (G_OBJECT (self), props[PROP_CALL_STATE]);
|
||||||
|
g_signal_emit_by_name (CALLS_CALL (self),
|
||||||
|
"state-changed",
|
||||||
|
state,
|
||||||
|
old_state);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -246,6 +246,7 @@ sip_i_state (int status,
|
||||||
|
|
||||||
case nua_callstate_received:
|
case nua_callstate_received:
|
||||||
state = CALLS_CALL_STATE_INCOMING;
|
state = CALLS_CALL_STATE_INCOMING;
|
||||||
|
g_debug ("Call incoming");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case nua_callstate_ready:
|
case nua_callstate_ready:
|
||||||
|
@ -260,7 +261,13 @@ sip_i_state (int status,
|
||||||
|
|
||||||
calls_sip_call_activate_media (call, FALSE);
|
calls_sip_call_activate_media (call, FALSE);
|
||||||
state = CALLS_CALL_STATE_DISCONNECTED;
|
state = CALLS_CALL_STATE_DISCONNECTED;
|
||||||
break;
|
|
||||||
|
g_hash_table_remove (origin->call_handles, nh);
|
||||||
|
|
||||||
|
calls_sip_call_set_state (call, state);
|
||||||
|
g_object_unref (G_OBJECT (call));
|
||||||
|
|
||||||
|
return;
|
||||||
|
|
||||||
case nua_callstate_authenticating:
|
case nua_callstate_authenticating:
|
||||||
g_warning ("TODO Move authentication (INVITE) here");
|
g_warning ("TODO Move authentication (INVITE) here");
|
||||||
|
@ -579,12 +586,7 @@ remove_call (CallsSipOrigin *self,
|
||||||
if (self->oper->call_handle == nh)
|
if (self->oper->call_handle == nh)
|
||||||
self->oper->call_handle = NULL;
|
self->oper->call_handle = NULL;
|
||||||
|
|
||||||
g_hash_table_remove (self->call_handles, nh);
|
|
||||||
nua_handle_unref (nh);
|
|
||||||
|
|
||||||
g_signal_emit_by_name (origin, "call-removed", call, reason);
|
g_signal_emit_by_name (origin, "call-removed", call, reason);
|
||||||
|
|
||||||
g_object_unref (G_OBJECT (call));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue