[Pkg-voip-commits] r3517 - freepbx/trunk/debian/patches

Diego Iastrubni elcuco-guest at alioth.debian.org
Sun May 6 09:43:22 UTC 2007


Author: elcuco-guest
Date: 2007-05-06 09:43:21 +0000 (Sun, 06 May 2007)
New Revision: 3517

Modified:
   freepbx/trunk/debian/patches/add-sqlite3-support.dpatch
Log:
outbound routes should be working when using sqlite3 with this update to the patch


Modified: freepbx/trunk/debian/patches/add-sqlite3-support.dpatch
===================================================================
--- freepbx/trunk/debian/patches/add-sqlite3-support.dpatch	2007-05-02 21:21:43 UTC (rev 3516)
+++ freepbx/trunk/debian/patches/add-sqlite3-support.dpatch	2007-05-06 09:43:21 UTC (rev 3517)
@@ -6,8 +6,8 @@
 
 @DPATCH@
 diff -urNad upstream~/amp_conf/bin/retrieve_conf upstream/amp_conf/bin/retrieve_conf
---- upstream~/amp_conf/bin/retrieve_conf	2007-01-04 02:48:29.000000000 +0200
-+++ upstream/amp_conf/bin/retrieve_conf	2007-02-12 17:05:40.000000000 +0200
+--- upstream~/amp_conf/bin/retrieve_conf	2007-05-06 12:40:11.000000000 +0300
++++ upstream/amp_conf/bin/retrieve_conf	2007-05-06 12:40:11.000000000 +0300
 @@ -223,6 +223,18 @@
  		$db->connect( $DSN );
  		break;
@@ -28,8 +28,8 @@
  		die( "Unknown SQL engine: [$db_engine]");
  }
 diff -urNad upstream~/amp_conf/bin/retrieve_iax_conf_from_mysql.pl upstream/amp_conf/bin/retrieve_iax_conf_from_mysql.pl
---- upstream~/amp_conf/bin/retrieve_iax_conf_from_mysql.pl	2006-11-27 04:53:24.000000000 +0200
-+++ upstream/amp_conf/bin/retrieve_iax_conf_from_mysql.pl	2007-02-12 17:05:40.000000000 +0200
+--- upstream~/amp_conf/bin/retrieve_iax_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
++++ upstream/amp_conf/bin/retrieve_iax_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
 @@ -60,6 +60,15 @@
  	my $db_file = $ampconf->{"AMPDBFILE"};
  	$dbh = DBI->connect("dbi:SQLite2:dbname=$db_file","","");
@@ -47,8 +47,8 @@
  # Load the 'register' lines into iax_registrations.conf
  
 diff -urNad upstream~/amp_conf/bin/retrieve_op_conf_from_mysql.pl upstream/amp_conf/bin/retrieve_op_conf_from_mysql.pl
---- upstream~/amp_conf/bin/retrieve_op_conf_from_mysql.pl	2007-02-12 17:05:40.000000000 +0200
-+++ upstream/amp_conf/bin/retrieve_op_conf_from_mysql.pl	2007-02-12 17:05:40.000000000 +0200
+--- upstream~/amp_conf/bin/retrieve_op_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
++++ upstream/amp_conf/bin/retrieve_op_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
 @@ -178,6 +178,15 @@
  	my $db_file = $ampconf->{"AMPDBFILE"};
  	$dbh = DBI->connect("dbi:SQLite2:dbname=$db_file","","");
@@ -63,12 +63,12 @@
 +	$dbh = DBI->connect("dbi:SQLite:dbname=$db_file","","");
 +}
  
- open( EXTEN, ">$op_conf" ) or die "Cannot create/overwrite config file: $op_conf (!$)\n";
+ open( EXTEN, ">$op_conf" ) or die "Cannot create/overwrite config file: $op_conf ($!)\n";
  print EXTEN $warning_banner;
 diff -urNad upstream~/amp_conf/bin/retrieve_queues_conf_from_mysql.pl upstream/amp_conf/bin/retrieve_queues_conf_from_mysql.pl
---- upstream~/amp_conf/bin/retrieve_queues_conf_from_mysql.pl	2006-11-27 04:53:24.000000000 +0200
-+++ upstream/amp_conf/bin/retrieve_queues_conf_from_mysql.pl	2007-02-12 17:05:40.000000000 +0200
-@@ -56,6 +56,15 @@
+--- upstream~/amp_conf/bin/retrieve_queues_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
++++ upstream/amp_conf/bin/retrieve_queues_conf_from_mysql.pl	2007-05-06 12:40:30.000000000 +0300
+@@ -56,8 +56,18 @@
  	my $db_file = $ampconf->{"AMPDBFILE"};
  	$dbh = DBI->connect("dbi:SQLite2:dbname=$db_file","","");
  }
