Patch to Net_Sieve and a test script
| From: | Damian Alejandro Fernandez Sosa | Date: | Fri, 02 May 2003 18:51:36 +0000 |
| Subject: | Patch to Net_Sieve and a test script | ||
| Groups: | php.pear.dev | ||
| Request: | Send a blank email to pear-dev+get-15784@lists.php.net to get a copy of this message | ||
I created a patch to SIEVE.php (Sieve_debug_path) to add debug output
to Net_Sieve and a missing disconect() method
Also, I attach test_sieve.php to add a test script to Net_Sieve package
Can anybody upload those changes to the CVS server?
I have maintainership of Net_Sieve but I don't have CVS access Yet....
--
Damian Alejandro Fernandez Sosa <damian@cnba.uba.ar>
Attachment: [application/x-php] test_sieve.php
--- /usr/lib/php/pear/Net/Sieve.php.old 2003-01-02 23:17:10.000000000 -0300 +++ Sieve.php 2003-05-02 15:49:51.000000000 -0300 @@ -97,6 +97,16 @@ */ var $_error; + + /** + * To allow class debuging + * @var boolean + */ + var $_debug = false; + + + + /** * Constructor * Sets up the object, connects to the server and logs in. stores @@ -110,7 +120,7 @@ * @param string $port Port of server * @param string $logintype Type of login to perform */ - function Net_Sieve($user, $pass, $host = 'localhost', $port = 2000, $logintype = 'PLAIN') + function Net_Sieve($user, $pass, $host = 'localhost', $port = 2000, $logintype = 'PLAIN', $debug = false) { $this->_state = NET_SIEVE_STATE_DISCONNECTED; @@ -118,6 +128,7 @@ $this->_data['pass'] = $pass; $this->_data['host'] = $host; $this->_data['port'] = $port; + $this->_debug = $debug; $this->_sock = &new Net_Socket(); if (PEAR::isError($res = $this->_connect($host, $port))) { @@ -502,6 +513,10 @@ function _sendCmd($cmd) { $this->_sock->writeLine($cmd); + if($this->_debug){ + echo "C:$cmd\n"; + } + } /** @@ -517,6 +532,10 @@ while (true) { $line = $this->_sock->readLine(); + if($this->_debug){ + echo "S:$line\n"; + } + if ('ok' == strtolower(substr($line, 0, 2))) { return rtrim($response); @@ -531,5 +550,35 @@ $response .= $line . "\r\n"; } } + + + /** + * Sets the bebug state + * + * @access public + * @return void + */ + function setDebug($debug=true) + { + $this->_debug=$debug; + } + + /** + * Disconnect from the Sieve server + * + * @access public + * @param string $scriptname The name of the script to be set as active + * @return mixed true on success, PEAR_Error on failure + */ + function disconnect() + { + return $this->_cmdLogout(); + } + + + } + + + ?> \ No newline at end of file
Attachment: [application/x-php] test_sieve.php
--- /usr/lib/php/pear/Net/Sieve.php.old 2003-01-02 23:17:10.000000000 -0300 +++ Sieve.php 2003-05-02 15:49:51.000000000 -0300 @@ -97,6 +97,16 @@ */ var $_error; + + /** + * To allow class debuging + * @var boolean + */ + var $_debug = false; + + + + /** * Constructor * Sets up the object, connects to the server and logs in. stores @@ -110,7 +120,7 @@ * @param string $port Port of server * @param string $logintype Type of login to perform */ - function Net_Sieve($user, $pass, $host = 'localhost', $port = 2000, $logintype = 'PLAIN') + function Net_Sieve($user, $pass, $host = 'localhost', $port = 2000, $logintype = 'PLAIN', $debug = false) { $this->_state = NET_SIEVE_STATE_DISCONNECTED; @@ -118,6 +128,7 @@ $this->_data['pass'] = $pass; $this->_data['host'] = $host; $this->_data['port'] = $port; + $this->_debug = $debug; $this->_sock = &new Net_Socket(); if (PEAR::isError($res = $this->_connect($host, $port))) { @@ -502,6 +513,10 @@ function _sendCmd($cmd) { $this->_sock->writeLine($cmd); + if($this->_debug){ + echo "C:$cmd\n"; + } + } /** @@ -517,6 +532,10 @@ while (true) { $line = $this->_sock->readLine(); + if($this->_debug){ + echo "S:$line\n"; + } + if ('ok' == strtolower(substr($line, 0, 2))) { return rtrim($response); @@ -531,5 +550,35 @@ $response .= $line . "\r\n"; } } + + + /** + * Sets the bebug state + * + * @access public + * @return void + */ + function setDebug($debug=true) + { + $this->_debug=$debug; + } + + /** + * Disconnect from the Sieve server + * + * @access public + * @param string $scriptname The name of the script to be set as active + * @return mixed true on success, PEAR_Error on failure + */ + function disconnect() + { + return $this->_cmdLogout(); + } + + + } + + + ?> \ No newline at end of file