1
0
Fork 0
mirror of https://gitlab.gnome.org/GNOME/calls.git synced 2024-12-25 05:47:35 +00:00

application: Do not prepend country code when dialing

Fixes #176

(cherry picked from commit 1a14075945)
This commit is contained in:
Evangelos Ribeiro Tzaras 2021-09-07 14:03:27 +02:00
parent f9cafbb6e1
commit 849e971199

View file

@ -46,7 +46,6 @@
#include <glib/gi18n.h> #include <glib/gi18n.h>
#include <handy.h> #include <handy.h>
#include <libcallaudio.h> #include <libcallaudio.h>
#include <libebook-contacts/libebook-contacts.h>
/** /**
* SECTION: calls-application * SECTION: calls-application
@ -254,6 +253,36 @@ extract_dial_string (const char *number)
} }
static void
call_number (CallsApplication *self,
const char *number)
{
g_autofree char *dial_string = NULL;
gboolean number_ok;
number_ok = check_dial_number (number);
if (!number_ok) {
g_warning ("Dial number `%s' is not a valid dial string",
number);
return;
}
dial_string = extract_dial_string (number);
if (!dial_string) {
return;
}
g_debug ("Dialing dial string `%s' extracted from number `%s'",
dial_string, number);
start_proper (self);
calls_main_window_dial (self->main_window,
dial_string);
}
static void static void
dial_action (GSimpleAction *action, dial_action (GSimpleAction *action,
GVariant *parameter, GVariant *parameter,
@ -261,31 +290,11 @@ dial_action (GSimpleAction *action,
{ {
CallsApplication *self = CALLS_APPLICATION (user_data); CallsApplication *self = CALLS_APPLICATION (user_data);
const char *number; const char *number;
gboolean number_ok;
g_autofree char *dial_string = NULL;
number = g_variant_get_string (parameter, NULL); number = g_variant_get_string (parameter, NULL);
g_return_if_fail (number != NULL); g_return_if_fail (number != NULL);
number_ok = check_dial_number (number); call_number (self, number);
if (!number_ok) {
g_warning ("Dial number `%s' is not a valid dial string",
number);
return;
}
dial_string = extract_dial_string (number);
if (!dial_string) {
return;
}
g_debug ("Dialing dial string `%s' extracted from number `%s'",
dial_string, number);
start_proper (self);
calls_main_window_dial (self->main_window,
dial_string);
} }
static void static void
@ -520,35 +529,23 @@ static void
open_tel_uri (CallsApplication *self, open_tel_uri (CallsApplication *self,
const char *uri) const char *uri)
{ {
g_autoptr (EPhoneNumber) number = NULL; const char *number = NULL;
g_autoptr (GError) error = NULL;
g_autofree char *dial_str = NULL;
g_autofree char *country_code = NULL;
g_object_get (calls_manager_get_default (),
"country-code", &country_code,
NULL);
g_debug ("Opening tel URI `%s'", uri); g_debug ("Opening tel URI `%s'", uri);
number = e_phone_number_from_string (uri, country_code, &error); number = &uri[4]; // tel:NUMBER
if (!number) { if (!number || number[0] == '\0') {
g_autofree char *msg = g_autofree char *msg =
g_strdup_printf (_("Tried dialing unparsable tel URI `%s'"), uri); g_strdup_printf (_("Tried invalid tel URI `%s'"), uri);
g_signal_emit_by_name (calls_manager_get_default (), g_signal_emit_by_name (calls_manager_get_default (),
"error", "error",
msg); msg);
g_warning ("Ignoring unparsable tel URI `%s': %s", g_warning ("Ignoring invalid tel URI `%s'", uri);
uri, error->message);
return; return;
} }
dial_str = e_phone_number_to_string call_number (self, number);
(number, E_PHONE_NUMBER_FORMAT_E164);
calls_main_window_dial (self->main_window,
dial_str);
} }
static void static void