From: Denis Kenzior <denkenz@gmail.com>
To: ofono@lists.linux.dev
Cc: Denis Kenzior <denkenz@gmail.com>
Subject: [PATCH v2 11/14] ofono: Add support for ofono main.conf settings
Date: Wed, 3 Apr 2024 11:05:34 -0500 [thread overview]
Message-ID: <20240403160557.2828145-11-denkenz@gmail.com> (raw)
In-Reply-To: <20240403160557.2828145-1-denkenz@gmail.com>
It would be useful to support some oFono wide configuration settings
that can be configured for the system. Introduce a new
__ofono_get_config() function that will obtain the parsed settings file
as a pointer to l_settings. The settings will be parsed from the
configuration directory set using CONFIGURATION_DIRECTORY environment
variable, or the default CONFIGDIR variable set during
configuration/compilation.
---
src/main.c | 32 ++++++++++++++++++++++++++++++++
src/ofono.h | 1 +
2 files changed, 33 insertions(+)
diff --git a/src/main.c b/src/main.c
index 141853eef8ae..6dd073b4f31a 100644
--- a/src/main.c
+++ b/src/main.c
@@ -39,6 +39,12 @@
#define SHUTDOWN_GRACE_SECONDS 10
static GMainLoop *event_loop;
+static struct l_settings *ofono_config;
+
+const struct l_settings *__ofono_get_config(void)
+{
+ return ofono_config;
+}
void __ofono_exit(void)
{
@@ -204,6 +210,9 @@ int main(int argc, char **argv)
DBusError error;
guint signal;
struct ell_event_source *source;
+ const char *config_dir;
+ char **config_dirs;
+ unsigned int i;
context = g_option_context_new(NULL);
g_option_context_add_main_entries(context, options, NULL);
@@ -254,6 +263,27 @@ int main(int argc, char **argv)
__ofono_log_init(argv[0], option_debug, option_detach);
+ config_dir = getenv("CONFIGURATION_DIRECTORY");
+ if (!config_dir)
+ config_dir = CONFIGDIR;
+
+ l_debug("Using configuration directory: %s", config_dir);
+ config_dirs = l_strsplit(config_dir, ':');
+ ofono_config = l_settings_new();
+
+ for (i = 0; config_dirs[i]; i++) {
+ _auto_(l_free) char *path = l_strdup_printf("%s/main.conf",
+ config_dirs[i]);
+
+ if (!l_settings_load_from_file(ofono_config, path))
+ continue;
+
+ l_info("Loaded configuration from %s", path);
+ break;
+ }
+
+ l_strv_free(config_dirs);
+
dbus_error_init(&error);
conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, OFONO_SERVICE, &error);
@@ -291,6 +321,8 @@ fail_module_init:
__ofono_dbus_cleanup();
dbus_connection_unref(conn);
+ l_settings_free(ofono_config);
+
cleanup:
g_source_remove(signal);
diff --git a/src/ofono.h b/src/ofono.h
index 294e90a37c23..80add8351ee7 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -26,6 +26,7 @@
#include <ofono/types.h>
+const struct l_settings *__ofono_get_config(void);
void __ofono_exit(void);
int __ofono_handsfree_audio_manager_init(void);
--
2.43.0
next prev parent reply other threads:[~2024-04-03 16:06 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-04-03 16:05 [PATCH v2 01/14] simutil: Convert eons APIs to use ell Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 02/14] sim: Simplify SPN management logic Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 03/14] data: Remove AweSIM entry Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 04/14] data: Mark some MVNOs via the "spn" attribute Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 05/14] data: Remove outdated T-mobile settings Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 06/14] data: Remove RESELLER settings from AT&T Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 07/14] provisiontool: Add support for context tags Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 08/14] provisiondb: Add tags_filter support Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 09/14] tools: lookup-apn: add support for optional tags filter Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 10/14] data: Add tags for AT&T and T-Mobile contexts Denis Kenzior
2024-04-03 16:05 ` Denis Kenzior [this message]
2024-04-03 16:05 ` [PATCH v2 12/14] provision: Add support for provision filter tags Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 13/14] examples: Fix use after free and resource leaks Denis Kenzior
2024-04-03 16:05 ` [PATCH v2 14/14] unit: Add test cases with tags_filter provided Denis Kenzior
2024-04-03 17:00 ` [PATCH v2 01/14] simutil: Convert eons APIs to use ell patchwork-bot+ofono
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20240403160557.2828145-11-denkenz@gmail.com \
--to=denkenz@gmail.com \
--cc=ofono@lists.linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.