[calls] contacts-provider: Add API to add new contacts
- From: Evangelos Ribeiro Tzaras <devrtz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [calls] contacts-provider: Add API to add new contacts
- Date: Tue, 18 Jan 2022 02:44:06 +0000 (UTC)
commit 5588bd934a57a202ac55d860dfbecb6637babc04
Author: Evangelos Ribeiro Tzaras <devrtz fortysixandtwo eu>
Date: Thu Jan 6 19:52:06 2022 +0100
contacts-provider: Add API to add new contacts
src/calls-contacts-provider.c | 31 +++++++++++++++++++++++++++++++
src/calls-contacts-provider.h | 2 ++
2 files changed, 33 insertions(+)
---
diff --git a/src/calls-contacts-provider.c b/src/calls-contacts-provider.c
index c41c517f..9597bfa7 100644
--- a/src/calls-contacts-provider.c
+++ b/src/calls-contacts-provider.c
@@ -448,4 +448,35 @@ calls_contacts_provider_get_can_add_contacts (CallsContactsProvider *self)
return self->can_add_contacts;
}
+
+void
+calls_contacts_provider_add_new_contact (CallsContactsProvider *self,
+ const char *phone_number)
+{
+ GVariant *contact_parameter;
+ GVariantBuilder contact_builder;
+ CallsBestMatch *best_match;
+
+ g_return_if_fail (CALLS_IS_CONTACTS_PROVIDER (self));
+ g_return_if_fail (phone_number || *phone_number);
+ g_return_if_fail (self->can_add_contacts);
+
+ best_match = g_hash_table_lookup (self->best_matches, phone_number);
+ if (best_match && calls_best_match_has_individual (best_match)) {
+ g_warning ("Cannot add contact. Contact '%s' with number '%s' already exists",
+ calls_best_match_get_name (best_match), phone_number);
+ return;
+ }
+
+ g_variant_builder_init (&contact_builder, G_VARIANT_TYPE_ARRAY);
+ g_variant_builder_add (&contact_builder, "(ss)",
+ "phone-numbers",
+ phone_number);
+ contact_parameter = g_variant_builder_end (&contact_builder);
+
+ g_action_group_activate_action (G_ACTION_GROUP (self->contacts_action_group),
+ "new-contact-data",
+ contact_parameter);
+}
+
#undef DBUS_BUS_NAME
diff --git a/src/calls-contacts-provider.h b/src/calls-contacts-provider.h
index 3acd929d..be6cfd8a 100644
--- a/src/calls-contacts-provider.h
+++ b/src/calls-contacts-provider.h
@@ -57,5 +57,7 @@ void calls_contacts_provider_consume_iter_on_idle (GeeIterato
IdleCallback callback,
gpointer user_data);
gboolean calls_contacts_provider_get_can_add_contacts (CallsContactsProvider *self);
+void calls_contacts_provider_add_new_contact (CallsContactsProvider *self,
+ const char *phone_number);
G_END_DECLS
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]