[calls] best-match: Preliminary handling of SIP addresses



commit c293b7029d09498ac65cadcc8a6ec42a8fd0514a
Author: Evangelos Ribeiro Tzaras <evangelos tzaras puri sm>
Date:   Thu Jul 1 02:01:32 2021 +0200

    best-match: Preliminary handling of SIP addresses
    
    This does not perform any contact lookup, but instead introduces a benign
    hack to be able to get something sensible when calling
    `calls_best_match_get_name()` and avoids unnecessary warnings.

 src/calls-best-match.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
---
diff --git a/src/calls-best-match.c b/src/calls-best-match.c
index ae513a16..63a69060 100644
--- a/src/calls-best-match.c
+++ b/src/calls-best-match.c
@@ -39,6 +39,7 @@ struct _CallsBestMatch
   FolksIndividual    *best_match;
   char               *phone_number;
   char               *country_code;
+  char               *name_sip;
   gboolean            had_country_code_last_time;
 };
 
@@ -205,6 +206,7 @@ dispose (GObject *object)
   g_clear_object (&self->view);
   g_clear_pointer (&self->phone_number, g_free);
   g_clear_pointer (&self->country_code, g_free);
+  g_clear_pointer (&self->name_sip, g_free);
 
   if (self->best_match) {
     g_signal_handlers_disconnect_by_data (self->best_match, self);
@@ -328,6 +330,14 @@ calls_best_match_set_phone_number (CallsBestMatch *self,
   g_clear_object (&self->view);
 
   if (self->phone_number) {
+    /* This is a SIP address, don' try parsing it as a phone number */
+    if (g_str_has_prefix (self->phone_number, "sip")) {
+      g_auto (GStrv) split = g_strsplit_set (self->phone_number, ":@", -1);
+
+      self->name_sip = g_strdup (split[1]);
+      g_object_notify_by_pspec (G_OBJECT (self), props[PROP_PHONE_NUMBER]);
+      return;
+    }
     number = e_phone_number_from_string (phone_number, self->country_code, &error);
 
     if (!number) {


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