From ccd53cf9913d6af335d69daea0e99e310913c463 Mon Sep 17 00:00:00 2001 From: Bloody Date: Thu, 12 Jan 2017 08:42:49 +0500 Subject: [PATCH 1/9] Add support for AMI event DeviceStateChange doc: https://wiki.asterisk.org/wiki/display/AST/Asterisk+14+ManagerEvent_DeviceStateChange example: [event] => DeviceStateChange [privilege] => call,all [device] => SIP/208 [state] => NOT_INUSE --- .../Message/Event/DeviceStateChangeEvent.php | 75 +++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 src/PAMI/Message/Event/DeviceStateChangeEvent.php diff --git a/src/PAMI/Message/Event/DeviceStateChangeEvent.php b/src/PAMI/Message/Event/DeviceStateChangeEvent.php new file mode 100644 index 000000000..1fa928ea6 --- /dev/null +++ b/src/PAMI/Message/Event/DeviceStateChangeEvent.php @@ -0,0 +1,75 @@ + + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @version SVN: $Id$ + * @link http://marcelog.github.com/PAMI/ + * + * Copyright 2011 Marcelo Gornstein + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ +namespace PAMI\Message\Event; + +/** + * Event triggered when a caller abandons the queue. + * + * PHP Version 5 + * + * @category Pami + * @package Message + * @subpackage Event + * @author Marcelo Gornstein + * @license http://marcelog.github.com/PAMI/ Apache License 2.0 + * @link http://marcelog.github.com/PAMI/ + */ +class DeviceStateChangeEvent extends EventMessage +{ + /** + * Returns key: 'Privilege'. + * + * @return string + */ + public function getPrivilege() + { + return $this->getKey('Privilege'); + } + + /** + * Returns key: 'Device'. + * + * @return string + */ + public function getDevice() + { + return $this->getKey('Device'); + } + + /** + * Returns key: 'State'. + * + * @return string + */ + public function getState() + { + return $this->getKey('State'); + } +} From d4fcea3197e0f9bd81cafd9b4bfcbc205939db8f Mon Sep 17 00:00:00 2001 From: Bloody Date: Thu, 12 Jan 2017 17:55:49 +0500 Subject: [PATCH 2/9] Extend supported fields for AMI event VarSet, with test cases --- src/PAMI/Message/Event/VarSetEvent.php | 59 ++++++++++++++++++++++++++ test/events/Test_Events.php | 8 +++- 2 files changed, 66 insertions(+), 1 deletion(-) diff --git a/src/PAMI/Message/Event/VarSetEvent.php b/src/PAMI/Message/Event/VarSetEvent.php index 4f0432092..da58e0371 100644 --- a/src/PAMI/Message/Event/VarSetEvent.php +++ b/src/PAMI/Message/Event/VarSetEvent.php @@ -94,4 +94,63 @@ public function getUniqueID() { return $this->getKey('UniqueID'); } + + /** + * Returns key: 'ChannelState'. + * + * @return string + */ + public function getChannelState() + { + return $this->getKey('ChannelState'); + } + + /** + * Returns key: 'ChannelStateDesc'. + * + * @return string + */ + public function getChannelStateDesc() + { + return $this->getKey('ChannelStateDesc'); + } + + /** + * Returns key: 'CallerIDNum'. + * + * @return string + */ + public function getCallerIDNum() + { + return $this->getKey('CallerIDNum'); + } + + /** + * Returns key: 'CallerIDName'. + * + * @return string + */ + public function getCallerIDName() + { + return $this->getKey('CallerIDName'); + } + + /** + * Returns key: 'ConnectedLineNum'. + * + * @return string + */ + public function getConnectedLineNum() + { + return $this->getKey('ConnectedLineNum'); + } + /** + * Returns key: 'ConnectedLineName'. + * + * @return string + */ + public function getConnectedLineName() + { + return $this->getKey('ConnectedLineName'); + } } diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 4a8976c74..2d1a5b101 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -682,7 +682,13 @@ public function can_report_events() 'Channel' => 'Channel', 'Variable' => 'Variable', 'Value' => 'Value', - 'UniqueID' => 'UniqueID' + 'UniqueID' => 'UniqueID', + 'ChannelState' => 'ChannelState', + 'ChannelStateDesc' => 'ChannelStateDesc', + 'CallerIDNum' => 'CallerIDNum', + 'CallerIDName' => 'CallerIDName', + 'ConnectedLineNum' => 'ConnectedLineNum', + 'ConnectedLineName' => 'ConnectedLineName' ), 'Unlink' => array( 'Privilege' => 'Privilege', From 409c03b70561349ee50929662a9b3a9049bc55fb Mon Sep 17 00:00:00 2001 From: Bloody Date: Thu, 12 Jan 2017 18:03:55 +0500 Subject: [PATCH 3/9] Added testes for AMI event DeviceStateChange --- test/events/Test_Events.php | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 2d1a5b101..c3a451814 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -82,6 +82,7 @@ public function can_report_events() 'QueueCallerLeave', 'AttendedTransfer', 'BlindTransfer', + 'DeviceStateChange', 'DialBegin', 'DialEnd', 'DTMFBegin', @@ -1085,6 +1086,10 @@ public function can_report_events() 'Context' => 'Context', 'Extension' => 'Extension', ), + 'DeviceStateChange' => array( + 'Device' => 'Device', + 'State' => 'State', + ), 'DialBegin' => array( 'Channel' => 'Channel', 'ChannelState' => 'ChannelState', From 6e915ee44fadb22c4cdff918ab47a5d354b3675e Mon Sep 17 00:00:00 2001 From: Bloody Date: Thu, 12 Jan 2017 18:18:42 +0500 Subject: [PATCH 4/9] Added test for method getPrivilege() for DeviceStateChangeEvent --- test/events/Test_Events.php | 1 + 1 file changed, 1 insertion(+) diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index c3a451814..28d4e63f3 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -1087,6 +1087,7 @@ public function can_report_events() 'Extension' => 'Extension', ), 'DeviceStateChange' => array( + 'Privilege' => 'Privilege', 'Device' => 'Device', 'State' => 'State', ), From c8da0967c8890677182fcf308af2c445c8237812 Mon Sep 17 00:00:00 2001 From: Bloody Date: Fri, 13 Jan 2017 13:11:02 +0500 Subject: [PATCH 5/9] Some tests added --- test/events/Test_Events.php | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 28d4e63f3..7f16b9079 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -80,11 +80,13 @@ public function can_report_events() 'AsyncAGIEnd', 'QueueCallerJoin', 'QueueCallerLeave', + 'QueueCallerAbandon', 'AttendedTransfer', 'BlindTransfer', 'DeviceStateChange', 'DialBegin', 'DialEnd', + 'DNDStateEvent', 'DTMFBegin', 'DTMFEnd', 'BridgeCreate', @@ -227,6 +229,11 @@ public function can_report_events() 'Device' => 'Device', 'Status' => 'Status' ), + 'DNDStateEvent' => array( + 'Privilege' => 'Privilege', + 'Status' => 'Status', + 'DAHDIChannel' => 'DAHDIChannel', + ), 'AgentConnect' => array( 'HoldTime' => 'HoldTime', 'Privilege' => 'Privilege', @@ -886,6 +893,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Command' => 'Command', 'CommandId' => 'CommandId', @@ -904,6 +912,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Env' => 'Env', ), @@ -935,6 +944,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', ), 'QueueCallerJoin' => array( @@ -949,6 +959,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Queue' => 'Queue', 'Position' => 'Position', @@ -966,6 +977,25 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', + 'Uniqueid' => 'Uniqueid', + 'Queue' => 'Queue', + 'Count' => 'Count', + 'Position' => 'Position', + ), + 'QueueCallerAbandon' => array( + 'Channel' => 'Channel', + 'ChannelState' => 'ChannelState', + 'ChannelStateDesc' => 'ChannelStateDesc', + 'CallerIDNum' => 'CallerIDNum', + 'CallerIDName' => 'CallerIDName', + 'ConnectedLineNum' => 'ConnectedLineNum', + 'ConnectedLineName' => 'ConnectedLineName', + 'AccountCode' => 'AccountCode', + 'Context' => 'Context', + 'Exten' => 'Exten', + 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Queue' => 'Queue', 'Count' => 'Count', @@ -1085,6 +1115,7 @@ public function can_report_events() 'IsExternal' => 'IsExternal', 'Context' => 'Context', 'Extension' => 'Extension', + 'Privilege' => 'Privilege', ), 'DeviceStateChange' => array( 'Privilege' => 'Privilege', @@ -1117,6 +1148,8 @@ public function can_report_events() 'DestPriority' => 'DestPriority', 'DestUniqueid' => 'DestUniqueid', 'DialString' => 'DialString', + 'DialStatus' => 'DialStatus', + 'Privilege' => 'Privilege', ), 'DialEnd' => array( 'Channel' => 'Channel', @@ -1157,6 +1190,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Digit' => 'Digit', 'Direction' => 'Direction', @@ -1173,6 +1207,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Digit' => 'Digit', 'DurationMs' => 'DurationMs', @@ -1185,6 +1220,7 @@ public function can_report_events() 'BridgeCreator' => 'BridgeCreator', 'BridgeName' => 'BridgeName', 'BridgeNumChannels' => 'BridgeNumChannels', + 'Privilege' => 'Privilege', ), 'BridgeDestroy' => array( 'BridgeUniqueid' => 'BridgeUniqueid', @@ -1193,6 +1229,7 @@ public function can_report_events() 'BridgeCreator' => 'BridgeCreator', 'BridgeName' => 'BridgeName', 'BridgeNumChannels' => 'BridgeNumChannels', + 'Privilege' => 'Privilege', ), 'BridgeEnter' => array( 'BridgeUniqueid' => 'BridgeUniqueid', @@ -1247,6 +1284,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Class' => 'Class', ), @@ -1262,6 +1300,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', ), ); From 2e26097157358518ddf3ca9722eab98efe4c000e Mon Sep 17 00:00:00 2001 From: Bloody Date: Fri, 13 Jan 2017 13:16:03 +0500 Subject: [PATCH 6/9] Improoved code style --- test/events/Test_Events.php | 396 +++++++++++++++++++++--------------- 1 file changed, 228 insertions(+), 168 deletions(-) diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 7f16b9079..29c9a52cb 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -28,6 +28,7 @@ * */ namespace PAMI\Client\Impl { + /** * This class will test some events. * @@ -54,25 +55,84 @@ public function setUp() public function can_report_events() { $eventNames = array( - 'AsyncAGI', 'AGIExec', 'VarSet', 'Unlink', 'vgsm_sms_rx', 'vgsm_net_state', - 'vgsm_me_state', 'DTMF', 'Bridge', 'VoicemailUserEntryComplete', - 'StatusComplete', 'ParkedCallsComplete', 'DBGetResponse', - 'VoicemailUserEntry', 'Transfer', 'Status', 'ShowDialPlanComplete', - 'Rename', 'RegistrationsComplete', 'RTPSenderStat', 'RTPReceiverStat', - 'RTCPSent', 'RTCPReceiverStat', 'RTCPReceived', 'QueueSummaryComplete', - 'QueueStatusComplete', 'DAHDIShowChannelsComplete', 'QueueSummary', - 'QueueParams', 'QueueMemberStatus', 'QueueMemberRemoved', - 'QueueMemberPaused', 'QueueMember', 'QueueMemberAdded', 'PeerlistComplete', - 'PeerStatus', 'PeerEntry', 'OriginateResponse', 'Newstate', 'Newexten', - 'Newchannel', 'NewCallerid', 'NewAccountCode', 'MusicOnHold', - 'MessageWaiting', 'Masquerade', 'ListDialplan', 'Leave', 'Join', - 'Hold', 'Hangup', 'ExtensionStatus', 'Dial', 'DAHDIShowChannels', - 'CoreShowChannelsComplete', 'CoreShowChannel', 'ChannelUpdate', - 'Agents', 'AgentsComplete', 'Agentlogoff', 'Agentlogin', 'AgentConnect', - 'DongleSMSStatus', 'FullyBooted', 'DongleShowDevicesComplete', 'DongleDeviceEntry', - 'DongleNewUSSDBase64', 'DongleNewUSSD', 'DongleUSSDStatus', 'DongleNewCUSD', - 'DongleStatus', 'CEL', 'JabberEvent', 'Registry', 'UserEvent', - 'ParkedCall', 'UnParkedCall', 'Link', + 'AsyncAGI', + 'AGIExec', + 'VarSet', + 'Unlink', + 'vgsm_sms_rx', + 'vgsm_net_state', + 'vgsm_me_state', + 'DTMF', + 'Bridge', + 'VoicemailUserEntryComplete', + 'StatusComplete', + 'ParkedCallsComplete', + 'DBGetResponse', + 'VoicemailUserEntry', + 'Transfer', + 'Status', + 'ShowDialPlanComplete', + 'Rename', + 'RegistrationsComplete', + 'RTPSenderStat', + 'RTPReceiverStat', + 'RTCPSent', + 'RTCPReceiverStat', + 'RTCPReceived', + 'QueueSummaryComplete', + 'QueueStatusComplete', + 'DAHDIShowChannelsComplete', + 'QueueSummary', + 'QueueParams', + 'QueueMemberStatus', + 'QueueMemberRemoved', + 'QueueMemberPaused', + 'QueueMember', + 'QueueMemberAdded', + 'PeerlistComplete', + 'PeerStatus', + 'PeerEntry', + 'OriginateResponse', + 'Newstate', + 'Newexten', + 'Newchannel', + 'NewCallerid', + 'NewAccountCode', + 'MusicOnHold', + 'MessageWaiting', + 'Masquerade', + 'ListDialplan', + 'Leave', + 'Join', + 'Hold', + 'Hangup', + 'ExtensionStatus', + 'Dial', + 'DAHDIShowChannels', + 'CoreShowChannelsComplete', + 'CoreShowChannel', + 'ChannelUpdate', + 'Agents', + 'AgentsComplete', + 'Agentlogoff', + 'Agentlogin', + 'AgentConnect', + 'DongleSMSStatus', + 'FullyBooted', + 'DongleShowDevicesComplete', + 'DongleDeviceEntry', + 'DongleNewUSSDBase64', + 'DongleNewUSSD', + 'DongleUSSDStatus', + 'DongleNewCUSD', + 'DongleStatus', + 'CEL', + 'JabberEvent', + 'Registry', + 'UserEvent', + 'ParkedCall', + 'UnParkedCall', + 'Link', 'AGIExecStart', 'AGIExecEnd', 'AsyncAGIStart', @@ -137,16 +197,16 @@ public function can_report_events() 'FullyBooted' => array(), 'DongleUSSDStatus' => array( 'Privilege' => 'Privilege', - 'Id' => 'Id', - 'Device' => 'Device', + 'Id' => 'Id', + 'Device' => 'Device', 'Status' => 'Status' ), - 'DongleNewUSSDBase64' => array( + 'DongleNewUSSDBase64' => array( 'Device' => 'Device', 'Message' => 'Message', 'Privilege' => 'Privilege' ), - 'DongleNewCUSD' => array( + 'DongleNewCUSD' => array( 'Device' => 'Device', 'Message' => 'Message', 'Privilege' => 'Privilege' @@ -216,17 +276,17 @@ public function can_report_events() 'Waiting' => 'Waiting', 'Releasing' => 'Releasing', 'Initializing' => 'Initializing' - ), - 'DongleShowDevicesComplete' => array('ListItems' => 'items'), + ), + 'DongleShowDevicesComplete' => array('ListItems' => 'items'), 'DongleSMSStatus' => array( 'Privilege' => 'Privilege', - 'Id' => 'Id', - 'Device' => 'Device', + 'Id' => 'Id', + 'Device' => 'Device', 'Status' => 'Status' ), 'DongleStatus' => array( 'Privilege' => 'Privilege', - 'Device' => 'Device', + 'Device' => 'Device', 'Status' => 'Status' ), 'DNDStateEvent' => array( @@ -271,12 +331,12 @@ public function can_report_events() 'Privilege' => 'Privilege', 'Channel' => 'Channel', 'ChannelType' => 'ChannelType', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'SIPfullcontact' => 'SIPfullcontact', 'SIPcallid' => 'SIPcallid' ), 'CoreShowChannel' => array( - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'Privilege' => 'Privilege', 'Channel' => 'Channel', 'AccountCode' => 'AccountCode', @@ -304,40 +364,40 @@ public function can_report_events() 'Privilege' => 'Privilege', 'Destination' => 'Destination', 'SubEvent' => 'SubEvent', - 'CallerIdName' => 'CallerIdName', + 'CallerIdName' => 'CallerIdName', 'CallerIdNum' => 'CallerIdNum', 'Channel' => 'Channel', - 'DialStatus' => 'DialStatus', + 'DialStatus' => 'DialStatus', 'DialString' => 'DialString', - 'UniqueID' => 'UniqueID', - 'DestUniqueID' => 'DestUniqueID', + 'UniqueID' => 'UniqueID', + 'DestUniqueID' => 'DestUniqueID', ), 'ExtensionStatus' => array( 'Privilege' => 'Privilege', 'Status' => 'Status', 'Exten' => 'Extension', 'Hint' => 'Hint', - 'Context' => 'Context', + 'Context' => 'Context', ), 'Hangup' => array( 'CallerIdName' => 'CallerIdName', 'CallerIdNum' => 'CallerIdNum', 'Channel' => 'Channel', 'Privilege' => 'Privilege', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'Cause' => 'Cause', 'cause-txt' => 'cause-txt' ), 'Hold' => array( 'Privilege' => 'Privilege', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'Status' => 'Status', 'Channel' => 'Channel', ), - 'Join' => array( + 'Join' => array( 'CallerIdName' => 'CallerIdName', 'CallerIdNum' => 'CallerIdNum', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'Position' => 'Position', 'Queue' => 'Queue', 'Channel' => 'Channel', @@ -347,11 +407,11 @@ public function can_report_events() 'Leave' => array( 'Channel' => 'Channel', 'Privilege' => 'Privilege', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'Count' => 'Count', 'Queue' => 'Queue' ), - 'ListDialplan' => array( + 'ListDialplan' => array( 'AppData' => 'AppData', 'Application' => 'Application', 'Priority' => 'Priority', @@ -368,25 +428,25 @@ public function can_report_events() 'Privilege' => 'Privilege', ), 'MessageWaiting' => array( - 'Privilege' => 'Privilege', - 'Waiting' => 'Waiting', - 'Mailbox' => 'Mailbox', + 'Privilege' => 'Privilege', + 'Waiting' => 'Waiting', + 'Mailbox' => 'Mailbox', ), 'MusicOnHold' => array( 'Channel' => 'Channel', 'Privilege' => 'Privilege', - 'UniqueID' => 'UniqueID', - 'State' => 'State', + 'UniqueID' => 'UniqueID', + 'State' => 'State', ), 'NewAccountCode' => array( 'Channel' => 'Channel', 'Privilege' => 'Privilege', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'AccountCode' => 'AccountCode', 'OldAccountCode' => 'OldAccountCode', ), 'NewCallerid' => array( - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'CallerIdName' => 'CallerIdName', 'CallerIdNum' => 'CallerIdNum', 'Channel' => 'Channel', @@ -394,7 +454,7 @@ public function can_report_events() 'CID-CallingPres' => 'CID-CallingPres' ), 'Newchannel' => array( - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'CallerIdName' => 'CallerIdName', 'CallerIdNum' => 'CallerIdNum', 'ChannelStateDesc' => 'ChannelStateDesc', @@ -405,7 +465,7 @@ public function can_report_events() 'Exten' => 'Exten', 'Privilege' => 'Privilege' ), - 'Newexten' => array( + 'Newexten' => array( 'Channel' => 'Channel', 'Privilege' => 'Privilege', 'AppData' => 'AppData', @@ -414,9 +474,9 @@ public function can_report_events() 'Extension' => 'Extension', 'Exten' => 'Exten', 'Context' => 'Context', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', ), - 'Newstate' => array( + 'Newstate' => array( 'CallerIdName' => 'CallerIdName', 'CallerIdNum' => 'CallerIdNum', 'UniqueID' => 'UniqueID', @@ -453,7 +513,7 @@ public function can_report_events() 'ObjectName' => 'ObjectName', 'ChannelType' => 'ChannelType', ), - 'PeerStatus' => array( + 'PeerStatus' => array( 'Privilege' => 'Privilege', 'ChannelType' => 'ChannelType', 'Peer' => 'Peer', @@ -470,28 +530,28 @@ public function can_report_events() 'Location' => 'Location', 'Queue' => 'Queue', 'Privilege' => 'Privilege', - 'Paused' => 1, + 'Paused' => 1, ), 'QueueMember' => array( 'Name' => 'Name', 'Location' => 'Location', 'Queue' => 'Queue', - 'Paused' => 1, + 'Paused' => 1, 'Status' => 'Status', 'CallsTaken' => 'CallsTaken', 'Penalty' => 'Penalty', - 'Membership' => 'Membership', + 'Membership' => 'Membership', ), 'QueueMemberAdded' => array( 'MemberName' => 'MemberName', 'LastCall' => 'LastCall', 'Location' => 'Location', 'Queue' => 'Queue', - 'Paused' => 1, + 'Paused' => 1, 'Status' => 'Status', 'CallsTaken' => 'CallsTaken', 'Penalty' => 'Penalty', - 'Membership' => 'Membership', + 'Membership' => 'Membership', 'Privilege' => 'Privilege' ), 'QueueMemberStatus' => array( @@ -505,9 +565,9 @@ public function can_report_events() 'Queue' => 'Queue', 'Privilege' => 'Privilege' ), - 'QueueParams' => array( + 'QueueParams' => array( 'Completed' => '4', - 'HoldTime' => '5', + 'HoldTime' => '5', 'Calls' => '6', 'Strategy' => 'Strategy', 'Max' => '6', @@ -518,7 +578,7 @@ public function can_report_events() 'Abandoned' => '3' ), 'QueueSummaryComplete' => array(), - 'QueueSummary' => array( + 'QueueSummary' => array( 'LongestHoldTime' => 'LongestHoldTime', 'HoldTime' => 'HoldTime', 'Callers' => 'Callers', @@ -527,8 +587,8 @@ public function can_report_events() 'Queue' => 'Queue', ), 'QueueStatusComplete' => array(), - 'DAHDIShowChannelsComplete' => array('items' => 'ListItems'), - 'PeerlistComplete' => array('ListItems' => 'ListItems'), + 'DAHDIShowChannelsComplete' => array('items' => 'ListItems'), + 'PeerlistComplete' => array('ListItems' => 'ListItems'), 'CoreShowChannelsComplete' => array('ListItems' => 'ListItems'), 'RTCPReceived' => array( 'DLSR' => 'DLSR', @@ -616,7 +676,7 @@ public function can_report_events() 'Extension' => 'Extension', 'Context' => 'Context', 'UniqueID' => 'UniqueID', - 'Privilege' => 'Privilege', + 'Privilege' => 'Privilege', 'Channel' => 'Channel' ), 'Transfer' => array( @@ -664,91 +724,91 @@ public function can_report_events() 'Key' => 'Key', 'Val' => 'Val' ), - 'ParkedCallsComplete' => array(), - 'StatusComplete' => array('Items' => 'Items'), + 'ParkedCallsComplete' => array(), + 'StatusComplete' => array('Items' => 'Items'), 'RegistrationsComplete' => array('ListItems' => 'ListItems'), 'DTMF' => array( - 'Privilege' => 'Privilege', - 'UniqueID' => 'UniqueID', + 'Privilege' => 'Privilege', + 'UniqueID' => 'UniqueID', 'Channel' => 'Channel', 'Direction' => 'Direction', 'End' => 'End', 'Begin' => 'Begin', 'Digit' => 'Digit' - ), + ), 'AGIExec' => array( - 'Privilege' => 'Privilege', - 'CommandId' => 'CommandId', + 'Privilege' => 'Privilege', + 'CommandId' => 'CommandId', 'SubEvent' => 'SubEvent', 'Channel' => 'Channel', 'Command' => 'Command', 'Result' => 'Result', 'ResultCode' => 'ResultCode' - ), + ), 'VarSet' => array( - 'Privilege' => 'Privilege', + 'Privilege' => 'Privilege', 'Channel' => 'Channel', 'Variable' => 'Variable', 'Value' => 'Value', - 'UniqueID' => 'UniqueID', + 'UniqueID' => 'UniqueID', 'ChannelState' => 'ChannelState', 'ChannelStateDesc' => 'ChannelStateDesc', 'CallerIDNum' => 'CallerIDNum', 'CallerIDName' => 'CallerIDName', 'ConnectedLineNum' => 'ConnectedLineNum', 'ConnectedLineName' => 'ConnectedLineName' - ), - 'Unlink' => array( - 'Privilege' => 'Privilege', - 'CallerID1' => 'CallerID1', - 'CallerID2' => 'CallerID2', - 'UniqueID1' => 'UniqueID1', - 'UniqueID2' => 'UniqueID2', - 'Channel1' => 'Channel1', - 'Channel2' => 'Channel2', - ), - 'Bridge' => array( - 'Privilege' => 'Privilege', - 'CallerID1' => 'CallerID1', - 'CallerID2' => 'CallerID2', - 'UniqueID1' => 'UniqueID1', - 'UniqueID2' => 'UniqueID2', - 'Channel1' => 'Channel1', - 'Channel2' => 'Channel2', - 'BridgeState' => 'BridgeStart', - 'BridgeType' => 'BridgeType' - ), - 'vgsm_sms_rx' => array( - 'Privilege' => 'Privilege', - 'X-SMS-Status-Report-Indication' => 'X-SMS-Status-Report-Indication', - 'X-SMS-User-Data-Header-Indicator' => 'X-SMS-User-Data-Header-Indicator', - 'X-SMS-Reply-Path' => 'X-SMS-Reply-Path', - 'X-SMS-More-Messages-To-Send' => 'X-SMS-More-Messages-To-Send', - 'X-SMS-SMCC-Number' => 'X-SMS-SMCC-Number', - 'X-SMS-SMCC-TON' => 'X-SMS-SMCC-TON', - 'X-SMS-SMCC-NP' => 'X-SMS-SMCC-NP', - 'X-SMS-Sender-Number' => 'X-SMS-Sender-Number', - 'X-SMS-Sender-TON' => 'X-SMS-Sender-TON', - 'X-SMS-Sender-NP' => 'X-SMS-Sender-NP', - 'X-SMS-Message-Type' => 'X-SMS-Message-Type', - 'Content' => 'Content', - 'Date' => 'Date', - 'Content-Transfer-Encoding' => 'ContentEncoding', - 'Content-Type' => 'ContentType', - 'MIME-Version' => 'MIME-Version', - 'Subject' => 'Subject', - 'From' => 'From', - 'Received' => 'Received' - ), - 'vgsm_net_state' => array( - 'Privilege' => 'Privilege', - 'X-vGSM-GSM-Registration' => 'X-vGSM-GSM-Registration', - ), - 'vgsm_me_state' => array( - 'Privilege' => 'Privilege', - 'X-vGSM-ME-State-Change-Reason' => 'X-vGSM-ME-State-Change-Reason', - 'X-vGSM-ME-Old-State' => 'X-vGSM-ME-Old-State', - 'X-vGSM-ME-State' => 'X-vGSM-ME-State', + ), + 'Unlink' => array( + 'Privilege' => 'Privilege', + 'CallerID1' => 'CallerID1', + 'CallerID2' => 'CallerID2', + 'UniqueID1' => 'UniqueID1', + 'UniqueID2' => 'UniqueID2', + 'Channel1' => 'Channel1', + 'Channel2' => 'Channel2', + ), + 'Bridge' => array( + 'Privilege' => 'Privilege', + 'CallerID1' => 'CallerID1', + 'CallerID2' => 'CallerID2', + 'UniqueID1' => 'UniqueID1', + 'UniqueID2' => 'UniqueID2', + 'Channel1' => 'Channel1', + 'Channel2' => 'Channel2', + 'BridgeState' => 'BridgeStart', + 'BridgeType' => 'BridgeType' + ), + 'vgsm_sms_rx' => array( + 'Privilege' => 'Privilege', + 'X-SMS-Status-Report-Indication' => 'X-SMS-Status-Report-Indication', + 'X-SMS-User-Data-Header-Indicator' => 'X-SMS-User-Data-Header-Indicator', + 'X-SMS-Reply-Path' => 'X-SMS-Reply-Path', + 'X-SMS-More-Messages-To-Send' => 'X-SMS-More-Messages-To-Send', + 'X-SMS-SMCC-Number' => 'X-SMS-SMCC-Number', + 'X-SMS-SMCC-TON' => 'X-SMS-SMCC-TON', + 'X-SMS-SMCC-NP' => 'X-SMS-SMCC-NP', + 'X-SMS-Sender-Number' => 'X-SMS-Sender-Number', + 'X-SMS-Sender-TON' => 'X-SMS-Sender-TON', + 'X-SMS-Sender-NP' => 'X-SMS-Sender-NP', + 'X-SMS-Message-Type' => 'X-SMS-Message-Type', + 'Content' => 'Content', + 'Date' => 'Date', + 'Content-Transfer-Encoding' => 'ContentEncoding', + 'Content-Type' => 'ContentType', + 'MIME-Version' => 'MIME-Version', + 'Subject' => 'Subject', + 'From' => 'From', + 'Received' => 'Received' + ), + 'vgsm_net_state' => array( + 'Privilege' => 'Privilege', + 'X-vGSM-GSM-Registration' => 'X-vGSM-GSM-Registration', + ), + 'vgsm_me_state' => array( + 'Privilege' => 'Privilege', + 'X-vGSM-ME-State-Change-Reason' => 'X-vGSM-ME-State-Change-Reason', + 'X-vGSM-ME-Old-State' => 'X-vGSM-ME-Old-State', + 'X-vGSM-ME-State' => 'X-vGSM-ME-State', ), 'CEL' => array( 'AMAFlags' => 'AMAFlags', @@ -1314,20 +1374,20 @@ public function can_report_events() 'Agents' => array( 'LoggedInChan' => 'Channel' ), - 'ExtensionStatus' => array( + 'ExtensionStatus' => array( 'Exten' => 'Extension' ), 'Hangup' => array( 'cause-txt' => 'CauseText' ), - 'ListDialplan' => array( + 'ListDialplan' => array( 'AppData' => 'ApplicationData', ), 'NewCallerid' => array( 'CID-CallingPres' => 'CallerIdPres' ), 'Newchannel' => array('Exten' => 'Extension'), - 'Newexten' => array( + 'Newexten' => array( 'AppData' => 'ApplicationData', ), 'QueueMemberStatus' => array( @@ -1336,7 +1396,7 @@ public function can_report_events() 'QueueMember' => array( 'Name' => 'MemberName' ), - 'AGIExec' => array(), + 'AGIExec' => array(), 'Transfer' => array( 'SIP-Callid' => 'SipCallID', ), @@ -1345,31 +1405,31 @@ public function can_report_events() ), 'PeerEntry' => array('ChanObjectType' => 'ChannelObjectType'), 'VarSet' => array('Variable' => 'VariableName'), - 'StatusComplete' => array('Items' => 'ListItems'), + 'StatusComplete' => array('Items' => 'ListItems'), 'DBGetResponse' => array('Key' => 'KeyName', 'Val' => 'Value'), - 'vgsm_sms_rx' => array( - 'X-SMS-Status-Report-Indication' => 'StatusReportIndication', - 'X-SMS-User-Data-Header-Indicator' => 'DataHeaderIndicator', - 'X-SMS-Reply-Path' => 'ReplyPath', - 'X-SMS-More-Messages-To-Send' => 'MoreMessagesToSend', + 'vgsm_sms_rx' => array( + 'X-SMS-Status-Report-Indication' => 'StatusReportIndication', + 'X-SMS-User-Data-Header-Indicator' => 'DataHeaderIndicator', + 'X-SMS-Reply-Path' => 'ReplyPath', + 'X-SMS-More-Messages-To-Send' => 'MoreMessagesToSend', 'X-SMS-SMCC-Number' => 'SMCCNumber', - 'X-SMS-SMCC-TON' => 'SMCCTON', - 'X-SMS-SMCC-NP' => 'SMCCNP', - 'X-SMS-Sender-Number' => 'SenderNumber', - 'X-SMS-Sender-TON' => 'SenderTON', - 'X-SMS-Sender-NP' => 'SenderNP', - 'X-SMS-Message-Type' => 'MessageType', + 'X-SMS-SMCC-TON' => 'SMCCTON', + 'X-SMS-SMCC-NP' => 'SMCCNP', + 'X-SMS-Sender-Number' => 'SenderNumber', + 'X-SMS-Sender-TON' => 'SenderTON', + 'X-SMS-Sender-NP' => 'SenderNP', + 'X-SMS-Message-Type' => 'MessageType', 'Content-Transfer-Encoding' => 'ContentEncoding', 'Content-Type' => 'ContentType', 'MIME-Version' => 'MIMEVersion' - ), - 'DAHDIShowChannelsComplete' => array('items' => 'ListItems'), - 'vgsm_net_state' => array('X-vGSM-GSM-Registration' => 'State'), - 'vgsm_me_state' => array( - 'X-vGSM-ME-State-Change-Reason' => 'Reason', - 'X-vGSM-ME-Old-State' => 'OldState', - 'X-vGSM-ME-State' => 'State', - ), + ), + 'DAHDIShowChannelsComplete' => array('items' => 'ListItems'), + 'vgsm_net_state' => array('X-vGSM-GSM-Registration' => 'State'), + 'vgsm_me_state' => array( + 'X-vGSM-ME-State-Change-Reason' => 'Reason', + 'X-vGSM-ME-Old-State' => 'OldState', + 'X-vGSM-ME-State' => 'State', + ), 'ParkedCall' => array('Exten' => 'Extension'), 'UnParkedCall' => array('Exten' => 'Extension'), 'AGIExecStart' => array( @@ -1392,32 +1452,32 @@ private function _testEvent($eventName, array $getters, array $values, array $tr $mock_stream_socket_client = true; $mock_stream_set_blocking = true; $options = array( - 'host' => '2.3.4.5', + 'host' => '2.3.4.5', 'scheme' => 'tcp://', - 'port' => 9999, - 'username' => 'asd', - 'secret' => 'asd', + 'port' => 9999, + 'username' => 'asd', + 'secret' => 'asd', 'connect_timeout' => 10, - 'read_timeout' => 10 + 'read_timeout' => 10 ); $write = array( - "action: Login\r\nactionid: 1432.123\r\nusername: asd\r\nsecret: asd\r\n" + "action: Login\r\nactionid: 1432.123\r\nusername: asd\r\nsecret: asd\r\n" ); setFgetsMock($standardAMIStart, $write); $client = new \PAMI\Client\Impl\ClientImpl($options); $client->registerEventListener(new SomeListenerClass); - $client->open(); - $message = array(); - $message[] = 'Event: ' . $eventName; - foreach ($values as $key => $value) { - $message[] = $key . ': ' . $value; - } - $message[] = ''; - setFgetsMock($message, $message); - for($i = 0; $i < count($message); $i++) { - $client->process(); - } - $event = SomeListenerClass::$event; + $client->open(); + $message = array(); + $message[] = 'Event: ' . $eventName; + foreach ($values as $key => $value) { + $message[] = $key . ': ' . $value; + } + $message[] = ''; + setFgetsMock($message, $message); + for ($i = 0; $i < count($message); $i++) { + $client->process(); + } + $event = SomeListenerClass::$event; foreach ($values as $key => $value) { if (isset($getters[$eventName][$key])) { $methodName = 'get' . $getters[$eventName][$key]; From b8f694b52bfc6ac6bd915d724b163213ffee2eb9 Mon Sep 17 00:00:00 2001 From: Bloody Date: Fri, 13 Jan 2017 13:33:30 +0500 Subject: [PATCH 7/9] Test fixes --- test/events/Test_Events.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 29c9a52cb..3d120aa27 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -1058,8 +1058,8 @@ public function can_report_events() 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Queue' => 'Queue', - 'Count' => 'Count', 'Position' => 'Position', + 'HoldTime' => 'HoldTime', ), 'AttendedTransfer' => array( 'Result' => 'Result', @@ -1223,6 +1223,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'DestChannel' => 'DestChannel', 'DestChannelState' => 'DestChannelState', @@ -1309,6 +1310,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'SwapUniqueid' => 'SwapUniqueid', ), From 236c2f1ee9ee991bbd55e5521d515880f4c0d70d Mon Sep 17 00:00:00 2001 From: Bloody Date: Fri, 13 Jan 2017 14:07:46 +0500 Subject: [PATCH 8/9] Test fixes --- test/events/Test_Events.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 3d120aa27..0bd209aa6 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -146,7 +146,7 @@ public function can_report_events() 'DeviceStateChange', 'DialBegin', 'DialEnd', - 'DNDStateEvent', + 'DNDState', 'DTMFBegin', 'DTMFEnd', 'BridgeCreate', @@ -277,7 +277,9 @@ public function can_report_events() 'Releasing' => 'Releasing', 'Initializing' => 'Initializing' ), - 'DongleShowDevicesComplete' => array('ListItems' => 'items'), + 'DongleShowDevicesComplete' => array( + 'ListItems' => 'items' + ), 'DongleSMSStatus' => array( 'Privilege' => 'Privilege', 'Id' => 'Id', @@ -289,7 +291,7 @@ public function can_report_events() 'Device' => 'Device', 'Status' => 'Status' ), - 'DNDStateEvent' => array( + 'DNDState' => array( 'Privilege' => 'Privilege', 'Status' => 'Status', 'DAHDIChannel' => 'DAHDIChannel', From 8c4dfef4aa73d8a786255bef38406d36d77c5909 Mon Sep 17 00:00:00 2001 From: Bloody Date: Fri, 13 Jan 2017 14:29:58 +0500 Subject: [PATCH 9/9] Added test for ParkedCallGiveUp, ParkedCallTimeOut, and some tests extended --- test/events/Test_Events.php | 69 +++++++++++++++++++++++++++++++++++++ 1 file changed, 69 insertions(+) diff --git a/test/events/Test_Events.php b/test/events/Test_Events.php index 0bd209aa6..dbbaf8433 100644 --- a/test/events/Test_Events.php +++ b/test/events/Test_Events.php @@ -93,6 +93,8 @@ public function can_report_events() 'PeerStatus', 'PeerEntry', 'OriginateResponse', + 'ParkedCallGiveUp', + 'ParkedCallTimeOut', 'Newstate', 'Newexten', 'Newchannel', @@ -501,6 +503,70 @@ public function can_report_events() 'Exten' => 'Exten', 'Privilege' => 'Privilege' ), + 'ParkedCallGiveUp' => array( + 'Privilege' => 'Privilege', + 'ParkeeChannel' => 'ParkeeChannel', + 'ParkeeChannelState' => 'ParkeeChannelState', + 'ParkeeChannelStateDesc' => 'ParkeeChannelStateDesc', + 'ParkeeCallerIDNum' => 'ParkeeCallerIDNum', + 'ParkeeCallerIDName' => 'ParkeeCallerIDName', + 'ParkeeConnectedLineNum' => 'ParkeeConnectedLineNum', + 'ParkeeConnectedLineName' => 'ParkeeConnectedLineName', + 'ParkeeAccountCode' => 'ParkeeAccountCode', + 'ParkeeContext' => 'ParkeeContext', + 'ParkeeExten' => 'ParkeeExten', + 'ParkeePriority' => 'ParkeePriority', + 'ParkeeUniqueid' => 'ParkeeUniqueid', + 'ParkerChannel' => 'ParkerChannel', + 'ParkerChannelState' => 'ParkerChannelState', + 'ParkerChannelStateDesc' => 'ParkerChannelStateDesc', + 'ParkerCallerIDNum' => 'ParkerCallerIDNum', + 'ParkerCallerIDName' => 'ParkerCallerIDName', + 'ParkerConnectedLineNum' => 'ParkerConnectedLineNum', + 'ParkerConnectedLineName' => 'ParkerConnectedLineName', + 'ParkerAccountCode' => 'ParkerAccountCode', + 'ParkerContext' => 'ParkerContext', + 'ParkerExten' => 'ParkerExten', + 'ParkerPriority' => 'ParkerPriority', + 'ParkerUniqueid' => 'ParkerUniqueid', + 'ParkerDialString' => 'ParkerDialString', + 'Parkinglot' => 'Parkinglot', + 'ParkingSpace' => 'ParkingSpace', + 'ParkingTimeout' => 'ParkingTimeout', + 'ParkingDuration' => 'ParkingDuration', + ), + 'ParkedCallTimeOut' => array( + 'Privilege' => 'Privilege', + 'ParkeeChannel' => 'ParkeeChannel', + 'ParkeeChannelState' => 'ParkeeChannelState', + 'ParkeeChannelStateDesc' => 'ParkeeChannelStateDesc', + 'ParkeeCallerIDNum' => 'ParkeeCallerIDNum', + 'ParkeeCallerIDName' => 'ParkeeCallerIDName', + 'ParkeeConnectedLineNum' => 'ParkeeConnectedLineNum', + 'ParkeeConnectedLineName' => 'ParkeeConnectedLineName', + 'ParkeeAccountCode' => 'ParkeeAccountCode', + 'ParkeeContext' => 'ParkeeContext', + 'ParkeeExten' => 'ParkeeExten', + 'ParkeePriority' => 'ParkeePriority', + 'ParkeeUniqueid' => 'ParkeeUniqueid', + 'ParkerChannel' => 'ParkerChannel', + 'ParkerChannelState' => 'ParkerChannelState', + 'ParkerChannelStateDesc' => 'ParkerChannelStateDesc', + 'ParkerCallerIDNum' => 'ParkerCallerIDNum', + 'ParkerCallerIDName' => 'ParkerCallerIDName', + 'ParkerConnectedLineNum' => 'ParkerConnectedLineNum', + 'ParkerConnectedLineName' => 'ParkerConnectedLineName', + 'ParkerAccountCode' => 'ParkerAccountCode', + 'ParkerContext' => 'ParkerContext', + 'ParkerExten' => 'ParkerExten', + 'ParkerPriority' => 'ParkerPriority', + 'ParkerUniqueid' => 'ParkerUniqueid', + 'ParkerDialString' => 'ParkerDialString', + 'Parkinglot' => 'Parkinglot', + 'ParkingSpace' => 'ParkingSpace', + 'ParkingTimeout' => 'ParkingTimeout', + 'ParkingDuration' => 'ParkingDuration', + ), 'PeerEntry' => array( 'RealtimeDevice' => 'RealtimeDevice', 'Status' => 'Status', @@ -939,6 +1005,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Command' => 'Command', 'CommandId' => 'CommandId', @@ -990,6 +1057,7 @@ public function can_report_events() 'Context' => 'Context', 'Exten' => 'Exten', 'Priority' => 'Priority', + 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'CommandID' => 'CommandID', 'Result' => 'Result', @@ -1060,6 +1128,7 @@ public function can_report_events() 'Privilege' => 'Privilege', 'Uniqueid' => 'Uniqueid', 'Queue' => 'Queue', + 'OriginalPosition' => 'OriginalPosition', 'Position' => 'Position', 'HoldTime' => 'HoldTime', ),