From 55a2b610c7f5414345ac09e11afb9ac1120e51c7 Mon Sep 17 00:00:00 2001 From: Michael Wagner Date: Wed, 6 Apr 2016 12:26:51 +0200 Subject: [PATCH] posaune --- SL/mebil/ERiC.pm | 78 +++++++++++++++++++ etc/kivitendo-mebil.control | 9 +++ etc/{kivitendo.cp => kivitendo-mebil.cp} | 0 ...endo.postinst => kivitendo-mebil.postinst} | 0 etc/kivitendo.control | 9 --- 5 files changed, 87 insertions(+), 9 deletions(-) create mode 100644 SL/mebil/ERiC.pm create mode 100644 etc/kivitendo-mebil.control rename etc/{kivitendo.cp => kivitendo-mebil.cp} (100%) rename etc/{kivitendo.postinst => kivitendo-mebil.postinst} (100%) delete mode 100644 etc/kivitendo.control diff --git a/SL/mebil/ERiC.pm b/SL/mebil/ERiC.pm new file mode 100644 index 000000000..6fae2aa8c --- /dev/null +++ b/SL/mebil/ERiC.pm @@ -0,0 +1,78 @@ +package SL::mebil::ERiC; + +##################################################### +# Abhängigkeit: libinline-perl +# +##################################################### +use File::Copy qw(copy); +use strict; +use Inline C => Config => BUILD_NOISY => 1, MYEXTLIB => '/usr/lib/libmERiC.so'; +use Inline C => <<'C_END'; + +int validate (char*, char*); +int senddata (char*, char*, char*, char*); + +int c_validate(char* datenart, char* xml_file) { + int r = validate(datenart, xml_file); + return r; +} +int c_submit(char* datenart, char* xml_file, char* certificate_path, char* PIN) { + int r = senddata(datenart, xml_file, certificate_path, PIN); + return r; +} + +C_END + +sub new { + # parameter: 1) type of data: xmlfile must be named: .xml + # 2) xml file name + # 3) path to certificate + # 4) password + my $my_data = { + datatype => $_[1], + xml_file => $_[2], + certificate_path => $_[3], + PIN => $_[4]}; + bless $my_data; + return $my_data; +} + +sub validate { + my $self = shift; + + # open xml file for reading + open (FILE, "$self->{xml_file}") or die "cannot open $self->{xml_file}"; + + # check encoding + my $encod = ; + if ($encod =~ /UTF-8/) { + open (OUT, ">:encoding(iso-8859-1)", "data.xml"); + print OUT "\n"; + my $line; + while ($line = ) { + print OUT $line; + } + close (OUT); + close (FILE); + + } + elsif ($encod =~ /8859-15/) { + close (FILE); + copy "$self->{xml_file}", "data.xml"; + } + else { + die "unknown encoding $encod"; + } + + # call ERiC lib + return c_validate($self->{datatype}, "data.xml"); +} + +sub submit { + my $self = shift; + + # call ERiC lib + return c_submit($self->{datatype}, "data.xml", $self->{certificate_path}, $self->{PIN}); +} + +1; diff --git a/etc/kivitendo-mebil.control b/etc/kivitendo-mebil.control new file mode 100644 index 000000000..b65e18f6e --- /dev/null +++ b/etc/kivitendo-mebil.control @@ -0,0 +1,9 @@ +Package: kivitendo-mebil +Version: 0.1-%BUILD% +Section: base +Priority: optional +Architecture: all +Depends: kivitendo (= 3.3.0) +Maintainer: WagnerTech UG +Description: kivitendo-mebil Connector + diff --git a/etc/kivitendo.cp b/etc/kivitendo-mebil.cp similarity index 100% rename from etc/kivitendo.cp rename to etc/kivitendo-mebil.cp diff --git a/etc/kivitendo.postinst b/etc/kivitendo-mebil.postinst similarity index 100% rename from etc/kivitendo.postinst rename to etc/kivitendo-mebil.postinst diff --git a/etc/kivitendo.control b/etc/kivitendo.control deleted file mode 100644 index 997c9865d..000000000 --- a/etc/kivitendo.control +++ /dev/null @@ -1,9 +0,0 @@ -Package: kivitendo -Version: 3.3.0-%BUILD% -Section: base -Priority: optional -Architecture: all -Depends: -Maintainer: WagnerTech UG -Description: kivitendo-ERP - -- 2.20.1