1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-11-16 15:06:05 +00:00

notifier: Explicitly handle unknown callers

Closes #288
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-06-18 11:47:21 +02:00
parent c520bdae70
commit cce8318a64

View file

@ -49,24 +49,31 @@ notify (CallsNotifier *self, CallsCall *call)
g_autofree gchar *ref = NULL;
g_autofree gchar *label_callback = NULL;
const char *name;
const char *number;
gboolean got_number;
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);
number = calls_call_get_number (call);
got_number = !!number && (g_strcmp0 (number, "") != 0);
if (calls_best_match_has_individual (contact))
msg = g_strdup_printf (_("Missed call from <b>%s</b>"), name);
else if (got_number)
msg = g_strdup_printf (_("Missed call from %s"), number);
else
msg = g_strdup_printf (_("Missed call from %s"), calls_call_get_number (call));
msg = g_strdup (_("Missed call from unknown caller"));
g_notification_set_body (notification, msg);
if (calls_call_get_number (call)) {
label_callback = g_strdup_printf ("app.dial::%s", calls_call_get_number (call));
if (got_number) {
label_callback = g_strdup_printf ("app.dial::%s", number);
g_notification_add_button (notification, _("Call back"), label_callback);
}
ref = g_strdup_printf ("missed-call-%s", calls_call_get_number (call) ?: "unknown");
ref = g_strdup_printf ("missed-call-%s", number ?: "unknown");
g_application_send_notification (app, ref, notification);
}