All of lore.kernel.org
 help / color / mirror / Atom feed
* [RFC 0/6] Add configuration support via main.conf
@ 2011-01-26  8:56 Aki Niemi
  2011-01-26  8:56 ` [RFC 1/6] main: Add basic support for main.conf Aki Niemi
                   ` (5 more replies)
  0 siblings, 6 replies; 8+ messages in thread
From: Aki Niemi @ 2011-01-26  8:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 255 bytes --]

Hi all,

This set of patches adds support for oFono configuration settings via
main.conf. First three add the file and routines for parsing that
file; the following three take a parameter in the sms atom and makes
it configurable.

Cheers,
Aki


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [RFC 1/6] main: Add basic support for main.conf
  2011-01-26  8:56 [RFC 0/6] Add configuration support via main.conf Aki Niemi
@ 2011-01-26  8:56 ` Aki Niemi
  2011-01-26  9:06   ` Marcel Holtmann
  2011-01-26  8:56 ` [RFC 2/6] conf: Add bare bones configuration file Aki Niemi
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 8+ messages in thread
From: Aki Niemi @ 2011-01-26  8:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 2971 bytes --]

---
 src/main.c  |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
 src/ofono.h |   11 ++++++++++
 2 files changed, 72 insertions(+), 1 deletions(-)

diff --git a/src/main.c b/src/main.c
index 3db8819..129d36c 100644
--- a/src/main.c
+++ b/src/main.c
@@ -41,6 +41,7 @@
 #define SHUTDOWN_GRACE_SECONDS 10
 
 static GMainLoop *event_loop;
+struct main_opts main_opts;
 
 void __ofono_exit(void)
 {
@@ -92,6 +93,51 @@ static void system_bus_disconnected(DBusConnection *conn, void *user_data)
 	g_main_loop_quit(event_loop);
 }
 
+static GKeyFile *load_config(const char *file)
+{
+	GError *err = NULL;
+	GKeyFile *keyfile;
+
+	keyfile = g_key_file_new();
+
+	g_key_file_set_list_separator(keyfile, ',');
+
+	if (!g_key_file_load_from_file(keyfile, file, 0, &err)) {
+		ofono_error("Parsing %s failed: %s", file, err->message);
+		g_error_free(err);
+		g_key_file_free(keyfile);
+		return NULL;
+	}
+
+	return keyfile;
+}
+
+static void parse_config(GKeyFile *config)
+{
+	GError *err = NULL;
+	char *str;
+
+	if (!config)
+		return;
+
+	str = g_key_file_get_string(config, "General", "DisablePlugins", &err);
+	if (err) {
+		DBG("%s", err->message);
+		g_clear_error(&err);
+	} else {
+		DBG("DisablePlugins=%s", str);
+		main_opts.noplugin = g_strdup(str);
+		main_opts.flags |= OFONO_SET_NOPLUGIN;
+		g_free(str);
+	}
+}
+
+static void init_defaults(void)
+{
+	/* Default oFono daemon settings */
+	memset(&main_opts, 0, sizeof(main_opts));
+}
+
 static gchar *option_debug = NULL;
 static gchar *option_plugin = NULL;
 static gchar *option_noplugin = NULL;
@@ -135,6 +181,9 @@ int main(int argc, char **argv)
 	int signal_fd;
 	GIOChannel *signal_io;
 	int signal_source;
+	GKeyFile *config = NULL;
+
+	init_defaults();
 
 #ifdef HAVE_CAPNG
 	/* Drop capabilities */
@@ -235,10 +284,18 @@ int main(int argc, char **argv)
 
 	__ofono_manager_init();
 
-	__ofono_plugin_init(option_plugin, option_noplugin);
+	config = load_config(CONFIGDIR "/main.conf");
+
+	parse_config(config);
+
+	if (main_opts.flags & OFONO_SET_NOPLUGIN)
+		__ofono_plugin_init(option_plugin, main_opts.noplugin);
+	else
+		__ofono_plugin_init(option_plugin, option_noplugin);
 
 	g_free(option_plugin);
 	g_free(option_noplugin);
+	g_free(main_opts.noplugin);
 
 	g_main_loop_run(event_loop);
 
@@ -255,6 +312,9 @@ cleanup:
 	g_source_remove(signal_source);
 	g_main_loop_unref(event_loop);
 
+	if (config)
+		g_key_file_free(config);
+
 	__ofono_log_cleanup();
 
 	return 0;
diff --git a/src/ofono.h b/src/ofono.h
index e48dbf6..54de5a6 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -25,6 +25,17 @@
 
 #include <ofono/types.h>
 
+struct main_opts {
+	char *noplugin;
+	unsigned long flags;
+};
+
+enum {
+	OFONO_SET_NOPLUGIN =	1,
+};
+
+extern struct main_opts main_opts;
+
 void __ofono_exit(void);
 
 int __ofono_manager_init(void);
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 2/6] conf: Add bare bones configuration file
  2011-01-26  8:56 [RFC 0/6] Add configuration support via main.conf Aki Niemi
  2011-01-26  8:56 ` [RFC 1/6] main: Add basic support for main.conf Aki Niemi
