From a803294c4a8fe7fb4fb3581cb3c559fc3138721a Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Fri, 18 Jun 2021 19:09:00 +0200 Subject: [PATCH] sip: origin: Handle unregistering (going offline) and set the account state accordingly. --- plugins/sip/calls-sip-origin.c | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c index 9ee8fcc..67c95b6 100644 --- a/plugins/sip/calls-sip-origin.c +++ b/plugins/sip/calls-sip-origin.c @@ -475,6 +475,31 @@ sip_r_register (int status, } +static void +sip_r_unregister (int status, + char const *phrase, + nua_t *nua, + CallsSipOrigin *origin, + nua_handle_t *nh, + CallsSipHandles *op, + sip_t const *sip, + tagi_t tags[]) +{ + g_debug ("response to unregistering: %03d %s", status, phrase); + + if (status == 200) { + g_debug ("Unregistering successful"); + origin->state = CALLS_ACCOUNT_OFFLINE; + + } else { + g_warning ("Unregisterung unsuccessful: %03d %s", status, phrase); + origin->state = CALLS_ACCOUNT_UNKNOWN_ERROR; + } + + g_object_notify_by_pspec (G_OBJECT (origin), props[PROP_ACC_STATE]); +} + + static void sip_i_state (int status, char const *phrase, @@ -658,6 +683,17 @@ sip_callback (nua_event_t event, tags); break; + case nua_r_unregister: + sip_r_unregister (status, + phrase, + nua, + origin, + nh, + op, + sip, + tags); + break; + case nua_r_set_params: g_debug ("response to set_params: %03d %s", status, phrase); break;