From c5e4c80a47d332a28adc733fb3a6b60a0414b021 Mon Sep 17 00:00:00 2001 From: Evangelos Ribeiro Tzaras Date: Thu, 8 Jul 2021 17:34:40 +0200 Subject: [PATCH] Introduce CallsSecretStore to store credentials --- src/calls-secret-store.c | 45 ++++++++++++++++++++++++++++++++++++++++ src/calls-secret-store.h | 36 ++++++++++++++++++++++++++++++++ src/meson.build | 2 ++ 3 files changed, 83 insertions(+) create mode 100644 src/calls-secret-store.c create mode 100644 src/calls-secret-store.h diff --git a/src/calls-secret-store.c b/src/calls-secret-store.c new file mode 100644 index 0000000..802e550 --- /dev/null +++ b/src/calls-secret-store.c @@ -0,0 +1,45 @@ +/* + * Copyright (C) 2021 Purism SPC + * + * This file is part of Calls. + * + * Calls is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calls is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calls. If not, see . + * + * Author: Evangelos Ribeiro Tzaras + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#define G_LOG_DOMAIN "CallsSecretStore" + +#include "calls-secret-store.h" + +#include + +const SecretSchema * +calls_secret_get_schema (void) +{ + static const SecretSchema schema = { + "sm.puri.Calls", SECRET_SCHEMA_NONE, + { + { CALLS_USERNAME_ATTRIBUTE, SECRET_SCHEMA_ATTRIBUTE_STRING }, + { CALLS_SERVER_ATTRIBUTE, SECRET_SCHEMA_ATTRIBUTE_STRING }, + { CALLS_PROTOCOL_ATTRIBUTE, SECRET_SCHEMA_ATTRIBUTE_STRING }, + { NULL, 0 }, + } + }; + + return &schema; +} diff --git a/src/calls-secret-store.h b/src/calls-secret-store.h new file mode 100644 index 0000000..e709c0e --- /dev/null +++ b/src/calls-secret-store.h @@ -0,0 +1,36 @@ +/* + * Copyright (C) 2021 Purism SPC + * + * This file is part of Calls. + * + * Calls is free software: you can redistribute it and/or modify it + * under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * Calls is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with Calls. If not, see . + * + * Author: Evangelos Ribeiro Tzaras + * + * SPDX-License-Identifier: GPL-3.0-or-later + * + */ + +#pragma once + +#include + +#define CALLS_USERNAME_ATTRIBUTE "username" +#define CALLS_SERVER_ATTRIBUTE "server" +#define CALLS_PROTOCOL_ATTRIBUTE "protocol" + +const SecretSchema *calls_secret_get_schema (void) G_GNUC_CONST; + +#define CALLS_SECRET_SCHEMA calls_secret_get_schema () + diff --git a/src/meson.build b/src/meson.build index 290b6e2..d3ea088 100644 --- a/src/meson.build +++ b/src/meson.build @@ -38,6 +38,7 @@ calls_deps = [ dependency('gobject-2.0', version: '>= 2.58'), dependency('libebook-contacts-1.2'), dependency('folks'), dependency('libcallaudio-0.1'), + dependency('libsecret-1'), ] calls_vala_deps = [ @@ -111,6 +112,7 @@ calls_sources = files(['calls-message-source.c', 'calls-message-source.h', 'calls-account-overview.c', 'calls-account-overview.h', 'calls-account-row.c', 'calls-account-row.h', 'calls-settings.c', 'calls-settings.h', + 'calls-secret-store.c', 'calls-secret-store.h', ]) + calls_generated_sources calls_config_data = config_data