]> saetta.ns0.it Git - solipa/libsolipa/commitdiff
Aggiunto SolipaZakFormElementValidatorCodfisc.
authorAndrea Zagli <azagli@libero.it>
Sat, 22 Apr 2017 09:48:00 +0000 (11:48 +0200)
committerAndrea Zagli <azagli@libero.it>
Sat, 22 Apr 2017 09:48:00 +0000 (11:48 +0200)
src/Makefile.am
src/formelementvalidatorcodfisc.c [new file with mode: 0644]
src/formelementvalidatorcodfisc.h [new file with mode: 0644]
src/libsolipa.h

index f946cccc1fb217a17b2d96083aeab56c3e236f82..031097f533583cefbb36f722277a0308dc8921d0 100644 (file)
@@ -2,10 +2,16 @@ guidir = $(datadir)/$(PACKAGE)/gui
 
 if PLATFORM_WIN32
 WIN32_LIBS=-lwsock32 -lshell32
+libmodulesext = -0.dll
+libmodulesdir = $(bindir)
 else
 WIN32_LIBS=
+libmodulesext = .so
+libmodulesdir = $(libdir)
 endif
 
+libzakformmodulesdir = `pkg-config --variable=modulesdir libzakform`
+
 LIBS = $(SOLIPA_LIBS) \
        $(SOLIPA_WIN32_LIBS) \
        $(WIN32_LIBS) \
@@ -39,6 +45,7 @@ lib_LTLIBRARIES = libsolipa.la \
 
 libsolipa_la_SOURCES = solipa.c \
                        allegato.c \
+                       formelementvalidatorcodfisc.c \
                        log.c \
                        progresswindow.c \
                        utils.c \
@@ -50,6 +57,7 @@ libsolipa_la_LDFLAGS = -no-undefined
 libsolipa_include_HEADERS = libsolipa.h \
                             solipa.h \
                             allegato.h \
+                            formelementvalidatorcodfisc.h \
                             log.h \
                             progresswindow.h \
                             utils.h \
@@ -96,3 +104,11 @@ libsolipaooo_la_SOURCES = ooo.c
 libsolipaooo_include_HEADERS = ooo.h
 
 libsolipaooo_includedir = $(includedir)/libsolipa
