[calls/gnome-41] sip: origin: Make sure "@host" is in the dial string



commit 3f517683679c60ab8a87a635da82b29523c2245c
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date:   Fri Oct 29 01:11:37 2021 +0200

    sip: origin: Make sure "@host" is in the dial string
    
    This helps avoid some typing work in the case of dialing telephone numbers.
    
    Fixes #350
    
    (cherry picked from commit 2cf7c5e9817cacf33e5e0c2dac1b47cbd67581fd)

 plugins/sip/calls-sip-origin.c | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/plugins/sip/calls-sip-origin.c b/plugins/sip/calls-sip-origin.c
index ddf08582..b8b515ab 100644
--- a/plugins/sip/calls-sip-origin.c
+++ b/plugins/sip/calls-sip-origin.c
@@ -269,6 +269,7 @@ dial (CallsOrigin *origin,
   CallsSipOrigin *self;
   nua_handle_t *nh;
   g_autofree char *name = NULL;
+  g_autofree char *dial_target = NULL;
 
   g_assert (CALLS_ORIGIN (origin));
   g_assert (CALLS_IS_SIP_ORIGIN (origin));
@@ -288,17 +289,23 @@ dial (CallsOrigin *origin,
                    SOATAG_ACTIVE_AUDIO (SOA_ACTIVE_SENDRECV),
                    TAG_END ());
 
+  /* Make sure @host is in the dial target */
+  if (g_strstr_len (address, -1, "@"))
+    dial_target = g_strdup (address);
+  else
+    dial_target = g_strconcat (address, "@", self->host, NULL);
+
   g_debug ("Calling `%s' from origin '%s'", address, name);
 
   /* We don't require the user to input the prefix */
   if (!g_str_has_prefix (address, "sip:") &&
       !g_str_has_prefix (address, "sips:")) {
-    g_autofree char * address_prefix =
-      g_strconcat (self->protocol_prefix, ":", address, NULL);
+    g_autofree char * target_with_prefix =
+      g_strconcat (self->protocol_prefix, ":", dial_target, NULL);
 
-    add_call (CALLS_SIP_ORIGIN (origin), address_prefix, FALSE, nh);
+    add_call (CALLS_SIP_ORIGIN (origin), target_with_prefix, FALSE, nh);
   } else {
-    add_call (CALLS_SIP_ORIGIN (origin), address, FALSE, nh);
+    add_call (CALLS_SIP_ORIGIN (origin), dial_target, FALSE, nh);
   }
 }
 


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