posaune
authorMichael Wagner <info@wagnertech.de>
Wed, 6 Apr 2016 10:26:51 +0000 (12:26 +0200)
committerMichael Wagner <info@wagnertech.de>
Wed, 6 Apr 2016 10:26:51 +0000 (12:26 +0200)
SL/mebil/ERiC.pm [new file with mode: 0644]
etc/kivitendo-mebil.control [new file with mode: 0644]
etc/kivitendo-mebil.cp [new file with mode: 0755]
etc/kivitendo-mebil.postinst [new file with mode: 0755]
etc/kivitendo.control [deleted file]
etc/kivitendo.cp [deleted file]
etc/kivitendo.postinst [deleted file]

diff --git a/SL/mebil/ERiC.pm b/SL/mebil/ERiC.pm
new file mode 100644 (file)
index 0000000..6fae2aa
--- /dev/null
@@ -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: <datatype>.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 = <FILE>;
+       if ($encod =~ /UTF-8/) {
+               open (OUT, ">:encoding(iso-8859-1)", "data.xml");
+               print OUT "<?xml version=\"1.0\" encoding=\"ISO-8859-15\"?>\n";
+               my $line;
+               while ($line = <FILE>) {
+                       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 (file)
index 0000000..b65e18f
--- /dev/null
@@ -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 <mail@wagnertech.de>
+Description: kivitendo-mebil Connector
+
diff --git a/etc/kivitendo-mebil.cp b/etc/kivitendo-mebil.cp
new file mode 100755 (executable)
index 0000000..f0935cf
--- /dev/null
@@ -0,0 +1,7 @@
+#!/bin/bash
+set -e
+
+# parameter: $1: base dir for copy (optional)
+
+mkdir -p $1/opt
+cp -a src/kivitendo-erp $1/opt
diff --git a/etc/kivitendo-mebil.postinst b/etc/kivitendo-mebil.postinst
new file mode 100755 (executable)
index 0000000..1198bfd
--- /dev/null
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# kivitendo postinst
+
+# add sysal site to apache configuration
+cd /etc/apache2/sites-available
+if ! grep "#kivitendo#" default >/dev/null
+then
+       awk '/<.Virtual/ { print ""; \
+                     print "#kivitendo#"; \
+                     print "# Configuration for kivitendo"; \
+                     print "# Kivitendo-Installattion mit FCGI"; \
+                     print "AddHandler fcgid-script .fpl"; \
+                     print "AliasMatch ^/kivitendo/[^/]+\.pl /opt/kivitendo/dispatcher.fpl"; \
+                     print "Alias /kivitendo/ /opt/kivitendo/"; \
+                     print "FcgidMaxRequestLen 10485760"; \
+
+                     print "<Directory /opt/kivitendo>"; \
+                     print "  AllowOverride All"; \
+                     print "  Options ExecCGI Includes FollowSymlinks"; \
+                     print "  Order Allow,Deny"; \
+                     print "  Allow from All"; \
+                     print "</Directory>"; \
+
+                     print "<DirectoryMatch /opt/kivitendo/users>"; \
+                     print "  Order Deny,Allow"; \
+                     print "  Deny from All"; \
+                     print "</DirectoryMatch>"; \
+                                print "#kivitendo_end#";  } \
+                              {print $0;}' default >xxx
+
+       mv xxx default
+       echo "/etc/apache2/sites-available/default changed"
+       /etc/init.d/apache2 restart
+fi
+
+# check configuration file
+if [ ! -e /opt/kivitendo/config/kivitendo.conf ]
+then
+       echo "Type admin password:"
+       read a
+       sed "s/admin123/$a/" /opt/kivitendo/config/kivitendo.conf.default >/opt/kivitendo/config/kivitendo.conf
+fi
+
+# allow write access to some directories
+chown www-data /opt/kivitendo/users /opt/kivitendo/templates
+chgrp www-data /opt/kivitendo/users /opt/kivitendo/templates
+
diff --git a/etc/kivitendo.control b/etc/kivitendo.control
deleted file mode 100644 (file)
index 997c986..0000000
+++ /dev/null
@@ -1,9 +0,0 @@
-Package: kivitendo
-Version: 3.3.0-%BUILD%
-Section: base
-Priority: optional
-Architecture: all
-Depends:
-Maintainer: WagnerTech UG <mail@wagnertech.de>
-Description: kivitendo-ERP
-
diff --git a/etc/kivitendo.cp b/etc/kivitendo.cp
deleted file mode 100755 (executable)
index f0935cf..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-#!/bin/bash
-set -e
-
-# parameter: $1: base dir for copy (optional)
-
-mkdir -p $1/opt
-cp -a src/kivitendo-erp $1/opt
diff --git a/etc/kivitendo.postinst b/etc/kivitendo.postinst
deleted file mode 100755 (executable)
index 1198bfd..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-#!/bin/sh
-
-# kivitendo postinst
-
-# add sysal site to apache configuration
-cd /etc/apache2/sites-available
-if ! grep "#kivitendo#" default >/dev/null
-then
-       awk '/<.Virtual/ { print ""; \
-                     print "#kivitendo#"; \
-                     print "# Configuration for kivitendo"; \
-                     print "# Kivitendo-Installattion mit FCGI"; \
-                     print "AddHandler fcgid-script .fpl"; \
-                     print "AliasMatch ^/kivitendo/[^/]+\.pl /opt/kivitendo/dispatcher.fpl"; \
-                     print "Alias /kivitendo/ /opt/kivitendo/"; \
-                     print "FcgidMaxRequestLen 10485760"; \
-
-                     print "<Directory /opt/kivitendo>"; \
-                     print "  AllowOverride All"; \
-                     print "  Options ExecCGI Includes FollowSymlinks"; \
-                     print "  Order Allow,Deny"; \
-                     print "  Allow from All"; \
-                     print "</Directory>"; \
-
-                     print "<DirectoryMatch /opt/kivitendo/users>"; \
-                     print "  Order Deny,Allow"; \
-                     print "  Deny from All"; \
-                     print "</DirectoryMatch>"; \
-                                print "#kivitendo_end#";  } \
-                              {print $0;}' default >xxx
-
-       mv xxx default
-       echo "/etc/apache2/sites-available/default changed"
-       /etc/init.d/apache2 restart
-fi
-
-# check configuration file
-if [ ! -e /opt/kivitendo/config/kivitendo.conf ]
-then
-       echo "Type admin password:"
-       read a
-       sed "s/admin123/$a/" /opt/kivitendo/config/kivitendo.conf.default >/opt/kivitendo/config/kivitendo.conf
-fi
-
-# allow write access to some directories
-chown www-data /opt/kivitendo/users /opt/kivitendo/templates
-chgrp www-data /opt/kivitendo/users /opt/kivitendo/templates
-