[Pkg-voip-commits] r3427 - in freepbx/modules-2.2/modules/freepbx-module-zapauto: . debian share

Diego Iastrubni elcuco-guest at alioth.debian.org
Sun Apr 15 14:05:25 UTC 2007


Author: elcuco-guest
Date: 2007-04-15 14:05:25 +0000 (Sun, 15 Apr 2007)
New Revision: 3427

Modified:
   freepbx/modules-2.2/modules/freepbx-module-zapauto/debian/changelog
   freepbx/modules-2.2/modules/freepbx-module-zapauto/freepbx-module-zapauto.spec
   freepbx/modules-2.2/modules/freepbx-module-zapauto/share/fix_ast_db
   freepbx/modules-2.2/modules/freepbx-module-zapauto/share/zap2amp
Log:
attempt to support freepbx 2.1 and freepbx 2.2 with the same code.
yes, this cannot happen in debian, but this code is also used for trixbox. yes, trixbox.



Modified: freepbx/modules-2.2/modules/freepbx-module-zapauto/debian/changelog
===================================================================
--- freepbx/modules-2.2/modules/freepbx-module-zapauto/debian/changelog	2007-04-15 11:15:10 UTC (rev 3426)
+++ freepbx/modules-2.2/modules/freepbx-module-zapauto/debian/changelog	2007-04-15 14:05:25 UTC (rev 3427)
@@ -1,3 +1,9 @@
+freepbx-module-zapauto (2.2-0.6.3-1) unstable; urgency=low
+
+  * Code supports freePBX 2.1 and 2.2
+
+ -- Diego Iastrubni <diego.iastrubni at xorcom.com>  Sun, 15 Apr 2007 15:34:09 +0300
+
 freepbx-module-zapauto (2.2-0.6.2-1) unstable; urgency=low
 
   * New release

Modified: freepbx/modules-2.2/modules/freepbx-module-zapauto/freepbx-module-zapauto.spec
===================================================================
--- freepbx/modules-2.2/modules/freepbx-module-zapauto/freepbx-module-zapauto.spec	2007-04-15 11:15:10 UTC (rev 3426)
+++ freepbx/modules-2.2/modules/freepbx-module-zapauto/freepbx-module-zapauto.spec	2007-04-15 14:05:25 UTC (rev 3427)
@@ -1,6 +1,6 @@
 Summary: FreePBX module - Zaptel AutoConfiguration
 Name: freepbx-module-zapauto
-Version: 0.6.2
+Version: 0.6.3
 Release: 1
 License: GPL
 Group: Applications/System
@@ -58,6 +58,9 @@
 /var/lib/asterisk/bin/zap.template
 
 %changelog
+* Sun Apr 15 2007 Diego Iastrubni <diego.iastrubni at xorcom.com> - 0.6.3-1
+- Code supports freePBX 2.1 and 2.2
+
 * Sun Apr 1 2007 Diego Iastrubni <diego.iastrubni at xorcom.com> - 0.6.2-1
 - New release
 - Better, smarter configuration bootstrap

Modified: freepbx/modules-2.2/modules/freepbx-module-zapauto/share/fix_ast_db
===================================================================
--- freepbx/modules-2.2/modules/freepbx-module-zapauto/share/fix_ast_db	2007-04-15 11:15:10 UTC (rev 3426)
+++ freepbx/modules-2.2/modules/freepbx-module-zapauto/share/fix_ast_db	2007-04-15 14:05:25 UTC (rev 3427)
@@ -88,11 +88,11 @@
 
 $astman         = new AGI_AsteriskManager();
 if (! $res = $astman->connect("127.0.0.1", $amp_conf["AMPMGRUSER"] , $amp_conf["AMPMGRPASS"])) {
-        unset( $astman );
+	unset( $astman );
+	$astman = null;
 }
 
 require_once( 'common/db_connect.php' );
-require_once( 'common/php-asmanager.php' );
 
 core_users2astdb();
 core_devices2astdb();

