Skip to content

Commit

Permalink
Use Socket_Client package
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Oct 16, 2013
1 parent d430112 commit 227e171
Show file tree
Hide file tree
Showing 11 changed files with 105 additions and 445 deletions.
2 changes: 1 addition & 1 deletion framework/Imap_Client/lib/Horde/Imap/Client/Base.php
Expand Up @@ -79,7 +79,7 @@ abstract class Horde_Imap_Client_Base implements Serializable
/**
* Connection to the IMAP server.
*
* @var Horde_Imap_Client_Base_Connection
* @var Horde\Socket\Client
*/
protected $_connection = null;

Expand Down
117 changes: 0 additions & 117 deletions framework/Imap_Client/lib/Horde/Imap/Client/Base/Connection.php

This file was deleted.

23 changes: 22 additions & 1 deletion framework/Imap_Client/lib/Horde/Imap/Client/Socket.php
Expand Up @@ -541,7 +541,28 @@ protected function _connect()
return;
}

$this->_connection = new Horde_Imap_Client_Socket_Connection_Socket($this, $this->_debug);
try {
$this->_connection = new Horde_Imap_Client_Socket_Connection_Socket(
$this->getParam('hostspec'),
$this->getParam('port'),
$this->getParam('timeout'),
$this->getParam('secure'),
array(
'debug' => $this->_debug,
'debugliteral' => $this->getParam('debug_literal')
)
);
if (!$this->_connection->secure) {
$this->setParam('secure', false);
}
} catch (Horde\Socket\Client\Exception $e) {
$e2 = new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Error connecting to mail server."),
Horde_Imap_Client_Exception::SERVER_CONNECT
);
$e2->details($e->details);
throw $e2;
}

// If we already have capability information, don't re-set with
// (possibly) limited information sent in the initial banner.
Expand Down
128 changes: 0 additions & 128 deletions framework/Imap_Client/lib/Horde/Imap/Client/Socket/Connection.php

This file was deleted.

Expand Up @@ -25,8 +25,7 @@
* @license http://www.horde.org/licenses/lgpl21 LGPL 2.1
* @package Imap_Client
*/
class Horde_Imap_Client_Socket_Connection_Pop3
extends Horde_Imap_Client_Socket_Connection
class Horde_Imap_Client_Socket_Connection_Pop3 extends Horde\Socket\Client
{
/**
* Writes data to the POP3 output stream.
Expand All @@ -44,7 +43,7 @@ public function write($data)
);
}

$this->_debug->client($data);
$this->_params['debug']->client($data);
}

/**
Expand All @@ -58,22 +57,22 @@ public function read()
{
if (feof($this->_stream)) {
$this->close();
$this->_debug->info("ERROR: Server closed the connection.");
$this->_params['debug']->info("ERROR: Server closed the connection.");
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Server closed the connection unexpectedly."),
Horde_Imap_Client_Exception::DISCONNECT
);
}

if (($read = fgets($this->_stream)) === false) {
$this->_debug->info("ERROR: read/timeout error.");
$this->_params['debug']->info("ERROR: read/timeout error.");
throw new Horde_Imap_Client_Exception(
Horde_Imap_Client_Translation::t("Error when communicating with the mail server."),
Horde_Imap_Client_Exception::SERVER_READERROR
);
}

$this->_debug->server(rtrim($read, "\r\n"));
$this->_params['debug']->server(rtrim($read, "\r\n"));

return $read;
}
Expand Down

0 comments on commit 227e171

Please sign in to comment.