@@ -81,12 +81,16 @@
 +	my $db_file = $ampconf->{"AMPDBFILE"};
 +	$dbh = DBI->connect("dbi:SQLite:dbname=$db_file","","");
 +}
++
++$statement = "SELECT keyword,data from $table_name where id=0 and keyword <> 'account'";
  
- $statement = "SELECT keyword,data from $table_name where id=0 and keyword <> 'account'";
+-$statement = "SELECT keyword,data from $table_name where id='-1' and keyword <> 'account'";
  my $result = $dbh->selectall_arrayref($statement);
+ unless ($result) {
+   # check for errors after every single database call
 diff -urNad upstream~/amp_conf/bin/retrieve_sip_conf_from_mysql.pl upstream/amp_conf/bin/retrieve_sip_conf_from_mysql.pl
---- upstream~/amp_conf/bin/retrieve_sip_conf_from_mysql.pl	2006-11-27 04:53:24.000000000 +0200
-+++ upstream/amp_conf/bin/retrieve_sip_conf_from_mysql.pl	2007-02-12 17:05:40.000000000 +0200
+--- upstream~/amp_conf/bin/retrieve_sip_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
++++ upstream/amp_conf/bin/retrieve_sip_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
 @@ -60,6 +60,15 @@
  	my $db_file = $ampconf->{"AMPDBFILE"};
  	$dbh = DBI->connect("dbi:SQLite2:dbname=$db_file","","");
@@ -104,8 +108,8 @@
  $statement = "SELECT keyword,data from $table_name where id=-1 and keyword <> 'account' and flags <> 1";
  my $result = $dbh->selectall_arrayref($statement);
 diff -urNad upstream~/amp_conf/bin/retrieve_zap_conf_from_mysql.pl upstream/amp_conf/bin/retrieve_zap_conf_from_mysql.pl
---- upstream~/amp_conf/bin/retrieve_zap_conf_from_mysql.pl	2006-11-27 04:53:24.000000000 +0200
-+++ upstream/amp_conf/bin/retrieve_zap_conf_from_mysql.pl	2007-02-12 17:05:40.000000000 +0200
+--- upstream~/amp_conf/bin/retrieve_zap_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
++++ upstream/amp_conf/bin/retrieve_zap_conf_from_mysql.pl	2007-05-06 12:40:11.000000000 +0300
 @@ -61,6 +61,15 @@
  	my $db_file = $ampconf->{"AMPDBFILE"};
  	$dbh = DBI->connect("dbi:SQLite2:dbname=$db_file","","");
@@ -124,7 +128,7 @@
  my $result = $dbh->selectall_arrayref($statement);
 diff -urNad upstream~/amp_conf/htdocs/admin/common/db_connect.php upstream/amp_conf/htdocs/admin/common/db_connect.php
 --- upstream~/amp_conf/htdocs/admin/common/db_connect.php	2006-06-25 13:37:15.000000000 +0300
-+++ upstream/amp_conf/htdocs/admin/common/db_connect.php	2007-02-12 17:05:40.000000000 +0200
++++ upstream/amp_conf/htdocs/admin/common/db_connect.php	2007-05-06 12:40:11.000000000 +0300
 @@ -49,6 +49,18 @@
  		$db->connect( $DSN );
  		break;
@@ -145,9 +149,9 @@
  		die( "Unknown SQL engine: [$db_engine]");
  }
 diff -urNad upstream~/amp_conf/htdocs/admin/modules/core/functions.inc.php upstream/amp_conf/htdocs/admin/modules/core/functions.inc.php
---- upstream~/amp_conf/htdocs/admin/modules/core/functions.inc.php	2007-01-03 03:33:31.000000000 +0200
-+++ upstream/amp_conf/htdocs/admin/modules/core/functions.inc.php	2007-02-12 17:07:36.000000000 +0200
-@@ -1411,7 +1411,7 @@
+--- upstream~/amp_conf/htdocs/admin/modules/core/functions.inc.php	2007-01-25 09:14:53.000000000 +0200
++++ upstream/amp_conf/htdocs/admin/modules/core/functions.inc.php	2007-05-06 12:40:11.000000000 +0300
+@@ -1417,11 +1417,11 @@
  	global $db;
  	global $amp_conf;
  	
