]> saetta.ns0.it Git - libzakcgi/commitdiff
Added functions Session::set_from_form and ::fill_form (closes #994).
authorAndrea Zagli <azagli@libero.it>
Thu, 12 May 2016 10:03:45 +0000 (12:03 +0200)
committerAndrea Zagli <azagli@libero.it>
Thu, 12 May 2016 11:07:01 +0000 (13:07 +0200)
configure.ac
libzakcgi.pc.in
src/session.c
src/session.h

index 2c9147985ab360b60c0dc09161c2589768bc6b71..a02bbbf52a5023e3341194f6dc3adea38c273702 100644 (file)
@@ -34,7 +34,8 @@ PKG_CHECK_MODULES(ZAKCGI, [glib-2.0 >= 2.36
                            gobject-2.0 >= 2.36
                            gio-2.0 >= 2.36
                            gio-unix-2.0 >= 2.36
-                           libzakform >= 0.0.1])
+                           libzakform >= 0.0.1
+                           libzakformini])
 
 AC_SUBST(ZAKCGI_CFLAGS)
 AC_SUBST(ZAKCGI_LIBS)
index 453643a6807ad31dc2aaf39d6fbf8bebfd824cf9..5b736f5047c3b2482c7cb28553d8aae8509c809a 100644 (file)
@@ -6,6 +6,6 @@ includedir=@includedir@
 Name: @PACKAGE_NAME@
 Description: Class for CGI.
 Version: @PACKAGE_VERSION@
-Requires: glib-2.0 >= 2.36 gobject-2.0 gio-2.0 gio-unix-2.0
+Requires: glib-2.0 >= 2.36 gobject-2.0 gio-2.0 gio-unix-2.0 libzakform libzakformini
 Libs: -L${libdir} -lzakcgi
 Cflags: -I${includedir}
index 1439ce37415ee1caec864095605d52c2f0376198..abcc82a203df22476b5edd5786de1f3e585859a7 100644 (file)
@@ -26,6 +26,8 @@
 
 #include <string.h>
 
+#include <libzakformini/libzakformini.h>
+
 #include "session.h"
 
 static void zak_cgi_session_class_init (ZakCgiSessionClass *class);
@@ -54,6 +56,7 @@ struct _ZakCgiSessionPrivate
                gchar *sid;
                GFile *gfile;
                GKeyFile *kfile;
+               ZakFormIniProvider *zakformini;
        };
 
 G_DEFINE_TYPE (ZakCgiSession, zak_cgi_session, G_TYPE_OBJECT)
@@ -81,6 +84,7 @@ zak_cgi_session_init (ZakCgiSession *zak_cgi_session)
        priv->path = NULL;
        priv->gfile = NULL;
        priv->kfile = NULL;
+       priv->zakformini = NULL;
 }
 
 /**
@@ -512,6 +516,47 @@ zak_cgi_session_get_value_full_boolean (ZakCgiSession *session, const gchar *gro
        return (gboolean)zak_cgi_session_get_value_full_int (session, group, name);
 }
 
+static void
+zak_cgi_session_get_form_ini_provider (ZakCgiSession *session)
+{
+       ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (session);
+
+       if (priv->zakformini == NULL)
+               {
+                       priv->zakformini = zak_form_ini_provider_new_from_gkeyfile (priv->kfile, g_file_get_path (priv->gfile));
+               }
+}
+
+/**
+ * zak_cgi_session_set_from_form:
+ * @session:
+ * @form:
+ *
+ */
+void
+zak_cgi_session_set_from_form (ZakCgiSession *session, ZakFormForm *form)
+{
+       ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (session);
+
+       zak_cgi_session_get_form_ini_provider (session);
+       zak_form_form_insert (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (priv->zakformini));
+}
+
+/**
+ * zak_cgi_session_fill_form:
+ * @session:
+ * @form:
+ *
+ */
+void
+zak_cgi_session_fill_form (ZakCgiSession *session, ZakFormForm *form)
+{
+       ZakCgiSessionPrivate *priv = ZAK_CGI_SESSION_GET_PRIVATE (session);
+
+       zak_cgi_session_get_form_ini_provider (session);
+       zak_form_form_load (ZAK_FORM_FORM (form), ZAK_FORM_IPROVIDER (priv->zakformini));
+}
+
 /**
  * zak_cgi_session_close:
  * @session:
index ce238a649148242008429be10abf7ee6694876f0..1bb0943e861b89c3e5c63c02dce2b901bea52e6d 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <glib-object.h>
 
+#include <libzakform/libzakform.h>
+
 #include "main.h"
 
 
@@ -71,6 +73,9 @@ gint zak_cgi_session_get_value_full_int (ZakCgiSession *session, const gchar *gr
 gdouble zak_cgi_session_get_value_full_double (ZakCgiSession *session, const gchar *group, const gchar *name);
 gboolean zak_cgi_session_get_value_full_boolean (ZakCgiSession *session, const gchar *group, const gchar *name);
 
+void zak_cgi_session_set_from_form (ZakCgiSession *session, ZakFormForm *form);
+void zak_cgi_session_fill_form (ZakCgiSession *session, ZakFormForm *form);
+
 void zak_cgi_session_close (ZakCgiSession *session);