From 22f2c21238d04c6645a4d1b4485c37d49f75b946 Mon Sep 17 00:00:00 2001 Message-Id: <22f2c21238d04c6645a4d1b4485c37d49f75b946.1351979134.git.matthew.monaco@0x01b.net> In-Reply-To: <0055b44cafe7d7bb6c5fb0d50d22fa4fc7978745.1351979134.git.matthew.monaco@0x01b.net> References: <0055b44cafe7d7bb6c5fb0d50d22fa4fc7978745.1351979134.git.matthew.monaco@0x01b.net> From: Matthew Monaco Date: Sat, 3 Nov 2012 14:31:18 -0600 Subject: [PATCH 2/4] cfg: initial support for a configuration file --- data/Makefile.am | 4 ++++ data/accountsservice.conf | 3 +++ src/Makefile.am | 1 + src/config.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ src/daemon.c | 4 ++++ src/util.h | 6 ++++++ 6 files changed, 64 insertions(+) create mode 100644 data/accountsservice.conf create mode 100644 src/config.c diff --git a/data/Makefile.am b/data/Makefile.am index 521c6c2..a3f9f61 100644 --- a/data/Makefile.am +++ b/data/Makefile.am @@ -7,6 +7,9 @@ dbusif_DATA = \ dbusconfdir = $(sysconfdir)/dbus-1/system.d dbusconf_DATA = org.freedesktop.Accounts.conf +configdir = $(sysconfdir) +config_DATA = accountsservice.conf + servicedir = $(datadir)/dbus-1/system-services service_in_files = org.freedesktop.Accounts.service.in service_DATA = $(service_in_files:.service.in=.service) @@ -32,6 +35,7 @@ endif EXTRA_DIST = \ $(dbusif_DATA) \ $(dbusconf_DATA) \ + $(config_DATA) \ $(service_in_files) \ $(policy_in_files) \ accounts-daemon.service.in diff --git a/data/accountsservice.conf b/data/accountsservice.conf new file mode 100644 index 0000000..ac7c06e --- /dev/null +++ b/data/accountsservice.conf @@ -0,0 +1,3 @@ +# +# Configuration for AccountsService +# diff --git a/src/Makefile.am b/src/Makefile.am index c368c02..58f4af4 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -34,6 +34,7 @@ accounts_daemon_SOURCES = \ user.c \ util.h \ util.c \ + config.c \ main.c accounts_daemon_LDADD = \ diff --git a/src/config.c b/src/config.c new file mode 100644 index 0000000..08a6b0f --- /dev/null +++ b/src/config.c @@ -0,0 +1,46 @@ +/* -*- Mode: C; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 8 -*- + * + * Copyright (C) 2012 Matthew Monaco + * + * This program 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. + * + * This program 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 this program; if not, write to the Free Software + * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "util.h" + +Config *cfg_init() +{ + gboolean b; + GKeyFile *f; + + f = g_key_file_new(); + b = g_key_file_load_from_file(f, PATH_CONFIG_FILE, G_KEY_FILE_NONE, NULL); + + if (b) { + return (Config*) f; + } else { + g_key_file_free(f); + return NULL; + } +} + +void cfg_free(Config *cfg) +{ + GKeyFile *f = (GKeyFile*) cfg; + g_key_file_free(f); +} + + +/* vim: set ts=8 sw=8 sts=8 et : */ diff --git a/src/daemon.c b/src/daemon.c index 84474b6..4b32122 100644 --- a/src/daemon.c +++ b/src/daemon.c @@ -634,6 +634,9 @@ daemon_init (Daemon *daemon) gint i; GFile *file; GError *error; + Config *cfg; + + cfg = cfg_init(); daemon->priv = DAEMON_GET_PRIVATE (daemon); @@ -697,6 +700,7 @@ daemon_init (Daemon *daemon) g_error_free (error); } + cfg_free(cfg); queue_reload_users (daemon); queue_reload_autologin (daemon); } diff --git a/src/util.h b/src/util.h index 714a87a..ff88973 100644 --- a/src/util.h +++ b/src/util.h @@ -28,6 +28,12 @@ G_BEGIN_DECLS +#define PATH_CONFIG_FILE "/etc/accountsservice.conf" + +typedef GKeyFile Config; +Config* cfg_init(void); +void cfg_free(Config*); + void sys_log (GDBusMethodInvocation *context, const gchar *format, ...); -- 1.8.0