@@ -156,16 +160,66 @@
  	{
  		// TODO: sqlite work arround - diego 
  		// need to reorder the trunks in PHP code
-@@ -1660,7 +1660,7 @@
+-		$unique_trunks = sql("SELECT * FROM globals WHERE variable LIKE 'OUT_%' ORDER BY variable","getAll"); 
++                $unique_trunks = sql("SELECT * FROM globals WHERE variable LIKE 'OUT\\_%' escape '\\' ORDER BY variable","getAll");
+ 	}
+ 	else
+ 	{
+@@ -1638,11 +1638,23 @@
+ 
+ //get outbound routes for a given trunk
+ function core_trunks_gettrunkroutes($trunknum) {
+-	$results = sql("SELECT DISTINCT SUBSTRING(context,7), priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%')ORDER BY context ","getAll");
++
++	global $amp_conf;
++
++	if ($amp_conf["AMPDBENGINE"] == "sqlite3")
++	        $results = sql("SELECT DISTINCT              context, priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%')ORDER BY context ","getAll");
++	else	
++		$results = sql("SELECT DISTINCT SUBSTRING(context,7), priority FROM extensions WHERE context LIKE 'outrt-%' AND (args LIKE 'dialout-trunk,".$trunknum.",%' OR args LIKE 'dialout-enum,".$trunknum.",%')ORDER BY context ","getAll");
+ 	
+ 	foreach ($results as $row) {
+-		$routes[$row[0]] = $row[1];
++                $t = ($amp_conf["AMPDBENGINE"] == "sqlite3") ? substr( $row[0], 7 ) : $row[0];
++                $r = $row[1];
++                $routes[ $r ] = $t;
++
++//		original code was:
++//		$routes[$row[0]] = $row[1];
+ 	}
++
+ 	// array(routename=>priority)
+ 	return isset($routes)?$routes:null;
+ }
+@@ -1666,10 +1678,16 @@
  {
  	global $amp_conf;
  	
 -	if ( $amp_conf["AMPDBENGINE"] == "sqlite")
 +	if ( ($amp_conf["AMPDBENGINE"] == "sqlite") || ($amp_conf["AMPDBENGINE"] == "sqlite3") )
  	{
- 		// TODO: sqlite work arround - diego
+-		// TODO: sqlite work arround - diego
++		// SUBSTRING is not supported under sqlite3, we need to filter
++		// this in php. I am not sure why "6" and not "7"
++		// but I don't really care -> it works :)
  		$results = sql("SELECT DISTINCT context FROM extensions WHERE context LIKE 'outrt-%' ORDER BY context ","getAll");
-@@ -1806,13 +1806,19 @@
++                foreach( $results as &$tmp )
++                {
++                    $tmp[0] = substr( $tmp[0], 6);
++                }
+ 	}
+ 	else
+ 	{
+@@ -1753,6 +1771,8 @@
+ function core_routing_setroutepriority($routepriority, $reporoutedirection, $reporoutekey)
+ {
+ 	global $db;
++	global $amp_conf;
++
+ 	$counter=-1;
+ 	foreach ($routepriority as $tresult) 
+ 	{
+@@ -1812,13 +1832,19 @@
  			die($result->getMessage(). $sql); 
   		}
  	}
@@ -188,9 +242,9 @@
  	
  }
 diff -urNad upstream~/install_amp upstream/install_amp
---- upstream~/install_amp	2007-02-12 17:05:40.000000000 +0200
-+++ upstream/install_amp	2007-02-12 17:05:40.000000000 +0200
-@@ -424,7 +424,8 @@
+--- upstream~/install_amp	2007-05-06 12:40:11.000000000 +0300
++++ upstream/install_amp	2007-05-06 12:40:11.000000000 +0300
+@@ -425,7 +425,8 @@
  				if ( (strtolower(substr($file,-4)) == ".sqlite") && ($db_engine == "sqlite") ) {
  					install_sqlupdate( $version, $file );
  				}
@@ -200,7 +254,7 @@
  					install_sqlupdate( $version, $file );
  				}
  			}
-@@ -982,6 +983,18 @@
+@@ -983,6 +984,18 @@
  		$db->connect( $DSN );
  		break;
  	




More information about the Pkg-voip-commits mailing list