@ 2011-01-26  8:56 ` Aki Niemi
  2011-01-26  8:56 ` [RFC 3/6] build: Add main.conf to the build Aki Niemi
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Aki Niemi @ 2011-01-26  8:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 376 bytes --]

---
 src/main.conf |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)
 create mode 100644 src/main.conf

diff --git a/src/main.conf b/src/main.conf
new file mode 100644
index 0000000..facb950
--- /dev/null
+++ b/src/main.conf
@@ -0,0 +1,4 @@
+[General]
+
+# List of plugins that should not be loaded on oFono startup
+#DisablePlugins =
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 3/6] build: Add main.conf to the build
  2011-01-26  8:56 [RFC 0/6] Add configuration support via main.conf Aki Niemi
  2011-01-26  8:56 ` [RFC 1/6] main: Add basic support for main.conf Aki Niemi
  2011-01-26  8:56 ` [RFC 2/6] conf: Add bare bones configuration file Aki Niemi
@ 2011-01-26  8:56 ` Aki Niemi
  2011-01-26  8:56 ` [RFC 4/6] conf: Add ref number setting for MessageManager Aki Niemi
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 8+ messages in thread
From: Aki Niemi @ 2011-01-26  8:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 668 bytes --]

---
 Makefile.am |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index f941a19..02ea2cb 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -35,7 +35,7 @@ endif
 
 confdir = $(sysconfdir)/ofono
 
-conf_DATA =
+conf_DATA = src/main.conf
 
 statedir = $(localstatedir)/lib/ofono
 
@@ -477,7 +477,7 @@ testdir = $(pkglibdir)/test
 test_SCRIPTS = $(test_scripts)
 endif
 
-conf_files = src/ofono.conf plugins/phonesim.conf
+conf_files = src/ofono.conf plugins/phonesim.conf src/main.conf
 
 EXTRA_DIST = src/genbuiltin $(conf_files) $(udev_files) \
 					$(doc_files) $(test_scripts)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 4/6] conf: Add ref number setting for MessageManager
  2011-01-26  8:56 [RFC 0/6] Add configuration support via main.conf Aki Niemi
                   ` (2 preceding siblings ...)
  2011-01-26  8:56 ` [RFC 3/6] build: Add main.conf to the build Aki Niemi
@ 2011-01-26  8:56 ` Aki Niemi
  2011-01-26  8:56 ` [RFC 5/6] main: Enable parsing SMS ref number setting Aki Niemi
  2011-01-26  8:56 ` [RFC 6/6] sms: Use main configuration for 16bit ref number Aki Niemi
  5 siblings, 0 replies; 8+ messages in thread
From: Aki Niemi @ 2011-01-26  8:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 509 bytes --]

---
 src/main.conf |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/src/main.conf b/src/main.conf
index facb950..0b23998 100644
--- a/src/main.conf
+++ b/src/main.conf
@@ -2,3 +2,9 @@
 
 # List of plugins that should not be loaded on oFono startup
 #DisablePlugins =
+
+[MessageManager]
+
+# Use 16bit long reference numbers in outgoing SMSs. The default is
+# False, which causes 8bit long reference numbers to be used.
+Use16bitReference = false
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 5/6] main: Enable parsing SMS ref number setting
  2011-01-26  8:56 [RFC 0/6] Add configuration support via main.conf Aki Niemi
                   ` (3 preceding siblings ...)
  2011-01-26  8:56 ` [RFC 4/6] conf: Add ref number setting for MessageManager Aki Niemi
@ 2011-01-26  8:56 ` Aki Niemi
  2011-01-26  8:56 ` [RFC 6/6] sms: Use main configuration for 16bit ref number Aki Niemi
  5 siblings, 0 replies; 8+ messages in thread
From: Aki Niemi @ 2011-01-26  8:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1061 bytes --]

---
 src/main.c  |   11 +++++++++++
 src/ofono.h |    1 +
 2 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/src/main.c b/src/main.c
index 129d36c..e55b6e7 100644
--- a/src/main.c
+++ b/src/main.c
@@ -116,6 +116,7 @@ static void parse_config(GKeyFile *config)
 {
 	GError *err = NULL;
 	char *str;
+	gboolean val;
 
 	if (!config)
 		return;
@@ -130,6 +131,16 @@ static void parse_config(GKeyFile *config)
 		main_opts.flags |= OFONO_SET_NOPLUGIN;
 		g_free(str);
 	}
+
+	val = g_key_file_get_boolean(config, "MessageManager",
+					"Use16bitReference", &err);
+	if (err) {
+		DBG("%s", err->message);
+		g_clear_error(&err);
+	} else {
+		DBG("Use16bitReference=%s", val ? "true" : "false");
+		main_opts.use_16bit_ref = val;
+	}
 }
 
 static void init_defaults(void)
diff --git a/src/ofono.h b/src/ofono.h
index 54de5a6..0c0f2a8 100644
--- a/src/ofono.h
+++ b/src/ofono.h
@@ -27,6 +27,7 @@
 
 struct main_opts {
 	char *noplugin;
+	gboolean use_16bit_ref;
 	unsigned long flags;
 };
 
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* [RFC 6/6] sms: Use main configuration for 16bit ref number
  2011-01-26  8:56 [RFC 0/6] Add configuration support via main.conf Aki Niemi
                   ` (4 preceding siblings ...)
  2011-01-26  8:56 ` [RFC 5/6] main: Enable parsing SMS ref number setting Aki Niemi
@ 2011-01-26  8:56 ` Aki Niemi
  5 siblings, 0 replies; 8+ messages in thread