Modified: freepbx/modules-2.2/modules/freepbx-module-zapauto/share/zap2amp
===================================================================
--- freepbx/modules-2.2/modules/freepbx-module-zapauto/share/zap2amp	2007-04-15 11:15:10 UTC (rev 3426)
+++ freepbx/modules-2.2/modules/freepbx-module-zapauto/share/zap2amp	2007-04-15 14:05:25 UTC (rev 3427)
@@ -1,7 +1,7 @@
 #! /usr/bin/perl -w
 
 #   Written by Diego Iastrubni <diego.iastrubni at xorcom.com>
-#   Copyright (C) 2005, Xorcom
+#   Copyright (C) 2005, 2007 Xorcom
 #  
 #   All rights reserved.
 #  
@@ -53,7 +53,10 @@
 my $termtype = '';
 my $astbanktype = '';
 
+# we detect on runtime which freepbx to support
+my $freepbx_version;
 
+
 my $debug = 0;
 
 
@@ -243,7 +246,12 @@
 	my $wait	= "";
 	my $privacyman	= "";
 
-	$sql_statement = "INSERT INTO users VALUES ( '$extension', '$password', '$name', '$voicemail', '$ringtimer', '$noanswer', '$recording', '$outboundcid', '$directdid', '$didalert', '$faxexten', '$faxemail', '$answer', '$wait', '$privacyman' )\n";
+	if ($freepbx_version eq "2.1") {
+		$sql_statement = "INSERT INTO users VALUES ( '$extension', '$password', '$name', '$voicemail', '$ringtimer', '$noanswer', '$recording', '$outboundcid', '$directdid', '$didalert' )\n";
+	}
+	elsif ($freepbx_version eq "2.2") {
+		$sql_statement = "INSERT INTO users VALUES ( '$extension', '$password', '$name', '$voicemail', '$ringtimer', '$noanswer', '$recording', '$outboundcid', '$directdid', '$didalert', '$faxexten', '$faxemail', '$answer', '$wait', '$privacyman' )\n";
+	}
 	
 	if ($debug==1) { printf( "$sql_statement\n" ); }
 	unless ($dbh->do( $sql_statement ) )
@@ -328,6 +336,51 @@
 	$dbh = DBI->connect("dbi:SQLite:dbname=$db_file","","");
 }
 
+
+# detect freepbx version, 2.1 or 2.2
+# this script supports both 2.1 and 2.2 versions
+$sql_statement = "SELECT value FROM admin WHERE variable = 'version'";
+if ($debug==1) { printf( "$sql_statement\n" ); }
+$result = $dbh->selectall_arrayref($sql_statement);
+unless ($result) 
+{
+	print_db_errors();
+	die("Could not connect to database");
+}
+
+foreach my $row ( @{ $result } ) 
+{
+	my $version = @{ $row }[0];
+	if ( $version =~ /^2\.1/ ){
+		if ($debug==1) { printf( "Using freePBX 2.1\n" ); }
+		printf( "Using freePBX 2.1\n" ); 
+		$freepbx_version = "2.1";
+	}
+	elsif ( $version =~ /^2\.2/ ){
+		if ($debug==1) { printf( "Using freePBX 2.2\n" ); }
+		printf( "Using freePBX 2.2\n" ); 
+		$freepbx_version = "2.2";
+	}
+	else{
+		die("Unsupported freePBX version : " . $version );
+	}
+}
+
+##################
+# supported version is only 2.2.X
+#
+# you are probablably wondering why this is written, specially
+# since this code is will work with 2.1
+# the reason is that fix_ast_db is harder to fix to work with both versions
+# and the best is to fail the HW detection in this phase.
+# if someone managed to make fix_ast_db to work with
+# 2.1.3, I will uncomment the next few lines
+#
+# - diego
+#if ($freepbx_version ne "2.2") {
+#	die("Unsupported freePBX version : " . $freepbx_version );
+#}
+
 # try and get the first ZAP number configured in amportal.conf
 # if none found, we still have the good old default
 if ( ! $$ampconf{"ZAP_FIRST_CHANNEL"} eq "" )




More information about the Pkg-voip-commits mailing list