Skip to content

Commit

Permalink
[mms] Add support for LANG extension for POP3 servers (RFC 6856).
Browse files Browse the repository at this point in the history
  • Loading branch information
slusarz committed Sep 23, 2014
1 parent b8a48c1 commit ca1cf03
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
46 changes: 44 additions & 2 deletions framework/Imap_Client/lib/Horde/Imap/Client/Socket/Pop3.php
Expand Up @@ -64,6 +64,7 @@
* - RFC 3206: AUTH/SYS response codes
* - RFC 4616: AUTH=PLAIN
* - RFC 5034: POP3 SASL
* - RFC 6856: LANG
* </pre>
*
* @author Richard Heyes <richard@phpguru.org>
Expand Down Expand Up @@ -453,15 +454,56 @@ protected function _getID()
*/
protected function _setLanguage($langs)
{
throw new Horde_Imap_Client_Exception_NoSupportPop3('LANGUAGE extension');
// RFC 6856 [3]
if (!$this->_capability('LANG')) {
throw new Horde_Imap_Client_Exception_NoSupportPop3('LANGUAGE extension');
}

foreach ($langs as $val) {
try {
$this->_sendLine('LANG ' . $val);
$this->_temp['lang'] = $val;
} catch (Horde_Imap_Client_Exception $e) {
// Setting language failed - move on to next one.
}
}

return $this->_getLanguage(false);
}

/**
* @throws Horde_Imap_Client_Exception_NoSupportPop3
*/
protected function _getLanguage($list)
{
throw new Horde_Imap_Client_Exception_NoSupportPop3('LANGUAGE extension');
// RFC 6856 [3]
if (!$this->_capability('LANG')) {
throw new Horde_Imap_Client_Exception_NoSupportPop3('LANGUAGE extension');
}

if (!$list) {
return isset($this->_temp['lang'])
? $this->_temp['lang']
: null;
}

$langs = array();

try {
$res = $this->_sendLine('LANG', array(
'multiline' => 'array'
));

foreach ($res['data'] as $val) {
$parts = explode(' ', $val);
$langs[] = $parts[0];
// $parts[1] - lanuage description (not used)
}
} catch (Horde_Imap_Client_Exception $e) {
// Ignore: language listing might fail. RFC 6856 [3.3]
}

return $langs;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions framework/Imap_Client/package.xml
Expand Up @@ -21,7 +21,7 @@
</stability>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Add support for LANG extension for POP3 servers (RFC 6856).
</notes>
<contents>
<dir baseinstalldir="/" name="/">
Expand Down Expand Up @@ -2716,7 +2716,7 @@
<date>2014-09-17</date>
<license uri="http://www.horde.org/licenses/lgpl21">LGPL-2.1</license>
<notes>
*
* [mms] Add support for LANG extension for POP3 servers (RFC 6856).
</notes>
</release>
</changelog>
Expand Down

0 comments on commit ca1cf03

Please sign in to comment.