]> saetta.ns0.it Git - libzakcgi/commitdiff
Use of libzakform.
authorAndrea Zagli <azagli@libero.it>
Sat, 31 Oct 2015 15:48:47 +0000 (16:48 +0100)
committerAndrea Zagli <azagli@libero.it>
Sat, 31 Oct 2015 15:48:47 +0000 (16:48 +0100)
24 files changed:
configure.ac
src/Makefile.am
src/form.c
src/form.h
src/formelement.c
src/formelement.h
src/formelementcheck.c
src/formelementfiltertrim.c [deleted file]
src/formelementfiltertrim.h [deleted file]
src/formelementhidden.c
src/formelementifilter.c [deleted file]
src/formelementifilter.h [deleted file]
src/formelementivalidator.c [deleted file]
src/formelementivalidator.h [deleted file]
src/formelementpassword.c
src/formelementselect.c
src/formelementstring.c
src/formelementtext.c
src/formelementtextarea.c
src/formelementvalidatornotempty.c [deleted file]
src/formelementvalidatornotempty.h [deleted file]
src/formelementvalidatorregex.c [deleted file]
src/formelementvalidatorregex.h [deleted file]
tests/form.c

index e8bb6e55dda3c4baa4a7f8a8a8607a41b67beb52..2c9147985ab360b60c0dc09161c2589768bc6b71 100644 (file)
@@ -33,7 +33,8 @@ AC_PROG_RANLIB
 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])
+                           gio-unix-2.0 >= 2.36
+                           libzakform >= 0.0.1])
 
 AC_SUBST(ZAKCGI_CFLAGS)
 AC_SUBST(ZAKCGI_LIBS)
index 3c58f477b79b26a7184281c43a01029c8f68ec94..62477160ab78d3ab3893a235f366fa9e4134c2bf 100644 (file)
@@ -17,11 +17,6 @@ libzakcgi_la_SOURCES = commons.c \
                        formelementtext.c \
                        formelementtextarea.c \
                        formelementsubmit.c \
-                       formelementifilter.c \
-                       formelementfiltertrim.c \
-                       formelementivalidator.c \
-                       formelementvalidatornotempty.c \
-                       formelementvalidatorregex.c \
                        main.c \
                        session.c \
                        tag.c \
@@ -41,11 +36,6 @@ libzakcgi_include_HEADERS = \
                             formelementtext.h \
                             formelementtextarea.h \
                             formelementsubmit.h \
-                            formelementifilter.h \
-                            formelementfiltertrim.h \
-                            formelementivalidator.h \
-                            formelementvalidatornotempty.h \
-                            formelementvalidatorregex.h \
                             main.h \
                             session.h \
                             tag.h \
index 351fa503397e29c84f6083c003c6b142f3bba60a..44a271bdefc66b4f5b096848cf381d7233b9a82f 100644 (file)
@@ -51,7 +51,7 @@ struct _ZakCgiFormPrivate
                GPtrArray *ar_elems;
        };
 
-G_DEFINE_TYPE (ZakCgiForm, zak_cgi_form, G_TYPE_OBJECT)
+G_DEFINE_TYPE (ZakCgiForm, zak_cgi_form, ZAK_FORM_TYPE_FORM)
 
 static void
 zak_cgi_form_class_init (ZakCgiFormClass *class)
@@ -73,7 +73,7 @@ zak_cgi_form_init (ZakCgiForm *zak_cgi_form)
 
        priv->zakcgimain = NULL;
        priv->ht_attrs = NULL;
