]> saetta.ns0.it Git - zakauthe/plugins/db/commitdiff
Re-enabled libzakconfi. confi
authorAndrea Zagli <azagli@libero.it>
Wed, 27 Apr 2016 13:54:49 +0000 (15:54 +0200)
committerAndrea Zagli <azagli@libero.it>
Wed, 27 Apr 2016 13:54:49 +0000 (15:54 +0200)
.gitignore
configure.ac
src/Makefile.am
src/aute_db.c
tests/Makefile.am
tests/test_confi.c [new file with mode: 0644]
tests/test_confi.conf [new file with mode: 0644]

index 93e51acf52952d95b4377fc31ce4fc6522b1936c..dc11495a1f6ea056e0ee49077152a3b635d84871 100644 (file)
@@ -26,6 +26,7 @@ missing
 config.h
 stamp-h1
 tests/test
+tests/test_confi
 tests/test_nogui
 tools/zakauthedb-mkpwd
 *.tar.gz
index e43a6b727c7f9258bad0b3c5659c855496f062b4..9fa66927cd1918e6010503e2b8aef20387847ebd 100644 (file)
@@ -21,17 +21,17 @@ AC_PROG_CC
 AC_PROG_LIBTOOL
 
 # Checks for libraries.
-PKG_CHECK_MODULES(LIBAUTEDB, [libzakauthe >= 0.5.0
-                              libgtkform >= 0.5.0])
+PKG_CHECK_MODULES(LIBZAKAUTHEDB, [libzakauthe >= 0.5.0
+                                                                libgtkform >= 0.5.0])
 
-AC_SUBST(LIBAUTEDB_CFLAGS)
-AC_SUBST(LIBAUTEDB_LIBS)
+AC_SUBST(LIBZAKAUTHEDB_CFLAGS)
+AC_SUBST(LIBZAKAUTHEDB_LIBS)
 
-PKG_CHECK_MODULES(LIBCONFI, [libconfi >= 0.0.2], [AC_DEFINE(HAVE_LIBCONFI, [1], [libconfi is present]), have_libconfi=yes], have_libconfi=no)
+PKG_CHECK_MODULES(LIBZAKCONFI, [libzakconfi >= 0.0.2], [AC_DEFINE(HAVE_LIBZAKCONFI, [1], [libzakconfi is present]), have_libzakconfi=yes], have_libzakconfi=no)
 
-AM_CONDITIONAL(HAVE_LIBCONFI, test x"$have_libconfi" = "xyes")
-AC_SUBST(LIBCONFI_CFLAGS)
-AC_SUBST(LIBCONFI_LIBS)
+AM_CONDITIONAL(HAVE_LIBZAKCONFI, test x"$have_libzakconfi" = "xyes")
+AC_SUBST(LIBZAKCONFI_CFLAGS)
+AC_SUBST(LIBZAKCONFI_LIBS)
 
 AM_PATH_LIBGCRYPT(1.2.1, :, [AC_MSG_ERROR([libgcrypt >= 1.2.1 not found.])])
 
index 47ecae4f76593c9953380b3a5cca23f79b01bcc4..0bf578630083ff06939429eb53451b253a1aeac0 100644 (file)
@@ -1,17 +1,17 @@
 guidir = $(datadir)/libzakauthedb/gui
 formdir = $(datadir)/libzakauthedb/form
 
-AM_CPPFLAGS = $(LIBAUTEDB_CFLAGS) \
+AM_CPPFLAGS = $(LIBZAKAUTHEDB_CFLAGS) \
               $(LIBGCRYPT_CFLAGS) \
               $(GPG_ERROR_CFLAGS) \
-              $(LIBCONFI_CFLAGS) \
+              $(LIBZAKCONFI_CFLAGS) \
               -DGUIDIR=\""$(guidir)"\" \
               -DFORMDIR=\""$(formdir)"\"
 
-LIBS = $(LIBAUTEDB_LIBS) \
+LIBS = $(LIBZAKAUTHEDB_LIBS) \
        $(LIBGCRYPT_LIBS) \
        $(GPG_ERROR_LIBS) \
-       $(LIBCONFI_LIBS)
+       $(LIBZAKCONFI_LIBS)
 
 libzakauthe_pluginsdir = $(libdir)/libzakauthe/plugins
 libzakauthe_plugins_LTLIBRARIES = libzakauthedb.la
index 14c205e5644da51e60f69eac870385a304c8ef90..ece9c4e02ce8369f3356902484b7f57a3ffc1e68 100644 (file)
@@ -26,8 +26,8 @@
 #include <libgdaex/libgdaex.h>
 #include <libgtkform/fielddatetime.h>
 
