[calls/gnome-41] sip: Do not fail if CallsNetworkWatch is unavailable



commit 497d8aacd5a5f5a199efbe033fcc87a0182c28d3
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Thu Sep 16 16:51:42 2021 +0200

    sip: Do not fail if CallsNetworkWatch is unavailable
    
    In this case network changes will not be detected.
    Additionally fall back to binding on all network interfaces (in this case a user
    will have problems when using multiple network interfaces, but there is really
    not much we can do without a functioning CallsNetworkWatch).
    
    (cherry picked from commit 1718823b803bc8170e1692b3a0d9420d89b0c33e)

 plugins/sip/calls-sip-origin.c | 17 ++++++++++++-----
 1 file changed, 12 insertions(+), 5 deletions(-)
---
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index 32fd80a6..a193d196 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -803,8 +803,10 @@ setup_nua (CallsSipOrigin *self)
 
   if (!sip_test_env || sip_test_env[0] == '\0') {
     CallsNetworkWatch *nw = calls_network_watch_get_default ();
-    ipv4_bind = calls_network_watch_get_ipv4 (nw);
-    ipv6_bind = calls_network_watch_get_ipv6 (nw);
+    if (nw) {
+      ipv4_bind = calls_network_watch_get_ipv4 (nw);
+      ipv6_bind = calls_network_watch_get_ipv6 (nw);
+    }
   }
 
   uuid = nua_generate_instance_identifier (self->ctx->home);
@@ -1461,9 +1463,14 @@ calls_sip_origin_init (CallsSipOrigin *self)
 {
   const char *sip_test_env = g_getenv ("CALLS_SIP_TEST");
 
-  if (!sip_test_env || sip_test_env[0] == '\0')
-    g_signal_connect_swapped (calls_network_watch_get_default (), "network-changed",
-                              G_CALLBACK (on_network_changed), self);
+  if (!sip_test_env || sip_test_env[0] == '\0') {
+    CallsNetworkWatch *nw = calls_network_watch_get_default ();
+    if (nw)
+      g_signal_connect_swapped (calls_network_watch_get_default (), "network-changed",
+                                G_CALLBACK (on_network_changed), self);
+    else
+      g_warning ("Network watch unavailable. Unable to detect network changes.");
+  }
 
   self->call_handles = g_hash_table_new (NULL, NULL);
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]