/**
* Gets data from the IMAP server stream and parses it.
*
* @return Horde_Imap_Client_Interaction_Server Server object.
*
* @throws Horde_Imap_Client_Exception
*/
protected function _getLine()
{
$server = Horde_Imap_Client_Interaction_Server::create($this->_readStream());
switch (get_class($server)) {
case 'Horde_Imap_Client_Interaction_Server_Continuation':
$this->_responseCode($server);
break;
case 'Horde_Imap_Client_Interaction_Server_Tagged':
/* Update HIGHESTMODSEQ value. */
if (!empty($this->_temp['modseqs'])) {
$this->_temp['mailbox']['highestmodseq'] = max($this->_temp['modseqs']);
}
/* Update FETCH items. */
if (!is_null($this->_temp['fetchresp'])) {
$this->_updateCache($this->_temp['fetchresp']);
}
$this->_responseCode($server);
break;
case 'Horde_Imap_Client_Interaction_Server_Untagged':
if (is_null($server->status)) {
$this->_serverResponse($server);
} else {
$this->_responseCode($server);
}
break;
}
switch ($server->status) {
case $server::BAD:
/* A tagged BAD response indicates that the tagged command caused
* the error. This information is unknown if untagged. (RFC 3501
* [7.1.3]) */
$cmd = $server instanceof Horde_Imap_Client_Interaction_Server_Tagged ? $this->_temp['lastcmd']->getCommand() : null;
throw new Horde_Imap_Client_Exception_ServerResponse(Horde_Imap_Client_Translation::t("IMAP error reported by server."), 0, $server->status, strval($server->token), $cmd);
case $server::BYE:
/* A BYE response received as part of a logout command should be
* be treated like a regular command: a client MUST process the
* entire command until logging out (RFC 3501 [3.4; 7.1.5]). */
if (empty($this->_temp['logout'])) {
$this->_temp['logout'] = true;
$this->logout();
$e = new Horde_Imap_Client_Exception(Horde_Imap_Client_Translation::t("IMAP Server closed the connection."), Horde_Imap_Client_Exception::DISCONNECT);
$e->details = strval($server);
throw $e;
}
break;
case $server::NO:
/* An untagged NO response indicates a warning; ignore and assume
* that it also included response text code that is handled
* elsewhere. Throw exception if tagged; command handlers can
* catch this if able to workaround this issue. (RFC 3501
* [7.1.2]) */
if ($server instanceof Horde_Imap_Client_Interaction_Server_Tagged) {
throw new Horde_Imap_Client_Exception_ServerResponse(Horde_Imap_Client_Translation::t("IMAP error reported by server."), 0, $server->status, strval($server->token), $this->_temp['lastcmd']->getCommand());
}
case $server::PREAUTH:
/* The user was pre-authenticated. (RFC 3501 [7.1.4]) */
$this->_temp['preauth'] = true;
break;
}
return $server;
}