initial import
[libicd-wpa] / gconf.c
diff --git a/gconf.c b/gconf.c
new file mode 100644 (file)
index 0000000..f08e567
--- /dev/null
+++ b/gconf.c
@@ -0,0 +1,51 @@
+/**
+  @file gconf.c
+
+  Copyright (C) 2009 Javier S. Pedro
+
+  @author Javier S. Pedro <javispedro@javispedro.com>
+
+  This file is part of libicd-network-wpa.
+
+  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 2 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.,
+  59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
+
+*/
+
+#include <string.h>
+
+#include <glib.h>
+#include <gconf/gconf-client.h>
+
+#include "log.h"
+
+gchar * gconf_get_string(GConfClient *client, gchar * path)
+{
+       GError *error = NULL;
+       gchar *value = gconf_client_get_string(client, path, &error);
+       
+       if (error) {
+               DLOG_ERR("Could not get setting:%s, error:%s", path, 
+                        error->message);
+                        
+               g_clear_error(&error);
+               value = NULL;
+       } else if (!value) {
+               DLOG_ERR("Could not get setting:%s", path);
+       }
+       
+       g_free(path);
+       
+       return value;
+}