From c1fb9370bd1666dd856e88540a145022a3dff5e3 Mon Sep 17 00:00:00 2001 From: steve-lad <72376554+steve-lad@users.noreply.github.com> Date: Sun, 7 Feb 2021 14:48:49 +0100 Subject: [PATCH] Test for chan_sccp_b version compatibility SoftKeySets fails with chan_sccp-b prior to revision number 11048. Check the version with the installer, and subsequently to ensure do not get exception. --- .../aminterface/oldinterface.class.php | 2 +- Sccp_manager.inc/srvinterface.class.php | 28 +++++++++++++------ install.php | 19 ++++++++++--- views/server.info.php | 3 ++ 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/Sccp_manager.inc/aminterface/oldinterface.class.php b/Sccp_manager.inc/aminterface/oldinterface.class.php index 1719f63..a8d8c86 100644 --- a/Sccp_manager.inc/aminterface/oldinterface.class.php +++ b/Sccp_manager.inc/aminterface/oldinterface.class.php @@ -306,7 +306,7 @@ class oldinterface $result["vCode"] = 433; } else { $result["vCode"] = 430; - } + } } } diff --git a/Sccp_manager.inc/srvinterface.class.php b/Sccp_manager.inc/srvinterface.class.php index cf8eea5..f6b3542 100644 --- a/Sccp_manager.inc/srvinterface.class.php +++ b/Sccp_manager.inc/srvinterface.class.php @@ -15,6 +15,7 @@ class srvinterface { var $error; var $_info; var $ami_mode; + var $useAmiForSoftKeys = true; public function __construct($parent_class = null) { $this->paren_class = $parent_class; @@ -206,24 +207,35 @@ class srvinterface { */ } } - public function get_compatible_sccp() { - + public function get_compatible_sccp($revNumComp=false) { + // only called with args from installer to get revision and compatibility $res = $this->getSCCPVersion(); if (empty($res)) { return 0; } switch ($res["vCode"]) { case 0: - return 0; + $retval = 0; + break; case 433: - return 433; - + $retval = 433; + break; case 432: + $retval = 430; + break; case 431: - return 431; + $retval = 431; + break; default: - return 430; + $retval = 430; } + if ($res['RevisionNum'] < 11048) { + $this->useAmiForSoftKeys = false; + } + if ($revNumComp) { + return array($retval, $this->useAmiForSoftKeys); + } + return $retval; } public function getSCCPVersion() { @@ -236,7 +248,7 @@ class srvinterface { public function sccp_list_keysets() { - if ($this->ami_mode) { + if (($this->ami_mode) && ($this->useAmiForSoftKeys)){ return $this->aminterface->sccp_list_keysets(); } else { return $this->oldinterface->sccp_list_keysets(); diff --git a/install.php b/install.php index 6c4f298..6e5c510 100644 --- a/install.php +++ b/install.php @@ -17,6 +17,7 @@ global $astman; global $version; global $srvinterface; global $mobile_hw; +global $useAmiForSoftKeys; $mobile_hw = '0'; $class = "\\FreePBX\\Modules\\Sccp_manager\\srvinterface"; @@ -375,6 +376,7 @@ $table_req = array('sccpdevice', 'sccpline'); $ss = FreePBX::create()->Sccp_manager; $astman = FreePBX::create()->astman; $sccp_compatible = 0; +$chanSCCPWarning = true; //$db_config = $db_config_v0; $db_config = ''; @@ -445,13 +447,13 @@ function CheckAsteriskVersion() function CheckChanSCCPCompatible() { + global $chanSCCPWarning; global $srvinterface, $astman; if (!$astman) { ie_freepbx('No asterisk manager connection provided!. Installation Failed'); } - $sccp_compatible = $srvinterface->get_compatible_sccp(); - outn("
  • " . _("Sccp model Compatible code : ") . $sccp_compatible . "
  • "); - return $sccp_compatible; + // calling with true returns array with compatibility and RevisionNumber + return $srvinterface->get_compatible_sccp(true); } function InstallDB_Buttons() @@ -964,7 +966,11 @@ function Setup_RealTime() CheckSCCPManagerDBTables($table_req); #CheckPermissions(); CheckAsteriskVersion(); -$sccp_compatible = CheckChanSCCPCompatible(); +$sccp_version = array(); +$sccp_version = CheckChanSCCPCompatible(); +$sccp_compatible = $sccp_version[0]; +$chanSCCPWarning = $sccp_version[1] ^= 1; +outn("
  • " . _("Sccp model Compatible code : ") . $resultReturned[0] . "
  • "); if ($sccp_compatible == 0) { // die_freepbx('Chan Sccp not Found. Install it before continuing'); outn("
    "); @@ -995,6 +1001,11 @@ if (!$sccp_db_ver) { InstallDB_createButtonConfigTrigger(); InstallDB_CreateSccpDeviceConfigView($sccp_compatible); InstallDB_updateDBVer($sccp_compatible); +dbug('chanSCCPWarning',$chanSCCPWarning); +if ($chanSCCPWarning) { + outn("
    "); + outn("Warning: Upgrade chan_sccp_b to use full ami functionality"); +} if (!$sccp_db_ver) { Setup_RealTime(); outn("
    "); diff --git a/views/server.info.php b/views/server.info.php index 3982fed..56da782 100644 --- a/views/server.info.php +++ b/views/server.info.php @@ -36,6 +36,9 @@ $info['aminterface'] = $this->aminterface->info(); $info['XML'] = $this->xmlinterface->info(); $info['sccp_class'] = $driver['sccp']; $info['Core_sccp'] = array('Version' => $core['Version'], 'about' => 'Sccp ver.' . $core['Version'] . ' r' . $core['vCode'] . ' Revision :' . $core['RevisionNum'] . ' Hash :' . $core['RevisionHash']); +if (!$this->srvinterface->useAmiForSoftKeys) { + $info['Core_sccp'] = array('Version' => $core['Version'], 'about' => 'Sccp ver.' . $core['Version'] . ' r' . $core['vCode'] . ' Revision :' . $core['RevisionNum'] . ' Hash :' . $core['RevisionHash'] . ' ----Warning: Upgrade chan_sccp to use full ami functionality'); +} $info['Asterisk'] = array('Version' => FreePBX::Config()->get('ASTVERSION'), 'about' => 'Asterisk.');