-#ifdef HAVE_LIBCONFI
-       #include <libconfi.h>
+#ifdef HAVE_LIBZAKCONFI
+       #include <libzakconfi/libzakconfi.h>
 #endif
 
 #include "user.h"
@@ -84,13 +84,13 @@ DllMain (HINSTANCE hinstDLL,
 }
 #endif
 
-#ifdef HAVE_LIBCONFI
+#ifdef HAVE_LIBZAKCONFI
 static gboolean
-get_connection_parameters_from_confi (Confi *confi, gchar **cnc_string)
+get_connection_parameters_from_confi (ZakConfi *confi, gchar **cnc_string)
 {
        gboolean ret = TRUE;
 
-       *cnc_string = confi_path_get_value (confi, "libzakauthe/libzakauthedb/db/cnc_string");
+       *cnc_string = zak_confi_path_get_value (confi, "libzakauthe/libzakauthedb/db/cnc_string");
 
        if (*cnc_string == NULL
            || strcmp (g_strstrip (*cnc_string), "") == 0)
@@ -109,14 +109,16 @@ get_gdaex (GSList *parameters)
 
        cnc_string = NULL;
 
-#ifdef HAVE_LIBCONFI
-       /* the first and only parameters must be a Confi object */
-       /* leggo i parametri di connessione dalla configurazione */
-       if (IS_CONFI (parameters->data))
+#ifdef HAVE_LIBZAKCONFI
+       /* the first and only parameters must be a ZakConfi object */
+       if (g_strcmp0 ((gchar *)parameters->data, "{libzakconfi}") == 0)
                {
-                       if (!get_connection_parameters_from_confi (CONFI (parameters->data), &cnc_string))
+                       if (ZAK_IS_CONFI ((ZakConfi *)g_slist_nth_data (parameters, 1)))
                                {
-                                       cnc_string = NULL;
+                                       if (!get_connection_parameters_from_confi (ZAK_CONFI ((ZakConfi *)g_slist_nth_data (parameters, 1)), &cnc_string))
+                                               {
+                                                       cnc_string = NULL;
+                                               }
                                }
                }
 #endif
index 9cda2104de1668a86afe739119967aa1ba1f84c5..e3c4da26f18a37a152932dfa778180407a2ab400 100644 (file)
@@ -1,12 +1,17 @@
 AM_CPPFLAGS = $(WARN_CFLAGS) \
               $(DISABLE_DEPRECATED_CFLAGS) \
-              $(LIBAUTEDB_CFLAGS) \
+              $(LIBZAKAUTHEDB_CFLAGS) \
+              $(LIBZAKCONFI_CFLAGS) \
               -I../src
 
 LIBS = $(GTK_LIBS) \
-       $(LIBAUTEDB_LIBS)
+       $(LIBZAKAUTHEDB_LIBS) \
+       $(LIBZAKCONFI_LIBS)
 
 LDADD = ../src/libzakauthedb.la
 
 noinst_PROGRAMS = test \
+                  test_confi \
                   test_nogui
+
+EXTRA_DIST = test_confi.conf
diff --git a/tests/test_confi.c b/tests/test_confi.c
new file mode 100644 (file)
index 0000000..a90a356
--- /dev/null
@@ -0,0 +1,48 @@
+/*
+ * Copyright (C) 2016 Andrea Zagli <azagli@libero.it>
+ *
+ *  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 <gtk/gtk.h>
+
+#include <libzakconfi/libzakconfi.h>
+
+#include <libzakauthe.h>
+
+int
+main (int argc, char **argv)
+{
+       ZakAuthe *aute;
+       ZakConfi *confi;
+       GSList *params;
+
+       gtk_init (&argc, &argv);
+
+       aute = zak_authe_new ();
+
+       params = NULL;
+
+       confi = zak_confi_new (argv[1]);
+
+       params = g_slist_append (params, "{libzakconfi}");
+       params = g_slist_append (params, confi);
+
+       zak_authe_set_config (aute, params);
+
+       g_message ("User %s\n", zak_authe_authe (aute));
+
+       return 0;
+}
diff --git a/tests/test_confi.conf b/tests/test_confi.conf
new file mode 100644 (file)
index 0000000..3fe6263
--- /dev/null
@@ -0,0 +1,5 @@
+[libzakauthe]
+plugin=/usr/local/lib/libzakauthe/plugins/libzakauthedb.so
+
+[libzakauthe/libzakauthedb/db]
+cnc_string=PostgreSql://postgres:postgres@HOST=localhost;DB_NAME=autedb
\ No newline at end of file