-       priv->ar_elems = g_ptr_array_new ();
+       priv->ar_elems = ZAK_FORM_FORM_CLASS (zak_cgi_form_parent_class)->get_elements (ZAK_FORM_FORM (zak_cgi_form));
 }
 
 /**
@@ -129,61 +129,6 @@ get_idx (ZakCgiForm *zakcgiform, const gchar *id)
        return idx;
 }
 
-/**
- * zak_cgi_form_add_element:
- * @zakcgiform:
- * @element:
- *
- * Returns: #TRUE if @element is added; FALSE otherwise.
- */
-gboolean
-zak_cgi_form_add_element (ZakCgiForm *zakcgiform, ZakCgiFormElement *element)
-{
-       gboolean ret;
-       gchar *id;
-
-       ZakCgiFormPrivate *priv;
-
-       priv = ZAK_CGI_FORM_GET_PRIVATE (zakcgiform);
-
-       id = zak_cgi_form_element_get_id (element);
-
-       if (get_idx (zakcgiform, id) > -1)
-               {
-                       g_warning ("You cannot add an element with id already present in the form.");
-                       ret = FALSE;
-               }
-       else
-               {
-                       g_ptr_array_add (priv->ar_elems, g_object_ref (element));
-                       ret = TRUE;
-               }
-
-       g_free (id);
-
-       return ret;
-}
-
-/**
- * zak_cgi_form_add_str:
- * @zakcgiform:
- * @str:
- *
- * Returns: #TRUE if @str is added; FALSE otherwise.
- */
-gboolean
-zak_cgi_form_add_str (ZakCgiForm *zakcgiform, const gchar *str)
-{
-       gboolean ret;
-
-       ZakCgiFormElement *element;
-
-       element = zak_cgi_form_element_string_new (str);
-       ret = zak_cgi_form_add_element (zakcgiform, element);
-
-       return ret;
-}
-
 /**
  * zak_cgi_form_bind:
  * @zakcgiform:
@@ -210,46 +155,12 @@ zak_cgi_form_bind (ZakCgiForm *zakcgiform)
                                        gval = zak_cgi_main_get_stdin_field (priv->zakcgimain, zak_cgi_form_element_get_id (element));
                                        if (gval != NULL)
                                                {
-                                                       zak_cgi_form_element_set_value (element, gval);
+                                                       zak_form_element_set_value (ZAK_FORM_ELEMENT (element), g_value_get_string (gval));
                                                }
                                }
                }
 }
 
-/**
- * zak_cgi_form_is_valid:
- * @zakcgiform:
- *
- * Returns:
- */
-gboolean
-zak_cgi_form_is_valid (ZakCgiForm *zakcgiform)
-{
-       guint i;
-
-       gboolean ret;
-
-       ZakCgiFormPrivate *priv;
-
-       priv = ZAK_CGI_FORM_GET_PRIVATE (zakcgiform);
-
-       ret = TRUE;
-
-       for (i = 0; i < priv->ar_elems->len; i++)
-               {
-                       ZakCgiFormElement *element = (ZakCgiFormElement *)g_ptr_array_index (priv->ar_elems, i);
-                       if (!ZAK_CGI_IS_FORM_ELEMENT_STRING (element))
-                               {
-                                       if (!zak_cgi_form_element_is_valid (element))
-                                               {
-                                                       ret = FALSE;
-                                               }
-                               }
-               }
-
-       return ret;
-}
-
 /**
  * zak_cgi_form_render_start:
  * @zakcgiform:
@@ -265,7 +176,7 @@ gchar
 
        ZakCgiFormPrivate *priv;
 
-       g_return_if_fail (ZAK_CGI_IS_FORM (zakcgiform));
+       g_return_val_if_fail (ZAK_CGI_IS_FORM (zakcgiform), g_strdup (""));
 
        priv = ZAK_CGI_FORM_GET_PRIVATE (zakcgiform);
 
index 1a6eaa823f86c914e3dcf245ce973398ff80b2ab..01fb4759a0e7136a91bfa1a7f87af3927b6171f6 100644 (file)
@@ -22,6 +22,8 @@
 
 #include <glib-object.h>
 
+#include <libzakform/libzakform.h>
+
 #include "main.h"
 #include "formelement.h"
 
 G_BEGIN_DECLS
 
 
-#define ZAK_CGI_TYPE_FORM                 (zak_cgi_form_get_type ())
-#define ZAK_CGI_FORM(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_CGI_TYPE_FORM, ZakCgiForm))
-#define ZAK_CGI_FORM_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_CGI_TYPE_FORM, ZakCgiFormClass))
-#define ZAK_CGI_IS_FORM(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_CGI_TYPE_FORM))
-#define ZAK_CGI_IS_FORM_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_CGI_TYPE_FORM))
-#define ZAK_CGI_FORM_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_CGI_TYPE_FORM, ZakCgiFormClass))
-
-typedef struct _ZakCgiForm ZakCgiForm;
-typedef struct _ZakCgiFormClass ZakCgiFormClass;
-
-struct _ZakCgiForm
-       {
-               GObject parent_instance;
-       };
+#define ZAK_CGI_TYPE_FORM zak_cgi_form_get_type ()
+G_DECLARE_DERIVABLE_TYPE (ZakCgiForm, zak_cgi_form, ZAK_CGI, FORM, ZakFormForm)
 
 struct _ZakCgiFormClass
-       {
-               GObjectClass parent_class;
-       };
-
-GType zak_cgi_form_get_type (void);
+{
+       ZakFormFormClass parent_class;
+};
 
 
 ZakCgiForm *zak_cgi_form_new (ZakCgiMain *zakcgimain, ...);
 
-gboolean zak_cgi_form_add_element (ZakCgiForm *zakcgiform, ZakCgiFormElement *element);
-gboolean zak_cgi_form_add_str (ZakCgiForm *zakcgiform, const gchar *str);
-
 void zak_cgi_form_bind (ZakCgiForm *zakcgiform);
-gboolean zak_cgi_form_is_valid (ZakCgiForm *zakcgiform);
 
 gchar *zak_cgi_form_render_start (ZakCgiForm *zakcgiform);
 gchar *zak_cgi_form_render (ZakCgiForm *zakcgiform);
index dd93d2e6573d469a39f598232b8487c7e6e0f41d..77abc0e9207c52426a6600b38e7ead89c50ac0c7 100644 (file)
@@ -59,13 +59,10 @@ struct _ZakCgiFormElementPrivate
        {
                gchar *id;
                GHashTable *ht_attrs;
-               GPtrArray *pa_filters;
-               GPtrArray *pa_validators;
-               GValue *value;
                GHashTable *ht_label_attrs;
        };
 
-G_DEFINE_TYPE (ZakCgiFormElement, zak_cgi_form_element, G_TYPE_OBJECT)
+G_DEFINE_TYPE (ZakCgiFormElement, zak_cgi_form_element, ZAK_FORM_TYPE_ELEMENT)
 
 static void
 zak_cgi_form_element_class_init (ZakCgiFormElementClass *class)
@@ -89,9 +86,6 @@ zak_cgi_form_element_init (ZakCgiFormElement *zak_cgi_form_element)
        ZakCgiFormElementPrivate *priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (zak_cgi_form_element);
 
        priv->ht_attrs = NULL;
-       priv->pa_filters = NULL;
-       priv->pa_validators = NULL;
-       priv->value = NULL;
        priv->ht_label_attrs = NULL;
 }
 
@@ -105,90 +99,6 @@ gchar
        return g_strdup (priv->id);
 }
 
-/**
- * zak_cgi_form_element_add_filter:
- * @element:
- * @filter:
- *
- */
-void
-zak_cgi_form_element_add_filter (ZakCgiFormElement *element, ZakCgiFormElementIFilter *filter)
-{
-       ZakCgiFormElementPrivate *priv;
-
-       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
-
-       if (priv->pa_filters == NULL)
-               {
-                       priv->pa_filters = g_ptr_array_new ();
-               }
-
-       g_ptr_array_add (priv->pa_filters, filter);
-}
-
-/**
- * zak_cgi_form_element_filter:
- * @element:
- *
- */
-void
-zak_cgi_form_element_filter (ZakCgiFormElement *element)
-{
-       guint i;
-
-       ZakCgiFormElementPrivate *priv;
-
-       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
-
-       if (priv->pa_filters == NULL)
-               {
-                       return;
-               }
-
-       for (i = 0; i < priv->pa_filters->len; i++)
-               {
-                       GValue *value;
-                       GValue *val;
-
-                       value = zak_cgi_form_element_get_value (element);
-
-                       val = zak_cgi_form_element_ifilter_filter ((ZakCgiFormElementIFilter *)g_ptr_array_index (priv->pa_filters, i),
-                                                                                                          value);
-                       zak_cgi_form_element_set_value (element, val);
-               }
-}
-
-/**
- * zak_cgi_form_element_set_value:
- * @element:
- * @value:
- *
- */
-void
-zak_cgi_form_element_set_value (ZakCgiFormElement *element, GValue *value)
-{
-       ZakCgiFormElementPrivate *priv;
-
-       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
-
-       priv->value = value;
-}
-
-/**
- * zak_cgi_form_element_get_value:
- * @element:
- *
- */
-GValue
-*zak_cgi_form_element_get_value (ZakCgiFormElement *element)
-{
-       ZakCgiFormElementPrivate *priv;
-
-       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
-
-       return priv->value;
-}
-
 /**
  * zak_cgi_form_element_set_label:
  * @element:
@@ -272,72 +182,6 @@ gchar
        return ret;
 }
 
-/**
- * zak_cgi_form_element_add_validator:
- * @element:
- * @validator:
- *
- */
-void
-zak_cgi_form_element_add_validator (ZakCgiFormElement *element, ZakCgiFormElementIValidator *validator)
-{
-       ZakCgiFormElementPrivate *priv;
-
-       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
-
-       if (priv->pa_validators == NULL)
-               {
-                       priv->pa_validators = g_ptr_array_new ();
-               }
-
-       g_ptr_array_add (priv->pa_validators, validator);
-}
-
-/**
- * zak_cgi_form_element_is_valid:
- * @element:
- *
- */
-gboolean
-zak_cgi_form_element_is_valid (ZakCgiFormElement *element)
-{
-       gboolean ret;
-
-       GValue *value;
-       guint i;
-
-       ZakCgiFormElementPrivate *priv;
-
-       priv = ZAK_CGI_FORM_ELEMENT_GET_PRIVATE (element);
-
-       ret = TRUE;
-
-       zak_cgi_form_element_filter (element);
-
-       if (priv->pa_validators != NULL)
-               {
-                       value = zak_cgi_form_element_get_value (element);
-
-                       for (i = 0; i < priv->pa_validators->len; i++)
-                               {
-                                       if (!zak_cgi_form_element_ivalidator_validate ((ZakCgiFormElementIValidator *)g_ptr_array_index (priv->pa_validators, i),
-                                                                                                                                  value))
-                                               {
-                                                       ret = FALSE;
-                                               }
-                               }
-               }
-
-       if (ZAK_CGI_IS_FORM_ELEMENT (element) && ZAK_CGI_FORM_ELEMENT_GET_CLASS (element)->is_valid != NULL)
-               {
-                       if (!ZAK_CGI_FORM_ELEMENT_GET_CLASS (element)->is_valid (element))
-                               {
-                                       ret = FALSE;
-                               }
-               }
-       return ret;
-}
-
 /* PRIVATE */
 static void
 zak_cgi_form_element_construct (ZakCgiFormElement *element,
index 34a89008498e24ec95b77494ea7a4ef217f4d530..6c1efd75e964b15bc8ce0cb65d3b496e10383e98 100644 (file)
 
 #include <glib-object.h>
 
+#include <libzakform/libzakform.h>
+
 #include "main.h"
-#include "formelementifilter.h"
-#include "formelementivalidator.h"
 
 
 G_BEGIN_DECLS
 
 
-#define ZAK_CGI_TYPE_FORM_ELEMENT                 (zak_cgi_form_element_get_type ())
-#define ZAK_CGI_FORM_ELEMENT(obj)                 (G_TYPE_CHECK_INSTANCE_CAST ((obj), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElement))
-#define ZAK_CGI_FORM_ELEMENT_CLASS(klass)         (G_TYPE_CHECK_CLASS_CAST ((klass), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElementClass))
-#define ZAK_CGI_IS_FORM_ELEMENT(obj)              (G_TYPE_CHECK_INSTANCE_TYPE ((obj), ZAK_CGI_TYPE_FORM_ELEMENT))
-#define ZAK_CGI_IS_FORM_ELEMENT_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE ((klass), ZAK_CGI_TYPE_FORM_ELEMENT))
-#define ZAK_CGI_FORM_ELEMENT_GET_CLASS(obj)       (G_TYPE_INSTANCE_GET_CLASS ((obj), ZAK_CGI_TYPE_FORM_ELEMENT, ZakCgiFormElementClass))
-
-typedef struct _ZakCgiFormElement ZakCgiFormElement;
-typedef struct _ZakCgiFormElementClass ZakCgiFormElementClass;
-
-struct _ZakCgiFormElement
-       {
-               GObject parent_instance;
-       };
+#define ZAK_CGI_TYPE_FORM_ELEMENT zak_cgi_form_element_get_type ()
+G_DECLARE_DERIVABLE_TYPE (ZakCgiFormElement, zak_cgi_form_element, ZAK_CGI, FORM_ELEMENT, ZakFormElement)
 
 struct _ZakCgiFormElementClass
        {
-               GObjectClass parent_class;
+               ZakFormElementClass parent_class;
 
                void (*construct) (ZakCgiFormElement *element, const gchar *id, GHashTable *ht_attrs);
                GHashTable *(*get_ht_attrs) (ZakCgiFormElement *element);
 
                gchar *(*render) (ZakCgiFormElement *element);
-               gboolean (*is_valid) (ZakCgiFormElement *element);
        };
 
 
-GType zak_cgi_form_element_get_type (void);
-
 gchar *zak_cgi_form_element_get_id (ZakCgiFormElement *element);
 
-void zak_cgi_form_element_add_filter (ZakCgiFormElement *element, ZakCgiFormElementIFilter *filter);
-void zak_cgi_form_element_filter (ZakCgiFormElement *element);
-
-void zak_cgi_form_element_set_value (ZakCgiFormElement *element, GValue *value);
-GValue *zak_cgi_form_element_get_value (ZakCgiFormElement *element);
-
 void zak_cgi_form_element_set_label (ZakCgiFormElement *element, const gchar *label, ...);
 
 gchar *zak_cgi_form_element_render (ZakCgiFormElement *element);
 
-void zak_cgi_form_element_add_validator (ZakCgiFormElement *element, ZakCgiFormElementIValidator *validator);
-gboolean zak_cgi_form_element_is_valid (ZakCgiFormElement *element);
-
 
 G_END_DECLS
 
index fc5d82a035a83827f27da931289968a1d858e2ee..21fd3da760cb7b6a86b4623ae9f94113d3803707 100644 (file)
@@ -116,7 +116,7 @@ static gchar
 
        GHashTable *ht_attrs;
 
-       GValue *value;
+       gchar *value;
 
        ZakCgiFormElementClass *klass;
 
@@ -124,10 +124,10 @@ static gchar
 
        ht_attrs = klass->get_ht_attrs (element);
 
-       value = zak_cgi_form_element_get_value (element);
+       value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_value_get_string (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("input", zak_cgi_form_element_get_id (element), ht_attrs);
diff --git a/src/formelementfiltertrim.c b/src/formelementfiltertrim.c
deleted file mode 100644 (file)
index d079967..0000000
+++ /dev/null
@@ -1,178 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include "formelementifilter.h"
-#include "formelementfiltertrim.h"
-
-static void zak_cgi_form_element_filter_trim_class_init (ZakCgiFormElementFilterTrimClass *class);
-static void zak_cgi_form_element_filter_trim_interface_init (ZakCgiFormElementIFilterInterface *iface);
-static void zak_cgi_form_element_filter_trim_init (ZakCgiFormElementFilterTrim *zak_cgi_form_element);
-
-static void zak_cgi_form_element_filter_trim_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
-static void zak_cgi_form_element_filter_trim_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
-
-static void zak_cgi_form_element_filter_trim_dispose (GObject *gobject);
-static void zak_cgi_form_element_filter_trim_finalize (GObject *gobject);
-
-static GValue *zak_cgi_form_element_filter_trim_filter (ZakCgiFormElementIFilter *filter_trim, GValue *value);
-
-struct _ZakCgiFormElementFilterTrim
-{
-       GObject parent_instance;
-
-       /* Other members, including private data. */
-};
-
-#define ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CGI_TYPE_FORM_ELEMENT_FILTER_TRIM, ZakCgiFormElementFilterTrimPrivate))
-
-typedef struct _ZakCgiFormElementFilterTrimPrivate ZakCgiFormElementFilterTrimPrivate;
-struct _ZakCgiFormElementFilterTrimPrivate
-       {
-               gpointer nothing;
-       };
-
-G_DEFINE_TYPE_WITH_CODE (ZakCgiFormElementFilterTrim, zak_cgi_form_element_filter_trim, G_TYPE_OBJECT,
-                                                G_IMPLEMENT_INTERFACE (ZAK_CGI_TYPE_FORM_ELEMENT_IFILTER,
-                                                                                               zak_cgi_form_element_filter_trim_interface_init))
-
-static void
-zak_cgi_form_element_filter_trim_class_init (ZakCgiFormElementFilterTrimClass *class)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-       object_class->set_property = zak_cgi_form_element_filter_trim_set_property;
-       object_class->get_property = zak_cgi_form_element_filter_trim_get_property;
-       object_class->dispose = zak_cgi_form_element_filter_trim_dispose;
-       object_class->finalize = zak_cgi_form_element_filter_trim_finalize;
-
-       g_type_class_add_private (object_class, sizeof (ZakCgiFormElementFilterTrimPrivate));
-}
-
-static void
-zak_cgi_form_element_filter_trim_interface_init (ZakCgiFormElementIFilterInterface *iface)
-{
-       iface->filter = zak_cgi_form_element_filter_trim_filter;
-}
-
-static void
-zak_cgi_form_element_filter_trim_init (ZakCgiFormElementFilterTrim *zak_cgi_form_element)
-{
-       ZakCgiFormElementFilterTrimPrivate *priv = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_cgi_form_element);
-}
-
-/**
- * zak_cgi_form_element_filter_trim_new:
- *
- * Returns: the newly created #ZakCgiFormElementFilterTrim object.
- */
-ZakCgiFormElementFilterTrim
-*zak_cgi_form_element_filter_trim_new ()
-{
-       ZakCgiFormElementFilterTrim *zak_cgi_form_element_filter_trim;
-
-       zak_cgi_form_element_filter_trim = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM (g_object_new (zak_cgi_form_element_filter_trim_get_type (), NULL));
-
-       return zak_cgi_form_element_filter_trim;
-}
-
-/* PRIVATE */
-static void
-zak_cgi_form_element_filter_trim_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
-{
-       ZakCgiFormElementFilterTrim *zak_cgi_form_element = (ZakCgiFormElementFilterTrim *)object;
-       ZakCgiFormElementFilterTrimPrivate *priv = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_cgi_form_element);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-zak_cgi_form_element_filter_trim_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
-{
-       ZakCgiFormElementFilterTrim *zak_cgi_form_element = (ZakCgiFormElementFilterTrim *)object;
-       ZakCgiFormElementFilterTrimPrivate *priv = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_cgi_form_element);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-zak_cgi_form_element_filter_trim_dispose (GObject *gobject)
-{
-       ZakCgiFormElementFilterTrim *zak_cgi_form_element = (ZakCgiFormElementFilterTrim *)gobject;
-       ZakCgiFormElementFilterTrimPrivate *priv = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_cgi_form_element);
-
-
-
-       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
-       parent_class->dispose (gobject);
-}
-
-static void
-zak_cgi_form_element_filter_trim_finalize (GObject *gobject)
-{
-       ZakCgiFormElementFilterTrim *zak_cgi_form_element = (ZakCgiFormElementFilterTrim *)gobject;
-       ZakCgiFormElementFilterTrimPrivate *priv = ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_GET_PRIVATE (zak_cgi_form_element);
-
-
-
-       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
-       parent_class->finalize (gobject);
-}
-
-static GValue
-*zak_cgi_form_element_filter_trim_filter (ZakCgiFormElementIFilter *filter_trim,
-                                                                                 GValue *value)
-{
-       GValue *ret;
-       gchar *_value;
-
-       g_return_val_if_fail (value != NULL, g_strdup (""));
-
-       _value = g_strdup (g_value_get_string (value));
-
-       ret = g_new0 (GValue, 1);
-       g_value_init (ret, G_TYPE_STRING);
-       g_value_set_string (ret, g_strdup (g_strstrip (_value)));
-
-       return ret;
-}
diff --git a/src/formelementfiltertrim.h b/src/formelementfiltertrim.h
deleted file mode 100644 (file)
index 7b84a0d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_H__
-#define __ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_H__
-
-
-#include <glib-object.h>
-
-
-G_BEGIN_DECLS
-
-
-#define ZAK_CGI_TYPE_FORM_ELEMENT_FILTER_TRIM zak_cgi_form_element_filter_trim_get_type ()
-G_DECLARE_FINAL_TYPE (ZakCgiFormElementFilterTrim, zak_cgi_form_element_filter_trim, ZAK_CGI, FORM_ELEMENT_FILTER_TRIM, GObject)
-
-ZakCgiFormElementFilterTrim *zak_cgi_form_element_filter_trim_new (void);
-
-
-G_END_DECLS
-
-
-#endif /* __ZAK_CGI_FORM_ELEMENT_FILTER_TRIM_H__ */
index f2832b1671304bfff3c414ceb3000b476a5b17df..f612eb9f8b5ac7f45b456539d7e6c3b21b2b1229 100644 (file)
@@ -114,7 +114,7 @@ static gchar
 
        GHashTable *ht_attrs;
 