From: Aki Niemi @ 2011-01-26  8:56 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 845 bytes --]

---
 src/sms.c |    3 +--
 1 files changed, 1 insertions(+), 2 deletions(-)

diff --git a/src/sms.c b/src/sms.c
index 7224bdf..48d2d81 100644
--- a/src/sms.c
+++ b/src/sms.c
@@ -842,7 +842,6 @@ static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg,
 	GSList *msg_list;
 	struct ofono_modem *modem;
 	unsigned int flags;
-	gboolean use_16bit_ref = FALSE;
 	int err;
 	struct ofono_uuid uuid;
 
@@ -854,7 +853,7 @@ static DBusMessage *sms_send_message(DBusConnection *conn, DBusMessage *msg,
 	if (valid_phone_number_format(to) == FALSE)
 		return __ofono_error_invalid_format(msg);
 
-	msg_list = sms_text_prepare(to, text, sms->ref, use_16bit_ref,
+	msg_list = sms_text_prepare(to, text, sms->ref, main_opts.use_16bit_ref,
 						sms->use_delivery_reports);
 
 	if (msg_list == NULL)
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 8+ messages in thread

* Re: [RFC 1/6] main: Add basic support for main.conf
  2011-01-26  8:56 ` [RFC 1/6] main: Add basic support for main.conf Aki Niemi
@ 2011-01-26  9:06   ` Marcel Holtmann
  0 siblings, 0 replies; 8+ messages in thread
From: Marcel Holtmann @ 2011-01-26  9:06 UTC (permalink / raw)
  To: ofono

[-- Attachment #1: Type: text/plain, Size: 1492 bytes --]

Hi Aki,

>  src/main.c  |   62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
>  src/ofono.h |   11 ++++++++++
>  2 files changed, 72 insertions(+), 1 deletions(-)
> 
> diff --git a/src/main.c b/src/main.c
> index 3db8819..129d36c 100644
> --- a/src/main.c
> +++ b/src/main.c
> @@ -41,6 +41,7 @@
>  #define SHUTDOWN_GRACE_SECONDS 10
>  
>  static GMainLoop *event_loop;
> +struct main_opts main_opts;

please please please don't copy legacy code from BlueZ. We should have
replaced this old main_opts thing for ages now, but we were just lazy to
do so. I think the main_opts is from 2002 or so.

We should go for something like we have in ConnMan:

const char *connman_option_get_string(const char *key)
{
}

And then we can also combine values from command line with values from a
config file if needed.

> +static void parse_config(GKeyFile *config)
> +{
> +	GError *err = NULL;
> +	char *str;
> +
> +	if (!config)
> +		return;
> +
> +	str = g_key_file_get_string(config, "General", "DisablePlugins", &err);

Do you really wants this. The only reason why this was actually in BlueZ
was because of qualification and shipping profile support that is not
officially part of the product.

And we had this before we got the command line options for -P and -p.
They are much more useful and powerful. So until we really need this,
please don't bother with something like DisablePlugins in a
configuration file.

Regards

Marcel



^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2011-01-26  9:06 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-26  8:56 [RFC 0/6] Add configuration support via main.conf Aki Niemi
2011-01-26  8:56 ` [RFC 1/6] main: Add basic support for main.conf Aki Niemi
2011-01-26  9:06   ` Marcel Holtmann
2011-01-26  8:56 ` [RFC 2/6] conf: Add bare bones configuration file Aki Niemi
2011-01-26  8:56 ` [RFC 3/6] build: Add main.conf to the build Aki Niemi
2011-01-26  8:56 ` [RFC 4/6] conf: Add ref number setting for MessageManager Aki Niemi
2011-01-26  8:56 ` [RFC 5/6] main: Enable parsing SMS ref number setting Aki Niemi
2011-01-26  8:56 ` [RFC 6/6] sms: Use main configuration for 16bit ref number Aki Niemi

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.