+
+
+install-exec-hook:
+       cd $(libzakformmodulesdir) && \
+       ln -s -f $(libmodulesdir)/libsolipa$(libmodulesext) .
+
+uninstall-hook:
+       rm -f $(libzakformmodulesdir)/libsolipa$(libmodulesext)
diff --git a/src/formelementvalidatorcodfisc.c b/src/formelementvalidatorcodfisc.c
new file mode 100644 (file)
index 0000000..9b6e906
--- /dev/null
@@ -0,0 +1,234 @@
+/*
+ * Copyright (C) 2017 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 <libzakutils/libzakutils.h>
+
+#include "utils.h"
+#include "formelementvalidatorcodfisc.h"
+
+enum
+       {
+               PROP_0,
+               PROP_EMPTY_GOOD
+       };
+
+static void solipa_zak_form_element_validator_codfisc_class_init (SolipaZakFormElementValidatorCodfiscClass *class);
+static void solipa_zak_form_element_validator_codfisc_init (SolipaZakFormElementValidatorCodfisc *solipa_zak_form_element);
+
+static void solipa_zak_form_element_validator_codfisc_set_property (GObject *object,
+                                                                    guint property_id,
+                                                                    const GValue *value,
+                                                                    GParamSpec *pspec);
+static void solipa_zak_form_element_validator_codfisc_get_property (GObject *object,
+                                                                    guint property_id,
+                                                                    GValue *value,
+                                                                    GParamSpec *pspec);
+
+static void solipa_zak_form_element_validator_codfisc_dispose (GObject *gobject);
+static void solipa_zak_form_element_validator_codfisc_finalize (GObject *gobject);
+
+static gboolean solipa_zak_form_element_validator_codfisc_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode);
+static gboolean solipa_zak_form_element_validator_codfisc_validate (ZakFormElementValidator *validator_codfisc, const gchar *value);
+
+struct _SolipaZakFormElementValidatorCodfisc
+{
+       ZakFormElementValidator parent_instance;
+
+       /* Other members, including private data. */
+};
+
+#define SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE ((obj), SOLIPA_ZAK_FORM_TYPE_ELEMENT_VALIDATOR_CODFISC, SolipaZakFormElementValidatorCodfiscPrivate))
+
+typedef struct _SolipaZakFormElementValidatorCodfiscPrivate SolipaZakFormElementValidatorCodfiscPrivate;
+struct _SolipaZakFormElementValidatorCodfiscPrivate
+       {
+               gboolean empty_good;
+       };
+
+G_DEFINE_TYPE (SolipaZakFormElementValidatorCodfisc, solipa_zak_form_element_validator_codfisc, ZAK_FORM_TYPE_ELEMENT_VALIDATOR)
+
+static void
+solipa_zak_form_element_validator_codfisc_class_init (SolipaZakFormElementValidatorCodfiscClass *class)
+{
+       GObjectClass *object_class = G_OBJECT_CLASS (class);
+       ZakFormElementValidatorClass *parent_class = ZAK_FORM_ELEMENT_VALIDATOR_CLASS (class);
+
+       object_class->set_property = solipa_zak_form_element_validator_codfisc_set_property;
+       object_class->get_property = solipa_zak_form_element_validator_codfisc_get_property;
+       object_class->dispose = solipa_zak_form_element_validator_codfisc_dispose;
+       object_class->finalize = solipa_zak_form_element_validator_codfisc_finalize;
+
+       parent_class->xml_parsing = solipa_zak_form_element_validator_codfisc_xml_parsing;
+       parent_class->validate = solipa_zak_form_element_validator_codfisc_validate;
+
+       g_type_class_add_private (object_class, sizeof (SolipaZakFormElementValidatorCodfiscPrivate));
+
+       g_object_class_install_property (object_class, PROP_EMPTY_GOOD,
+                                        g_param_spec_boolean ("empty-good",
+                                                              "Empty good",
+                                                              "Empty good",
+                                                              FALSE,
+                                                              G_PARAM_READWRITE | G_PARAM_CONSTRUCT));
+}
+
+static void
+solipa_zak_form_element_validator_codfisc_init (SolipaZakFormElementValidatorCodfisc *solipa_zak_form_element)
+{
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (solipa_zak_form_element);
+}
+
+/**
+ * solipa_zak_form_element_validator_codfisc_new:
+ *
+ * Returns: the newly created #SolipaZakFormElementValidatorCodfisc object.
+ */
+SolipaZakFormElementValidatorCodfisc
+*solipa_zak_form_element_validator_codfisc_new ()
+{
+       SolipaZakFormElementValidatorCodfisc *solipa_zak_form_element_validator_codfisc;
+
+       solipa_zak_form_element_validator_codfisc = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC (g_object_new (solipa_zak_form_element_validator_codfisc_get_type (), NULL));
+
+       return solipa_zak_form_element_validator_codfisc;
+}
+
+/**
+ * solipa_zak_form_element_validator_codfisc_xml_parsing:
+ * @validator:
+ * @xnode:
+ *
+ */
+static gboolean
+solipa_zak_form_element_validator_codfisc_xml_parsing (ZakFormElementValidator *validator, xmlNode *xnode)
+{
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+       priv->empty_good = zak_utils_string_to_boolean ((gchar *)xmlNodeGetContent (xnode));
+
+       return TRUE;
+}
+
+/**
+ * solipa_zak_form_element_validator_codfisc_set_empty_good:
+ * @validator:
+ * @empty_good
+ *
+ */
+void
+solipa_zak_form_element_validator_codfisc_set_empty_good (SolipaZakFormElementValidatorCodfisc *validator, gboolean empty_good)
+{
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+       priv->empty_good = empty_good;
+}
+
+/**
+ * solipa_zak_form_element_validator_codfisc_get_empty_good:
+ * @validator:
+ *
+ * Returns:
+ */
+gboolean
+solipa_zak_form_element_validator_codfisc_get_empty_good (SolipaZakFormElementValidatorCodfisc *validator)
+{
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+       return priv->empty_good;
+}
+
+/* PRIVATE */
+static void
+solipa_zak_form_element_validator_codfisc_set_property (GObject *object,
+                                                        guint property_id,
+                                                        const GValue *value,
+                                                        GParamSpec *pspec)
+{
+       SolipaZakFormElementValidatorCodfisc *validator = (SolipaZakFormElementValidatorCodfisc *)object;
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+       switch (property_id)
+               {
+               case PROP_EMPTY_GOOD:
+                       solipa_zak_form_element_validator_codfisc_set_empty_good (validator, g_value_get_boolean (value));
+                       break;
+
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+               }
+}
+
+static void
+solipa_zak_form_element_validator_codfisc_get_property (GObject *object,
+                                                        guint property_id,
+                                                        GValue *value,
+                                                        GParamSpec *pspec)
+{
+       SolipaZakFormElementValidatorCodfisc *validator = (SolipaZakFormElementValidatorCodfisc *)object;
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+       switch (property_id)
+               {
+               case PROP_EMPTY_GOOD:
+                       g_value_set_boolean (value, solipa_zak_form_element_validator_codfisc_get_empty_good (validator));
+                       break;
+
+               default:
+                       G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
+                       break;
+               }
+}
+
+static void
+solipa_zak_form_element_validator_codfisc_dispose (GObject *gobject)
+{
+       SolipaZakFormElementValidatorCodfisc *validator = (SolipaZakFormElementValidatorCodfisc *)gobject;
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+
+
+       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+       parent_class->dispose (gobject);
+}
+
+static void
+solipa_zak_form_element_validator_codfisc_finalize (GObject *gobject)
+{
+       SolipaZakFormElementValidatorCodfisc *validator = (SolipaZakFormElementValidatorCodfisc *)gobject;
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+
+
+       GObjectClass *parent_class = g_type_class_peek_parent (G_OBJECT_GET_CLASS (gobject));
+       parent_class->finalize (gobject);
+}
+
+static gboolean
+solipa_zak_form_element_validator_codfisc_validate (ZakFormElementValidator *validator,
+                                                    const gchar *value)
+{
+       SolipaZakFormElementValidatorCodfiscPrivate *priv = SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_GET_PRIVATE (validator);
+
+       g_return_val_if_fail (value != NULL, FALSE);
+
+       return solipa_chk_codice_fiscale (value, priv->empty_good);
+}
diff --git a/src/formelementvalidatorcodfisc.h b/src/formelementvalidatorcodfisc.h
new file mode 100644 (file)
index 0000000..3894e63
--- /dev/null
@@ -0,0 +1,45 @@
+/*
+ * Copyright (C) 2017 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 __SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_H__
+#define __SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_H__
+
+
+#include <glib-object.h>
+
+#include <libxml/tree.h>
+
+#include <libzakform/libzakform.h>
+
+
+G_BEGIN_DECLS
+
+
+#define SOLIPA_ZAK_FORM_TYPE_ELEMENT_VALIDATOR_CODFISC solipa_zak_form_element_validator_codfisc_get_type ()
+G_DECLARE_FINAL_TYPE (SolipaZakFormElementValidatorCodfisc, solipa_zak_form_element_validator_codfisc, SOLIPA_ZAK_FORM, ELEMENT_VALIDATOR_CODFISC, ZakFormElementValidator)
+
+SolipaZakFormElementValidatorCodfisc *solipa_zak_form_element_validator_codfisc_new (void);
+
+void solipa_zak_form_element_validator_codfisc_set_empty_good (SolipaZakFormElementValidatorCodfisc *validator, gboolean empty_godd);
+gboolean solipa_zak_form_element_validator_codfisc_get_empty_good (SolipaZakFormElementValidatorCodfisc *validator);
+
+
+G_END_DECLS
+
+
+#endif /* __SOLIPA_ZAK_FORM_ELEMENT_VALIDATOR_CODFISC_H__ */
index 651d6e9a97580a4325906a8c427e1e90324ef0c8..9b941d9a52492547a6d483a131699dfa0afeb040 100644 (file)
@@ -22,6 +22,7 @@
 #include <libsolipa/solipa.h>
 #include <libsolipa/allegato.h>
 #include <libsolipa/ctpl.h>
+#include <libsolipa/formelementvalidatorcodfisc.h>
 #include <libsolipa/log.h>
 #include <libsolipa/mail.h>
 #include <libsolipa/mailui.h>