-       GValue *value;
+       gchar *value;
 
        ZakCgiFormElementClass *klass;
 
@@ -122,10 +122,10 @@ static gchar
 
        ht_attrs = klass->get_ht_attrs (element);
 
-       value = zak_cgi_form_element_get_value (element);
+       value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_value_get_string (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("input", zak_cgi_form_element_get_id (element), ht_attrs);
diff --git a/src/formelementifilter.c b/src/formelementifilter.c
deleted file mode 100644 (file)
index b518632..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "formelementifilter.h"
-
-G_DEFINE_INTERFACE (ZakCgiFormElementIFilter, zak_cgi_form_element_ifilter, G_TYPE_OBJECT);
-
-static void
-zak_cgi_form_element_ifilter_default_init (ZakCgiFormElementIFilterInterface *iface)
-{
-    /* add properties and signals to the interface here */
-}
-
-GValue
-*zak_cgi_form_element_ifilter_filter (ZakCgiFormElementIFilter *self, GValue *value)
-{
-       g_return_if_fail (ZAK_CGI_IS_FORM_ELEMENT_IFILTER (self));
-
-       return ZAK_CGI_FORM_ELEMENT_IFILTER_GET_IFACE (self)->filter (self, value);
-}
diff --git a/src/formelementifilter.h b/src/formelementifilter.h
deleted file mode 100644 (file)
index fb8a09f..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __ZAK_CGI_FORM_ELEMENT_IFILTER_H__
-#define __ZAK_CGI_FORM_ELEMENT_IFILTER_H__
-
-#include <glib-object.h>
-
-
-G_BEGIN_DECLS
-
-
-#define ZAK_CGI_TYPE_FORM_ELEMENT_IFILTER zak_cgi_form_element_ifilter_get_type ()
-G_DECLARE_INTERFACE (ZakCgiFormElementIFilter, zak_cgi_form_element_ifilter, ZAK_CGI, FORM_ELEMENT_IFILTER, GObject)
-
-struct _ZakCgiFormElementIFilterInterface
-{
-       GTypeInterface parent_iface;
-
-       GValue *(*filter) (ZakCgiFormElementIFilter *self, GValue *value);
-};
-
-GValue *zak_cgi_form_element_ifilter_filter (ZakCgiFormElementIFilter *self, GValue *value);
-
-
-G_END_DECLS
-
-
-#endif /* __ZAK_CGI_FOR_ELEMENT_IFILTER_H__ */
diff --git a/src/formelementivalidator.c b/src/formelementivalidator.c
deleted file mode 100644 (file)
index 21b9734..0000000
+++ /dev/null
@@ -1,35 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#include "formelementivalidator.h"
-
-G_DEFINE_INTERFACE (ZakCgiFormElementIValidator, zak_cgi_form_element_ivalidator, G_TYPE_OBJECT);
-
-static void
-zak_cgi_form_element_ivalidator_default_init (ZakCgiFormElementIValidatorInterface *iface)
-{
-    /* add properties and signals to the interface here */
-}
-
-gboolean
-zak_cgi_form_element_ivalidator_validate (ZakCgiFormElementIValidator *self, GValue *value)
-{
-       g_return_if_fail (ZAK_CGI_IS_FORM_ELEMENT_IVALIDATOR (self));
-
-       return ZAK_CGI_FORM_ELEMENT_IVALIDATOR_GET_IFACE (self)->validate (self, value);
-}
diff --git a/src/formelementivalidator.h b/src/formelementivalidator.h
deleted file mode 100644 (file)
index cbce915..0000000
+++ /dev/null
@@ -1,44 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __ZAK_CGI_FORM_ELEMENT_IVALIDATOR_H__
-#define __ZAK_CGI_FORM_ELEMENT_IVALIDATOR_H__
-
-#include <glib-object.h>
-
-
-G_BEGIN_DECLS
-
-
-#define ZAK_CGI_TYPE_FORM_ELEMENT_IVALIDATOR zak_cgi_form_element_ivalidator_get_type ()
-G_DECLARE_INTERFACE (ZakCgiFormElementIValidator, zak_cgi_form_element_ivalidator, ZAK_CGI, FORM_ELEMENT_IVALIDATOR, GObject)
-
-struct _ZakCgiFormElementIValidatorInterface
-{
-       GTypeInterface parent_iface;
-
-       gboolean (*validate) (ZakCgiFormElementIValidator *self, GValue *value);
-};
-
-gboolean zak_cgi_form_element_ivalidator_validate (ZakCgiFormElementIValidator *self, GValue *value);
-
-
-G_END_DECLS
-
-
-#endif /* __ZAK_CGI_FOR_ELEMENT_IVALIDATOR_H__ */
index 88d2c33b4d589217707a6d83fa21374a46cd26a4..1797db436d6f1be42d5e3b4e02547ef9c7e9f278 100644 (file)
@@ -114,7 +114,7 @@ static gchar
 
        GHashTable *ht_attrs;
 
-       GValue *value;
+       gchar *value;
 
        ZakCgiFormElementClass *klass;
 
@@ -122,10 +122,10 @@ static gchar
 
        ht_attrs = klass->get_ht_attrs (element);
 
-       value = zak_cgi_form_element_get_value (element);
+       value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_value_get_string (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("input", zak_cgi_form_element_get_id (element), ht_attrs);
index 6f6e90c3285e2ae302bbcd20de585962b78910b9..6df66a3e09842ff5aff75019d52a0da14bdcf6f2 100644 (file)
@@ -146,7 +146,7 @@ static gchar
 
        GHashTable *ht_attrs;
 
-       GValue *gval;
+       gchar *gval;
 
        ZakCgiFormElementClass *klass;
 
@@ -154,7 +154,7 @@ static gchar
 
        klass = (ZakCgiFormElementClass *)g_type_class_peek_parent (ZAK_CGI_FORM_ELEMENT_SELECT_GET_CLASS (ZAK_CGI_FORM_ELEMENT_SELECT (element)));
 
-       gval = zak_cgi_form_element_get_value (element);
+       gval = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
 
        /* list options */
        options = g_string_new ("\n");
@@ -166,7 +166,7 @@ static gchar
 
                        if (gval != NULL)
                                {
-                                       if (g_strcmp0 (g_value_get_string (gval), (gchar *)key) == 0)
+                                       if (g_strcmp0 (gval, (gchar *)key) == 0)
                                                {
                                                        g_hash_table_replace (ht_options_attrs, "selected", g_strdup ("selected"));
                                                }
index 59fb663a50ed975a421c98a9fb3b2b71736116ca..05ef4e4c18fa600da1faed65a8cfb9a9d97ef905 100644 (file)
@@ -67,7 +67,7 @@ zak_cgi_form_element_string_class_init (ZakCgiFormElementStringClass *klass)
        object_class->finalize = zak_cgi_form_element_string_finalize;
 
        elem_class->render = zak_cgi_form_element_string_render;
-       elem_class->is_valid = zak_cgi_form_element_string_is_valid;
+       //elem_class->is_valid = zak_cgi_form_element_string_is_valid;
 
        g_type_class_add_private (object_class, sizeof (ZakCgiFormElementStringPrivate));
 }
index 81971120da319900c131ce92043f57263a72b914..8be61233bd5abaf403903f11fa5f8a20d994991c 100644 (file)
@@ -109,7 +109,7 @@ static gchar
 
        GHashTable *ht_attrs;
 
-       GValue *value;
+       gchar *value;
 
        ZakCgiFormElementClass *klass;
 
@@ -117,10 +117,10 @@ static gchar
 
        ht_attrs = klass->get_ht_attrs (element);
 
-       value = zak_cgi_form_element_get_value (element);
+       value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_value_get_string (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)"value", (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_text_ht (zak_cgi_form_element_get_id (element), ht_attrs);
index 22be71e2aac148e6b8ba03930d8d792c22338b1f..49e28e21421240b13ef4ea1ad62d3795be4a6cc9 100644 (file)
@@ -109,7 +109,7 @@ static gchar
 
        GHashTable *ht_attrs;
 
-       GValue *value;
+       gchar *value;
 
        ZakCgiFormElementClass *klass;
 
@@ -117,10 +117,10 @@ static gchar
 
        ht_attrs = klass->get_ht_attrs (element);
 
-       value = zak_cgi_form_element_get_value (element);
+       value = zak_form_element_get_value (ZAK_FORM_ELEMENT (element));
        if (value != NULL)
                {
-                       g_hash_table_insert (ht_attrs, (gpointer)"zak-cgi-content", (gpointer)g_value_get_string (value));
+                       g_hash_table_insert (ht_attrs, (gpointer)"zak-cgi-content", (gpointer)g_strdup (value));
                }
 
        ret = zak_cgi_tag_tag_ht ("textarea", zak_cgi_form_element_get_id (element), ht_attrs);
diff --git a/src/formelementvalidatornotempty.c b/src/formelementvalidatornotempty.c
deleted file mode 100644 (file)
index c2e1a8d..0000000
+++ /dev/null
@@ -1,173 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include "formelementivalidator.h"
-#include "formelementvalidatornotempty.h"
-
-static void zak_cgi_form_element_validator_notempty_class_init (ZakCgiFormElementValidatorNotemptyClass *class);
-static void zak_cgi_form_element_validator_notempty_interface_init (ZakCgiFormElementIValidatorInterface *iface);
-static void zak_cgi_form_element_validator_notempty_init (ZakCgiFormElementValidatorNotempty *zak_cgi_form_element);
-
-static void zak_cgi_form_element_validator_notempty_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
-static void zak_cgi_form_element_validator_notempty_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
-
-static void zak_cgi_form_element_validator_notempty_dispose (GObject *gobject);
-static void zak_cgi_form_element_validator_notempty_finalize (GObject *gobject);
-
-static gboolean zak_cgi_form_element_validator_notempty_validate (ZakCgiFormElementIValidator *validator_notempty, GValue *value);
-
-struct _ZakCgiFormElementValidatorNotempty
-{
-       GObject parent_instance;
-
-       /* Other members, including private data. */
-};
-
-#define ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CGI_TYPE_FORM_ELEMENT_VALIDATOR_NOTEMPTY, ZakCgiFormElementValidatorNotemptyPrivate))
-
-typedef struct _ZakCgiFormElementValidatorNotemptyPrivate ZakCgiFormElementValidatorNotemptyPrivate;
-struct _ZakCgiFormElementValidatorNotemptyPrivate
-       {
-               gpointer nothing;
-       };
-
-G_DEFINE_TYPE_WITH_CODE (ZakCgiFormElementValidatorNotempty, zak_cgi_form_element_validator_notempty, G_TYPE_OBJECT,
-                                                G_IMPLEMENT_INTERFACE (ZAK_CGI_TYPE_FORM_ELEMENT_IVALIDATOR,
-                                                                                               zak_cgi_form_element_validator_notempty_interface_init))
-
-static void
-zak_cgi_form_element_validator_notempty_class_init (ZakCgiFormElementValidatorNotemptyClass *class)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-       object_class->set_property = zak_cgi_form_element_validator_notempty_set_property;
-       object_class->get_property = zak_cgi_form_element_validator_notempty_get_property;
-       object_class->dispose = zak_cgi_form_element_validator_notempty_dispose;
-       object_class->finalize = zak_cgi_form_element_validator_notempty_finalize;
-
-       g_type_class_add_private (object_class, sizeof (ZakCgiFormElementValidatorNotemptyPrivate));
-}
-
-static void
-zak_cgi_form_element_validator_notempty_interface_init (ZakCgiFormElementIValidatorInterface *iface)
-{
-       iface->validate = zak_cgi_form_element_validator_notempty_validate;
-}
-
-static void
-zak_cgi_form_element_validator_notempty_init (ZakCgiFormElementValidatorNotempty *zak_cgi_form_element)
-{
-       ZakCgiFormElementValidatorNotemptyPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_cgi_form_element);
-}
-
-/**
- * zak_cgi_form_element_validator_notempty_new:
- *
- * Returns: the newly created #ZakCgiFormElementValidatorNotempty object.
- */
-ZakCgiFormElementValidatorNotempty
-*zak_cgi_form_element_validator_notempty_new ()
-{
-       ZakCgiFormElementValidatorNotempty *zak_cgi_form_element_validator_notempty;
-
-       zak_cgi_form_element_validator_notempty = ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY (g_object_new (zak_cgi_form_element_validator_notempty_get_type (), NULL));
-
-       return zak_cgi_form_element_validator_notempty;
-}
-
-/* PRIVATE */
-static void
-zak_cgi_form_element_validator_notempty_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
-{
-       ZakCgiFormElementValidatorNotempty *zak_cgi_form_element = (ZakCgiFormElementValidatorNotempty *)object;
-       ZakCgiFormElementValidatorNotemptyPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_cgi_form_element);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-zak_cgi_form_element_validator_notempty_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
-{
-       ZakCgiFormElementValidatorNotempty *zak_cgi_form_element = (ZakCgiFormElementValidatorNotempty *)object;
-       ZakCgiFormElementValidatorNotemptyPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_cgi_form_element);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-zak_cgi_form_element_validator_notempty_dispose (GObject *gobject)
-{
-       ZakCgiFormElementValidatorNotempty *zak_cgi_form_element = (ZakCgiFormElementValidatorNotempty *)gobject;
-       ZakCgiFormElementValidatorNotemptyPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_cgi_form_element);
-
-
-
-       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
-       parent_class->dispose (gobject);
-}
-
-static void
-zak_cgi_form_element_validator_notempty_finalize (GObject *gobject)
-{
-       ZakCgiFormElementValidatorNotempty *zak_cgi_form_element = (ZakCgiFormElementValidatorNotempty *)gobject;
-       ZakCgiFormElementValidatorNotemptyPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_GET_PRIVATE (zak_cgi_form_element);
-
-
-
-       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
-       parent_class->finalize (gobject);
-}
-
-static gboolean
-zak_cgi_form_element_validator_notempty_validate (ZakCgiFormElementIValidator *validator_notempty,
-                                                                                 GValue *value)
-{
-       gboolean ret;
-
-       g_return_val_if_fail (value != NULL, FALSE);
-
-       ret = (g_strcmp0 (g_value_get_string (value), "") != 0);
-
-       return ret;
-}
diff --git a/src/formelementvalidatornotempty.h b/src/formelementvalidatornotempty.h
deleted file mode 100644 (file)
index 3cda157..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_H__
-#define __ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_H__
-
-
-#include <glib-object.h>
-
-
-G_BEGIN_DECLS
-
-
-#define ZAK_CGI_TYPE_FORM_ELEMENT_VALIDATOR_NOTEMPTY zak_cgi_form_element_validator_notempty_get_type ()
-G_DECLARE_FINAL_TYPE (ZakCgiFormElementValidatorNotempty, zak_cgi_form_element_validator_notempty, ZAK_CGI, FORM_ELEMENT_VALIDATOR_NOTEMPTY, GObject)
-
-ZakCgiFormElementValidatorNotempty *zak_cgi_form_element_validator_notempty_new (void);
-
-
-G_END_DECLS
-
-
-#endif /* __ZAK_CGI_FORM_ELEMENT_VALIDATOR_NOTEMPTY_H__ */
diff --git a/src/formelementvalidatorregex.c b/src/formelementvalidatorregex.c
deleted file mode 100644 (file)
index 3ea9ba1..0000000
+++ /dev/null
@@ -1,205 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifdef HAVE_CONFIG_H
-       #include <config.h>
-#endif
-
-#include <syslog.h>
-
-#include "formelementivalidator.h"
-#include "formelementvalidatorregex.h"
-
-static void zak_cgi_form_element_validator_regex_class_init (ZakCgiFormElementValidatorRegexClass *class);
-static void zak_cgi_form_element_validator_regex_interface_init (ZakCgiFormElementIValidatorInterface *iface);
-static void zak_cgi_form_element_validator_regex_init (ZakCgiFormElementValidatorRegex *zak_cgi_form_element);
-
-static void zak_cgi_form_element_validator_regex_set_property (GObject *object,
-                               guint property_id,
-                               const GValue *value,
-                               GParamSpec *pspec);
-static void zak_cgi_form_element_validator_regex_get_property (GObject *object,
-                               guint property_id,
-                               GValue *value,
-                               GParamSpec *pspec);
-
-static void zak_cgi_form_element_validator_regex_dispose (GObject *gobject);
-static void zak_cgi_form_element_validator_regex_finalize (GObject *gobject);
-
-static gboolean zak_cgi_form_element_validator_regex_validate (ZakCgiFormElementIValidator *validator_regex, GValue *value);
-
-struct _ZakCgiFormElementValidatorRegex
-{
-       GObject parent_instance;
-
-       /* Other members, including private data. */
-};
-
-#define ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), ZAK_CGI_TYPE_FORM_ELEMENT_VALIDATOR_REGEX, ZakCgiFormElementValidatorRegexPrivate))
-
-typedef struct _ZakCgiFormElementValidatorRegexPrivate ZakCgiFormElementValidatorRegexPrivate;
-struct _ZakCgiFormElementValidatorRegexPrivate
-       {
-               gchar *regex;
-       };
-
-G_DEFINE_TYPE_WITH_CODE (ZakCgiFormElementValidatorRegex, zak_cgi_form_element_validator_regex, G_TYPE_OBJECT,
-                                                G_IMPLEMENT_INTERFACE (ZAK_CGI_TYPE_FORM_ELEMENT_IVALIDATOR,
-                                                                                               zak_cgi_form_element_validator_regex_interface_init))
-
-static void
-zak_cgi_form_element_validator_regex_class_init (ZakCgiFormElementValidatorRegexClass *class)
-{
-       GObjectClass *object_class = G_OBJECT_CLASS (class);
-
-       object_class->set_property = zak_cgi_form_element_validator_regex_set_property;
-       object_class->get_property = zak_cgi_form_element_validator_regex_get_property;
-       object_class->dispose = zak_cgi_form_element_validator_regex_dispose;
-       object_class->finalize = zak_cgi_form_element_validator_regex_finalize;
-
-       g_type_class_add_private (object_class, sizeof (ZakCgiFormElementValidatorRegexPrivate));
-}
-
-static void
-zak_cgi_form_element_validator_regex_interface_init (ZakCgiFormElementIValidatorInterface *iface)
-{
-       iface->validate = zak_cgi_form_element_validator_regex_validate;
-}
-
-static void
-zak_cgi_form_element_validator_regex_init (ZakCgiFormElementValidatorRegex *zak_cgi_form_element)
-{
-       ZakCgiFormElementValidatorRegexPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (zak_cgi_form_element);
-
-       priv->regex = NULL;
-}
-
-/**
- * zak_cgi_form_element_validator_regex_new:
- * @regex:
- *
- * Returns: the newly created #ZakCgiFormElementValidatorRegex object.
- */
-ZakCgiFormElementValidatorRegex
-*zak_cgi_form_element_validator_regex_new (const gchar *regex)
-{
-       ZakCgiFormElementValidatorRegex *zak_cgi_form_element_validator_regex;
-
-       zak_cgi_form_element_validator_regex = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX (g_object_new (zak_cgi_form_element_validator_regex_get_type (), NULL));
-
-       ZakCgiFormElementValidatorRegexPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (zak_cgi_form_element_validator_regex);
-
-       if (regex != NULL)
-               {
-                       priv->regex = g_strdup (regex);
-               }
-
-       return zak_cgi_form_element_validator_regex;
-}
-
-/* PRIVATE */
-static void
-zak_cgi_form_element_validator_regex_set_property (GObject *object,
-                   guint property_id,
-                   const GValue *value,
-                   GParamSpec *pspec)
-{
-       ZakCgiFormElementValidatorRegex *zak_cgi_form_element = (ZakCgiFormElementValidatorRegex *)object;
-       ZakCgiFormElementValidatorRegexPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (zak_cgi_form_element);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-zak_cgi_form_element_validator_regex_get_property (GObject *object,
-                   guint property_id,
-                   GValue *value,
-                   GParamSpec *pspec)
-{
-       ZakCgiFormElementValidatorRegex *zak_cgi_form_element = (ZakCgiFormElementValidatorRegex *)object;
-       ZakCgiFormElementValidatorRegexPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (zak_cgi_form_element);
-
-       switch (property_id)
-               {
-                       default:
-                               G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
-                               break;
-               }
-}
-
-static void
-zak_cgi_form_element_validator_regex_dispose (GObject *gobject)
-{
-       ZakCgiFormElementValidatorRegex *zak_cgi_form_element = (ZakCgiFormElementValidatorRegex *)gobject;
-       ZakCgiFormElementValidatorRegexPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (zak_cgi_form_element);
-
-
-
-       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
-       parent_class->dispose (gobject);
-}
-
-static void
-zak_cgi_form_element_validator_regex_finalize (GObject *gobject)
-{
-       ZakCgiFormElementValidatorRegex *zak_cgi_form_element = (ZakCgiFormElementValidatorRegex *)gobject;
-       ZakCgiFormElementValidatorRegexPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (zak_cgi_form_element);
-
-
-
-       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
-       parent_class->finalize (gobject);
-}
-
-static gboolean
-zak_cgi_form_element_validator_regex_validate (ZakCgiFormElementIValidator *validator_regex,
-                                                                                          GValue *value)
-{
-       gboolean ret;
-
-       GRegex *regex;
-       GError *error;
-
-       ZakCgiFormElementValidatorRegexPrivate *priv = ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_GET_PRIVATE (validator_regex);
-
-       if (G_VALUE_HOLDS (value, G_TYPE_STRING))
-               {
-                       error = NULL;
-                       regex = g_regex_new (priv->regex, 0, 0, &error);
-                       if (regex == NULL
-                               || error != NULL)
-                               {
-                                       syslog (LOG_MAKEPRI(LOG_SYSLOG, LOG_DEBUG), "Error on creating regex: %s.",
-                                                       error->message != NULL ? error->message : "no details");
-                                       return FALSE;
-                               }
-
-                       ret = g_regex_match ((const GRegex *)regex, g_value_get_string (value), 0, NULL);
-               }
-       else
-               {
-                       ret = FALSE;
-               }
-
-       return ret;
-}
diff --git a/src/formelementvalidatorregex.h b/src/formelementvalidatorregex.h
deleted file mode 100644 (file)
index d93b05d..0000000
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
- * Copyright (C) 2015 Andrea Zagli <azagli@libero.it>
- *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; either
- * version 2.1 of the License, or (at your option) any later version.
- *
- * This library 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
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
- */
-
-#ifndef __ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_H__
-#define __ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_H__
-
-
-#include <glib-object.h>
-
-
-G_BEGIN_DECLS
-
-
-#define ZAK_CGI_TYPE_FORM_ELEMENT_VALIDATOR_REGEX zak_cgi_form_element_validator_regex_get_type ()
-G_DECLARE_FINAL_TYPE (ZakCgiFormElementValidatorRegex, zak_cgi_form_element_validator_regex, ZAK_CGI, FORM_ELEMENT_VALIDATOR_REGEX, GObject)
-
-ZakCgiFormElementValidatorRegex *zak_cgi_form_element_validator_regex_new (const gchar *regex);
-
-
-G_END_DECLS
-
-
-#endif /* __ZAK_CGI_FORM_ELEMENT_VALIDATOR_REGEX_H__ */
index 8136b0404f64b14d3d5f991d0e986824234b4d5a..8b30f4c1194e3758d66d6182615cddbe553978f6 100644 (file)
 
 #include <unistd.h>
 
+#include <libzakform/libzakform.h>
+
 #include <form.h>
 #include <formelement.h>
 #include <formelementcheck.h>
 #include <formelementhidden.h>
 #include <formelementpassword.h>
 #include <formelementselect.h>
+#include <formelementstring.h>
 #include <formelementtext.h>
 #include <formelementtextarea.h>
 #include <formelementsubmit.h>
-#include <formelementifilter.h>
-#include <formelementfiltertrim.h>
-#include <formelementivalidator.h>
-#include <formelementvalidatornotempty.h>
-#include <formelementvalidatorregex.h>
 
 int
 main (int argc, char *argv[])
@@ -66,43 +64,44 @@ main (int argc, char *argv[])
 
        element = zak_cgi_form_element_text_new ("first", NULL);
        zak_cgi_form_element_set_label (element, "The Label for first", NULL);
-       zak_cgi_form_element_add_filter (element,
-                                                                        ZAK_CGI_FORM_ELEMENT_IFILTER (zak_cgi_form_element_filter_trim_new ()));
-       zak_cgi_form_element_add_validator (element,
-                                                                               ZAK_CGI_FORM_ELEMENT_IVALIDATOR (zak_cgi_form_element_validator_regex_new ("aaa")));
-       zak_cgi_form_add_element (form, element);
+       zak_form_element_add_filter (ZAK_FORM_ELEMENT (element),
+                                                                        ZAK_FORM_ELEMENT_IFILTER (zak_form_element_filter_trim_new ()));
+       zak_form_element_add_validator (ZAK_FORM_ELEMENT (element),
+                                                                               ZAK_FORM_ELEMENT_IVALIDATOR (zak_form_element_validator_regex_new ("^aaa$")));
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
        element = zak_cgi_form_element_check_new ("chk", NULL);
        zak_cgi_form_element_set_label (element, "The checkbox", NULL);
-       zak_cgi_form_add_element (form, element);
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
-       zak_cgi_form_add_str (form, "<h1>big big big</h1>");
+       element = zak_cgi_form_element_string_new ("<h1>big big big</h1>");
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
        element = zak_cgi_form_element_password_new ("pws", NULL);
        zak_cgi_form_element_set_label (element, "The password", NULL);
-       zak_cgi_form_add_element (form, element);
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
        element = zak_cgi_form_element_text_area_new ("txtarea", NULL);
        zak_cgi_form_element_set_label (element, "The text area", NULL);
-       zak_cgi_form_add_element (form, element);
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
        element = zak_cgi_form_element_select_new ("slc", NULL);
        zak_cgi_form_element_select_add_option (ZAK_CGI_FORM_ELEMENT_SELECT (element), "1", "first", NULL);
        zak_cgi_form_element_select_add_option (ZAK_CGI_FORM_ELEMENT_SELECT (element), "2", "second", NULL);
        zak_cgi_form_element_select_add_option (ZAK_CGI_FORM_ELEMENT_SELECT (element), "3", "third", NULL);
-       zak_cgi_form_add_element (form, element);
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
        element = zak_cgi_form_element_hidden_new ("hdn", NULL);
-       zak_cgi_form_add_element (form, element);
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
        element = zak_cgi_form_element_submit_new ("submit", "zak-cgi-content", "Submit", NULL);
-       zak_cgi_form_add_element (form, element);
+       zak_form_form_add_element (ZAK_FORM_FORM (form), ZAK_FORM_ELEMENT (element));
 
        if (zak_cgi_main_is_post (zakcgimain))
                {
                        /* validating the form */
                        zak_cgi_form_bind (form);
-                       if (zak_cgi_form_is_valid (form))
+                       if (zak_form_form_is_valid (ZAK_FORM_FORM (form)))
                                {
                                        g_string_append (str, "Form is valid!!!");
                                }