From 889d5a09817eb6f37a429edd25bffa1456d8e5ec Mon Sep 17 00:00:00 2001 From: Julian Sparber Date: Thu, 28 Jan 2021 17:09:43 +0100 Subject: [PATCH] CallManager: drop calls_manager_get_contact_name () This function is replaced with calls_call_get_contact () --- src/calls-manager.c | 34 ---------------------------------- src/calls-notifier.c | 8 ++++++-- 2 files changed, 6 insertions(+), 36 deletions(-) diff --git a/src/calls-manager.c b/src/calls-manager.c index 33bd842..364908b 100644 --- a/src/calls-manager.c +++ b/src/calls-manager.c @@ -656,37 +656,3 @@ calls_manager_set_default_origin (CallsManager *self, g_object_notify_by_pspec (G_OBJECT (self), props[PROP_DEFAULT_ORIGIN]); } - -/** - * calls_manager_get_contact_name: - * @call: a #CallsCall - * - * Looks up the contact name for @call. If the lookup - * succeeds, the contact name will be returned. NULL if - * no match has been found in the contact list. - * If no number is associated with the @call, then - * a translatable string will be returned. - * - * Returns: (transfer none): The caller's name, a string representing - * an unknown caller or %NULL - */ -const gchar * -calls_manager_get_contact_name (CallsCall *call) -{ - const gchar *number; - g_autoptr (CallsBestMatch) match = NULL; - CallsContactsProvider *contacts_provider; - - number = calls_call_get_number (call); - if (!number || g_strcmp0 (number, "") == 0) - return _("Anonymous caller"); - - contacts_provider = calls_manager_get_contacts_provider (calls_manager_get_default ()); - match = calls_contacts_provider_lookup_phone_number (contacts_provider, - number); - - if (!match) - return NULL; - - return calls_best_match_get_name (match); -} diff --git a/src/calls-notifier.c b/src/calls-notifier.c index 076e2c6..b4f7f63 100644 --- a/src/calls-notifier.c +++ b/src/calls-notifier.c @@ -44,6 +44,7 @@ notify (CallsNotifier *self, CallsCall *call) { GApplication *app = g_application_get_default (); g_autoptr(GNotification) notification; + g_autoptr (CallsBestMatch) contact = NULL; g_autofree gchar *msg = NULL; g_autofree gchar *ref = NULL; g_autofree gchar *label_callback = NULL; @@ -51,8 +52,11 @@ notify (CallsNotifier *self, CallsCall *call) notification = g_notification_new (_("Missed call")); - name = calls_manager_get_contact_name (call); - if (name) + contact = calls_call_get_contact (call); + // TODO: We need to update the notification when the contact name changes + name = calls_best_match_get_name (contact); + + if (calls_best_match_has_individual (contact)) msg = g_strdup_printf (_("Missed call from %s"), name); else msg = g_strdup_printf (_("Missed call from %s"), calls_call_get_number (call));