From 2175343b95ff93d67663d712a419d06d694f982f Mon Sep 17 00:00:00 2001 From: osaajani Date: Sun, 12 Jan 2020 21:25:10 +0100 Subject: [PATCH] Pass from gammu to smsd --- ...{GammuAdapter.php => GammuSmsdAdapter.php} | 67 +------------------ 1 file changed, 2 insertions(+), 65 deletions(-) rename adapters/{GammuAdapter.php => GammuSmsdAdapter.php} (79%) diff --git a/adapters/GammuAdapter.php b/adapters/GammuSmsdAdapter.php similarity index 79% rename from adapters/GammuAdapter.php rename to adapters/GammuSmsdAdapter.php index 2feeec6..a46ce93 100755 --- a/adapters/GammuAdapter.php +++ b/adapters/GammuSmsdAdapter.php @@ -8,7 +8,7 @@ * * All Phone Adapters must implement this interface */ - class GammuAdapter implements AdapterInterface + class GammuSmsdAdapter implements AdapterInterface { /** * Classname of the adapter @@ -25,7 +25,7 @@ * Description of the adapter. * A short description of the service the adapter implements. */ - public static function meta_description() : string { return 'Utilisation du logiciel Gammu qui doit être installé sur le serveur et configuré. Voir https://wammu.eu.'; } + public static function meta_description() : string { return 'Utilisation du logiciel Gammu & Gammu SMSd qui doivent être installés sur le serveur et configuré. Voir https://wammu.eu.'; } /** * Description of the datas expected by the adapter to help the user. (e.g : A list of expecteds Api credentials fields, with name and value) @@ -45,12 +45,6 @@ 'description' => 'Chemin vers le fichier de configuration que Gammu devra utilisé pour se connecter au téléphone.', 'required' => true, ], - [ - 'name' => 'pin', - 'title' => 'Code PIN', - 'description' => 'Code PIN devant être utilisé pour activer la carte SIM (laisser vide pour ne pas utiliser de code PIN).', - 'required' => false, - ], ]; } @@ -105,11 +99,6 @@ */ public function send (string $destination, string $text, bool $flash = false) { - if (!$this->unlock_sim()) - { - return false; - } - $command_parts = [ 'gammu', '--config', @@ -170,10 +159,6 @@ */ public function read () : array { - if (!$this->unlock_sim()) - { - return []; - } } @@ -188,12 +173,6 @@ { return false; } - - $result = $this->exec_command($command_parts); - if ($result['return'] != 0) - { - return false; - } return true; } @@ -209,48 +188,6 @@ } - /** - * Function to unlock pin - * @return bool : False on error, true else - */ - private function unlock_sim () : bool - { - if (!$this->datas['pin']) - { - return true; - } - - $command_parts = [ - 'gammu', - '--config', - escapeshellarg($this->datas['config_file']), - 'entersecuritycode', - 'PIN', - escapeshellarg($this->datas['pin']), - ]; - - $result = $this->exec_command($command_parts); - - - //Check security status - $command_parts = [ - 'gammu', - '--config', - escapeshellarg($this->datas['config_file']), - 'getsecuritystatus', - ]; - - $result = $this->exec_command($command_parts); - - if ($result['return'] != 0) - { - return false; - } - - return $this->search_for_string($result['output'], 'nothing'); - } - - /** * Function to execute a command and transmit it to Gammu * @param array $command_parts : Commands parts to be join with a space