Rename ImapClient::IsSupported() to ImapClient::hasCapability()

This commit is contained in:
the-djmaze 2022-12-16 11:52:56 +01:00
parent 3fdb2e7698
commit 19bc530879
13 changed files with 71 additions and 67 deletions

View file

@ -24,7 +24,7 @@ trait ACL
*/ */
public function ACLAllow(string $sFolderName, string $command) : bool public function ACLAllow(string $sFolderName, string $command) : bool
{ {
if ($this->IsSupported('ACL') || $this->CapabilityValue('RIGHTS')) { if ($this->hasCapability('ACL') || $this->CapabilityValue('RIGHTS')) {
if ('MYRIGHTS' === $command) { if ('MYRIGHTS' === $command) {
return true; return true;
} }
@ -129,7 +129,7 @@ trait ACL
public function FolderMyRights(string $sFolderName) : ?ACLResponse public function FolderMyRights(string $sFolderName) : ?ACLResponse
{ {
// if ($this->ACLAllow($sFolderName, 'MYRIGHTS')) { // if ($this->ACLAllow($sFolderName, 'MYRIGHTS')) {
// if ($this->IsSupported('ACL')) { // if ($this->hasCapability('ACL')) {
$oResponses = $this->SendRequestGetResponse('MYRIGHTS', array($this->EscapeString($sFolderName))); $oResponses = $this->SendRequestGetResponse('MYRIGHTS', array($this->EscapeString($sFolderName)));
foreach ($oResponses as $oResponse) { foreach ($oResponses as $oResponse) {
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType

View file

@ -113,23 +113,23 @@ trait Folders
FolderStatus::UIDVALIDITY FolderStatus::UIDVALIDITY
); );
// RFC 4551 // RFC 4551
if ($this->IsSupported('CONDSTORE')) { if ($this->hasCapability('CONDSTORE')) {
$aStatusItems[] = FolderStatus::HIGHESTMODSEQ; $aStatusItems[] = FolderStatus::HIGHESTMODSEQ;
} }
// RFC 7889 // RFC 7889
if ($this->IsSupported('APPENDLIMIT')) { if ($this->hasCapability('APPENDLIMIT')) {
$aStatusItems[] = FolderStatus::APPENDLIMIT; $aStatusItems[] = FolderStatus::APPENDLIMIT;
} }
// RFC 8474 // RFC 8474
if ($this->IsSupported('OBJECTID')) { if ($this->hasCapability('OBJECTID')) {
$aStatusItems[] = FolderStatus::MAILBOXID; $aStatusItems[] = FolderStatus::MAILBOXID;
/* /*
} else if ($this->IsSupported('X-DOVECOT')) { } else if ($this->hasCapability('X-DOVECOT')) {
$aStatusItems[] = 'X-GUID'; $aStatusItems[] = 'X-GUID';
*/ */
} }
/* // STATUS SIZE can take a significant amount of time, therefore not active /* // STATUS SIZE can take a significant amount of time, therefore not active
if ($this->IsSupported('IMAP4rev2')) { if ($this->hasCapability('IMAP4rev2')) {
$aStatusItems[] = FolderStatus::SIZE; $aStatusItems[] = FolderStatus::SIZE;
} }
*/ */
@ -156,7 +156,7 @@ trait Folders
* So we must unselect the folder to be able to get the APPENDLIMIT and UNSEEN. * So we must unselect the folder to be able to get the APPENDLIMIT and UNSEEN.
*/ */
/* /*
if ($this->IsSupported('ESEARCH') && !isset($oFolderInfo->UNSEEN)) { if ($this->hasCapability('ESEARCH') && !isset($oFolderInfo->UNSEEN)) {
$oFolderInfo->UNSEEN = $this->MessageSimpleESearch('UNSEEN', ['COUNT'])['COUNT']; $oFolderInfo->UNSEEN = $this->MessageSimpleESearch('UNSEEN', ['COUNT'])['COUNT'];
} }
return $oFolderInfo; return $oFolderInfo;
@ -235,7 +235,7 @@ trait Folders
public function FolderUnselect() : self public function FolderUnselect() : self
{ {
if ($this->IsSelected()) { if ($this->IsSelected()) {
if ($this->IsSupported('UNSELECT')) { if ($this->hasCapability('UNSELECT')) {
$this->SendRequestGetResponse('UNSELECT'); $this->SendRequestGetResponse('UNSELECT');
$this->oCurrentFolderInfo = null; $this->oCurrentFolderInfo = null;
} else { } else {
@ -266,7 +266,7 @@ trait Folders
$sCmd = 'EXPUNGE'; $sCmd = 'EXPUNGE';
$aArguments = array(); $aArguments = array();
if ($oUidRange && \count($oUidRange) && $oUidRange->UID && $this->IsSupported('UIDPLUS')) { if ($oUidRange && \count($oUidRange) && $oUidRange->UID && $this->hasCapability('UIDPLUS')) {
$sCmd = 'UID '.$sCmd; $sCmd = 'UID '.$sCmd;
$aArguments = array((string) $oUidRange); $aArguments = array((string) $oUidRange);
} }
@ -344,7 +344,7 @@ trait Folders
/* /*
// RFC 5162 // RFC 5162
if ($this->IsSupported('QRESYNC')) { if ($this->hasCapability('QRESYNC')) {
$this->Enable(['QRESYNC', 'CONDSTORE']); $this->Enable(['QRESYNC', 'CONDSTORE']);
- the last known UIDVALIDITY, - the last known UIDVALIDITY,
- the last known modification sequence, - the last known modification sequence,
@ -355,7 +355,7 @@ trait Folders
} }
// RFC 4551 // RFC 4551
if ($this->IsSupported('CONDSTORE')) { if ($this->hasCapability('CONDSTORE')) {
$aSelectParams[] = 'CONDSTORE'; $aSelectParams[] = 'CONDSTORE';
} }
@ -409,7 +409,7 @@ trait Folders
// IMAP4rev2 deprecated // IMAP4rev2 deprecated
$oResult->UNSEEN = null; $oResult->UNSEEN = null;
/* /*
if ($this->IsSupported('ESEARCH')) { if ($this->hasCapability('ESEARCH')) {
$oResult->UNSEEN = $this->MessageSimpleESearch('UNSEEN', ['COUNT'])['COUNT']; $oResult->UNSEEN = $this->MessageSimpleESearch('UNSEEN', ['COUNT'])['COUNT'];
} }
*/ */
@ -433,7 +433,7 @@ trait Folders
if ($bIsSubscribeList) { if ($bIsSubscribeList) {
// IMAP4rev2 deprecated // IMAP4rev2 deprecated
$sCmd = 'LSUB'; $sCmd = 'LSUB';
} else if ($this->IsSupported('LIST-EXTENDED')) { } else if ($this->hasCapability('LIST-EXTENDED')) {
// RFC 5258 // RFC 5258
$aReturnParams[] = 'SUBSCRIBED'; $aReturnParams[] = 'SUBSCRIBED';
// $aReturnParams[] = 'CHILDREN'; // $aReturnParams[] = 'CHILDREN';
@ -443,7 +443,7 @@ trait Folders
// $aParameters[0] = '()'; // $aParameters[0] = '()';
} }
// RFC 6154 // RFC 6154
if ($this->IsSupported('SPECIAL-USE')) { if ($this->hasCapability('SPECIAL-USE')) {
$aReturnParams[] = 'SPECIAL-USE'; $aReturnParams[] = 'SPECIAL-USE';
} }
} }
@ -453,7 +453,7 @@ trait Folders
// $aParameters[] = $this->EscapeString(\strlen(\trim($sListPattern)) ? $sListPattern : '*'); // $aParameters[] = $this->EscapeString(\strlen(\trim($sListPattern)) ? $sListPattern : '*');
// RFC 5819 // RFC 5819
if ($bUseListStatus && !$bIsSubscribeList && $this->IsSupported('LIST-STATUS')) if ($bUseListStatus && !$bIsSubscribeList && $this->hasCapability('LIST-STATUS'))
{ {
$aReturnParams[] = 'STATUS'; $aReturnParams[] = 'STATUS';
$aReturnParams[] = $this->FolderStatusItems(); $aReturnParams[] = $this->FolderStatusItems();
@ -473,7 +473,7 @@ trait Folders
$aReturn = array(); $aReturn = array();
// RFC 5464 // RFC 5464
$bMetadata = !$bIsSubscribeList && $this->IsSupported('METADATA'); $bMetadata = !$bIsSubscribeList && $this->hasCapability('METADATA');
$aMetadata = null; $aMetadata = null;
if ($bMetadata) { if ($bMetadata) {
// Dovecot supports fetching all METADATA at once // Dovecot supports fetching all METADATA at once

View file

@ -77,20 +77,20 @@ trait Messages
break; break;
} }
} }
if ($this->IsSupported('OBJECTID')) { if ($this->hasCapability('OBJECTID')) {
$aFetchItems[] = FetchType::EMAILID; $aFetchItems[] = FetchType::EMAILID;
$aFetchItems[] = FetchType::THREADID; $aFetchItems[] = FetchType::THREADID;
} else if ($this->IsSupported('X-GM-EXT-1')) { } else if ($this->hasCapability('X-GM-EXT-1')) {
// https://developers.google.com/gmail/imap/imap-extensions // https://developers.google.com/gmail/imap/imap-extensions
$aFetchItems[] = 'X-GM-MSGID'; $aFetchItems[] = 'X-GM-MSGID';
$aFetchItems[] = 'X-GM-THRID'; $aFetchItems[] = 'X-GM-THRID';
/* /*
} else if ($this->IsSupported('X-DOVECOT')) { } else if ($this->hasCapability('X-DOVECOT')) {
$aFetchItems[] = 'X-GUID'; $aFetchItems[] = 'X-GUID';
*/ */
} }
/* /*
if ($this->IsSupported('X-GM-EXT-1') && \in_array(FetchType::FLAGS, $aFetchItems)) { if ($this->hasCapability('X-GM-EXT-1') && \in_array(FetchType::FLAGS, $aFetchItems)) {
$aFetchItems[] = 'X-GM-LABELS'; $aFetchItems[] = 'X-GM-LABELS';
} }
*/ */
@ -147,7 +147,7 @@ trait Messages
/* /*
// RFC 3516 || RFC 6855 section-4 // RFC 3516 || RFC 6855 section-4
if ($this->IsSupported('BINARY') || $this->IsSupported('UTF8=ACCEPT')) { if ($this->hasCapability('BINARY') || $this->hasCapability('UTF8=ACCEPT')) {
$aParams[] = '~{'.$iStreamSize.'}'; $aParams[] = '~{'.$iStreamSize.'}';
} }
*/ */
@ -220,7 +220,7 @@ trait Messages
$this->writeLogException(new \InvalidArgumentException, \LOG_ERR, true); $this->writeLogException(new \InvalidArgumentException, \LOG_ERR, true);
} }
if (!$this->IsSupported('MOVE')) { if (!$this->hasCapability('MOVE')) {
$this->writeLogException( $this->writeLogException(
new \MailSo\RuntimeException('Move is not supported'), new \MailSo\RuntimeException('Move is not supported'),
\LOG_ERR, true); \LOG_ERR, true);
@ -246,7 +246,7 @@ trait Messages
*/ */
public function MessageReplaceStream(string $sFolderName, int $iUid, $rMessageStream, int $iStreamSize, array $aFlagsList = null, int $iDateTime = 0) : ?int public function MessageReplaceStream(string $sFolderName, int $iUid, $rMessageStream, int $iStreamSize, array $aFlagsList = null, int $iDateTime = 0) : ?int
{ {
if (1 > $iUid || !$this->IsSupported('REPLACE')) { if (1 > $iUid || !$this->hasCapability('REPLACE')) {
$this->FolderSelect($sFolderName); $this->FolderSelect($sFolderName);
$iNewUid = $this->MessageAppendStream($sFolderName, $rMessageStream, $iStreamSize, $aFlagsList, $iDateTime); $iNewUid = $this->MessageAppendStream($sFolderName, $rMessageStream, $iStreamSize, $aFlagsList, $iDateTime);
if ($iUid) { if ($iUid) {
@ -271,7 +271,7 @@ trait Messages
/* /*
// RFC 3516 || RFC 6855 section-4 // RFC 3516 || RFC 6855 section-4
if ($this->IsSupported('BINARY') || $this->IsSupported('UTF8=ACCEPT')) { if ($this->hasCapability('BINARY') || $this->hasCapability('UTF8=ACCEPT')) {
$aParams[] = '~{'.$iStreamSize.'}'; $aParams[] = '~{'.$iStreamSize.'}';
} }
*/ */

View file

@ -96,21 +96,21 @@ trait Metadata
public function ServerGetMetadata(array $aEntries, array $aOptions = []) : array public function ServerGetMetadata(array $aEntries, array $aOptions = []) : array
{ {
return $this->IsSupported('METADATA-SERVER') return $this->hasCapability('METADATA-SERVER')
? $this->getMetadata('', $aEntries, $aOptions) ? $this->getMetadata('', $aEntries, $aOptions)
: []; : [];
} }
public function FolderGetMetadata(string $sFolderName, array $aEntries, array $aOptions = []) : array public function FolderGetMetadata(string $sFolderName, array $aEntries, array $aOptions = []) : array
{ {
return $this->IsSupported('METADATA') return $this->hasCapability('METADATA')
? $this->getMetadata($sFolderName, $aEntries, $aOptions) ? $this->getMetadata($sFolderName, $aEntries, $aOptions)
: []; : [];
} }
public function FolderSetMetadata(string $sFolderName, array $aEntries) : void public function FolderSetMetadata(string $sFolderName, array $aEntries) : void
{ {
if ($this->IsSupported('METADATA')) { if ($this->hasCapability('METADATA')) {
if (!$aEntries) { if (!$aEntries) {
throw new \MailSo\Base\Exceptions\InvalidArgumentException("Wrong argument for SETMETADATA command"); throw new \MailSo\Base\Exceptions\InvalidArgumentException("Wrong argument for SETMETADATA command");
} }

View file

@ -47,7 +47,7 @@ trait Quota
// * QUOTA "User quota" (STORAGE 1284645 2097152)\r\n // * QUOTA "User quota" (STORAGE 1284645 2097152)\r\n
private function getQuota(bool $root, string $sFolderName) : ?array private function getQuota(bool $root, string $sFolderName) : ?array
{ {
if (!$this->IsSupported('QUOTA')) { if (!$this->hasCapability('QUOTA')) {
return null; return null;
} }
$oResponseCollection = $this->SendRequest(($root?'GETQUOTAROOT':'GETQUOTA') . " {$this->EscapeFolderName($sFolderName)}"); $oResponseCollection = $this->SendRequest(($root?'GETQUOTAROOT':'GETQUOTA') . " {$this->EscapeFolderName($sFolderName)}");

View file

@ -177,7 +177,7 @@ class Folder implements \JsonSerializable
} }
*/ */
/* /*
if ($this->ImapClient->IsSupported('ACL') || $this->ImapClient->CapabilityValue('RIGHTS')) { if ($this->ImapClient->hasCapability('ACL') || $this->ImapClient->CapabilityValue('RIGHTS')) {
// MailSo\Imap\Responses\ACL // MailSo\Imap\Responses\ACL
$rights = $this->ImapClient->FolderMyRights($this->FolderName); $rights = $this->ImapClient->FolderMyRights($this->FolderName);
} }

View file

@ -74,14 +74,14 @@ class ImapClient extends \MailSo\Net\NetClient
$this->setCapabilities($this->getResponse('*')); $this->setCapabilities($this->getResponse('*'));
if (ConnectionSecurityType::STARTTLS === $this->Settings->type if (ConnectionSecurityType::STARTTLS === $this->Settings->type
|| (ConnectionSecurityType::AUTO_DETECT === $this->Settings->type && $this->IsSupported('STARTTLS'))) { || (ConnectionSecurityType::AUTO_DETECT === $this->Settings->type && $this->hasCapability('STARTTLS'))) {
$this->StartTLS(); $this->StartTLS();
} }
} }
private function StartTLS() : void private function StartTLS() : void
{ {
if ($this->IsSupported('STARTTLS')) { if ($this->hasCapability('STARTTLS')) {
$this->SendRequestGetResponse('STARTTLS'); $this->SendRequestGetResponse('STARTTLS');
$this->EnableCrypto(); $this->EnableCrypto();
$this->aCapabilityItems = null; $this->aCapabilityItems = null;
@ -121,17 +121,17 @@ class ImapClient extends \MailSo\Net\NetClient
$type = ''; $type = '';
foreach ($oSettings->SASLMechanisms as $sasl_type) { foreach ($oSettings->SASLMechanisms as $sasl_type) {
if ($this->IsSupported("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) { if ($this->hasCapability("AUTH={$sasl_type}") && \SnappyMail\SASL::isSupported($sasl_type)) {
$type = $sasl_type; $type = $sasl_type;
break; break;
} }
} }
// RFC3501 6.2.3 // RFC3501 6.2.3
if (!$type && \in_array('LOGIN', $oSettings->SASLMechanisms) && !$this->IsSupported('LOGINDISABLED')) { if (!$type && \in_array('LOGIN', $oSettings->SASLMechanisms) && !$this->hasCapability('LOGINDISABLED')) {
$type = 'LOGIN'; $type = 'LOGIN';
} }
if (!$type) { if (!$type) {
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) { if (!$this->Encrypted() && $this->hasCapability('STARTTLS')) {
$this->StartTLS(); $this->StartTLS();
return $this->Login($oSettings); return $this->Login($oSettings);
} }
@ -170,7 +170,7 @@ class ImapClient extends \MailSo\Net\NetClient
{ {
$sAuth = $SASL->authenticate($sLogin, $sPassword); $sAuth = $SASL->authenticate($sLogin, $sPassword);
$this->oLogger && $this->oLogger->AddSecret($sAuth); $this->oLogger && $this->oLogger->AddSecret($sAuth);
if ($this->IsSupported('SASL-IR')) { if ($this->hasCapability('SASL-IR')) {
$oResponse = $this->SendRequestGetResponse('AUTHENTICATE', array($type, $sAuth)); $oResponse = $this->SendRequestGetResponse('AUTHENTICATE', array($type, $sAuth));
} else { } else {
$this->SendRequestGetResponse('AUTHENTICATE', array($type)); $this->SendRequestGetResponse('AUTHENTICATE', array($type));
@ -192,7 +192,7 @@ class ImapClient extends \MailSo\Net\NetClient
$oResponse = $this->getResponse(); $oResponse = $this->getResponse();
} }
} }
else if ($this->IsSupported('LOGINDISABLED')) else if ($this->hasCapability('LOGINDISABLED'))
{ {
$sB64 = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION); $sB64 = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
$this->sendRaw($SASL->authenticate($sLogin, $sPassword, $sB64), true); $this->sendRaw($SASL->authenticate($sLogin, $sPassword, $sB64), true);
@ -221,12 +221,12 @@ class ImapClient extends \MailSo\Net\NetClient
} }
/* /*
// TODO: RFC 9051 // TODO: RFC 9051
if ($this->IsSupported('IMAP4rev2')) { if ($this->hasCapability('IMAP4rev2')) {
$this->Enable('IMAP4rev1'); $this->Enable('IMAP4rev1');
} }
*/ */
// RFC 6855 || RFC 5738 // RFC 6855 || RFC 5738
$this->UTF8 = $this->IsSupported('UTF8=ONLY') || $this->IsSupported('UTF8=ACCEPT'); $this->UTF8 = $this->hasCapability('UTF8=ONLY') || $this->hasCapability('UTF8=ACCEPT');
if ($this->UTF8) { if ($this->UTF8) {
$this->Enable('UTF8=ACCEPT'); $this->Enable('UTF8=ACCEPT');
} }
@ -334,11 +334,15 @@ class ImapClient extends \MailSo\Net\NetClient
* @throws \MailSo\Net\Exceptions\* * @throws \MailSo\Net\Exceptions\*
* @throws \MailSo\Imap\Exceptions\* * @throws \MailSo\Imap\Exceptions\*
*/ */
public function IsSupported(string $sExtentionName) : bool public function hasCapability(string $sExtentionName) : bool
{ {
$sExtentionName = \trim($sExtentionName); $sExtentionName = \trim($sExtentionName);
return $sExtentionName && \in_array(\strtoupper($sExtentionName), $this->Capability() ?: []); return $sExtentionName && \in_array(\strtoupper($sExtentionName), $this->Capability() ?: []);
} }
public function IsSupported(string $sExtentionName) : bool
{
return $this->hasCapability($sExtentionName);
}
/** /**
* RFC 5161 * RFC 5161
@ -360,7 +364,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/ */
public function GetNamespace() : ?NamespaceResult public function GetNamespace() : ?NamespaceResult
{ {
if (!$this->IsSupported('NAMESPACE')) { if (!$this->hasCapability('NAMESPACE')) {
return null; return null;
} }
@ -637,7 +641,7 @@ class ImapClient extends \MailSo\Net\NetClient
*/ */
public function ServerID() : string public function ServerID() : string
{ {
if ($this->IsSupported('ID')) { if ($this->hasCapability('ID')) {
foreach ($this->SendRequestGetResponse('ID', [null]) as $oResponse) { foreach ($this->SendRequestGetResponse('ID', [null]) as $oResponse) {
if ('ID' === $oResponse->ResponseList[1] && \is_array($oResponse->ResponseList[2])) { if ('ID' === $oResponse->ResponseList[1] && \is_array($oResponse->ResponseList[2])) {
$c = \count($oResponse->ResponseList[2]); $c = \count($oResponse->ResponseList[2]);
@ -659,7 +663,7 @@ class ImapClient extends \MailSo\Net\NetClient
public function Compress() : bool public function Compress() : bool
{ {
try { try {
if ($this->IsSupported('COMPRESS=DEFLATE')) { if ($this->hasCapability('COMPRESS=DEFLATE')) {
$this->SendRequestGetResponse('COMPRESS', ['DEFLATE']); $this->SendRequestGetResponse('COMPRESS', ['DEFLATE']);
\stream_filter_append($this->ConnectionResource(), 'zlib.inflate'); \stream_filter_append($this->ConnectionResource(), 'zlib.inflate');
\stream_filter_append($this->ConnectionResource(), 'zlib.deflate', STREAM_FILTER_WRITE, array( \stream_filter_append($this->ConnectionResource(), 'zlib.deflate', STREAM_FILTER_WRITE, array(

View file

@ -52,7 +52,7 @@ class ESEARCH extends Request
function __construct(\MailSo\Imap\ImapClient $oImapClient) function __construct(\MailSo\Imap\ImapClient $oImapClient)
{ {
if (!$oImapClient->IsSupported('ESEARCH')) { if (!$oImapClient->hasCapability('ESEARCH')) {
$oImapClient->writeLogException( $oImapClient->writeLogException(
new \MailSo\RuntimeException('ESEARCH is not supported'), new \MailSo\RuntimeException('ESEARCH is not supported'),
\LOG_ERR, true); \LOG_ERR, true);
@ -66,7 +66,7 @@ class ESEARCH extends Request
$aRequest = array(); $aRequest = array();
/* // RFC 6203 /* // RFC 6203
if (false !== \stripos($this->sCriterias, 'FUZZY') && !$this->oImapClient->IsSupported('SEARCH=FUZZY')) { if (false !== \stripos($this->sCriterias, 'FUZZY') && !$this->oImapClient->hasCapability('SEARCH=FUZZY')) {
$this->oImapClient->writeLogException( $this->oImapClient->writeLogException(
new \MailSo\RuntimeException('SEARCH=FUZZY is not supported'), new \MailSo\RuntimeException('SEARCH=FUZZY is not supported'),
\LOG_ERR, true); \LOG_ERR, true);
@ -87,7 +87,7 @@ class ESEARCH extends Request
$aFolders[] = $this->aSubtreesOne; $aFolders[] = $this->aSubtreesOne;
} }
if ($aFolders) { if ($aFolders) {
if (!$this->oImapClient->IsSupported('MULTISEARCH')) { if (!$this->oImapClient->hasCapability('MULTISEARCH')) {
$this->oImapClient->writeLogException( $this->oImapClient->writeLogException(
new \MailSo\RuntimeException('MULTISEARCH is not supported'), new \MailSo\RuntimeException('MULTISEARCH is not supported'),
\LOG_ERR, true); \LOG_ERR, true);
@ -105,7 +105,7 @@ class ESEARCH extends Request
$aRequest[] = 'RETURN'; $aRequest[] = 'RETURN';
if ($this->aReturn) { if ($this->aReturn) {
// RFC 5267 checks // RFC 5267 checks
if (!$this->oImapClient->IsSupported('CONTEXT=SEARCH')) { if (!$this->oImapClient->hasCapability('CONTEXT=SEARCH')) {
foreach ($this->aReturn as $sReturn) { foreach ($this->aReturn as $sReturn) {
if (\preg_match('/PARTIAL|UPDATE|CONTEXT/i', $sReturn)) { if (\preg_match('/PARTIAL|UPDATE|CONTEXT/i', $sReturn)) {
$this->oImapClient->writeLogException( $this->oImapClient->writeLogException(

View file

@ -53,7 +53,7 @@ class SORT extends Request
function __construct(\MailSo\Imap\ImapClient $oImapClient) function __construct(\MailSo\Imap\ImapClient $oImapClient)
{ {
if (!$oImapClient->IsSupported('SORT')) { if (!$oImapClient->hasCapability('SORT')) {
$oImapClient->writeLogException( $oImapClient->writeLogException(
new \MailSo\RuntimeException('SORT is not supported'), new \MailSo\RuntimeException('SORT is not supported'),
\LOG_ERR, true); \LOG_ERR, true);
@ -73,12 +73,12 @@ class SORT extends Request
if ($this->aReturn) { if ($this->aReturn) {
// RFC 5267 checks // RFC 5267 checks
if (!$this->oImapClient->IsSupported('ESORT')) { if (!$this->oImapClient->hasCapability('ESORT')) {
$this->oImapClient->writeLogException( $this->oImapClient->writeLogException(
new \MailSo\RuntimeException('ESORT is not supported'), new \MailSo\RuntimeException('ESORT is not supported'),
\LOG_ERR, true); \LOG_ERR, true);
} }
if (!$this->oImapClient->IsSupported('CONTEXT=SORT')) { if (!$this->oImapClient->hasCapability('CONTEXT=SORT')) {
foreach ($this->aReturn as $sReturn) { foreach ($this->aReturn as $sReturn) {
if (\preg_match('/PARTIAL|UPDATE|CONTEXT/i', $sReturn)) { if (\preg_match('/PARTIAL|UPDATE|CONTEXT/i', $sReturn)) {
$this->oImapClient->writeLogException( $this->oImapClient->writeLogException(

View file

@ -27,11 +27,11 @@ class THREAD extends Request
function __construct(\MailSo\Imap\ImapClient $oImapClient) function __construct(\MailSo\Imap\ImapClient $oImapClient)
{ {
if ($oImapClient->IsSupported('THREAD=REFS')) { if ($oImapClient->hasCapability('THREAD=REFS')) {
$this->sAlgorithm = 'REFS'; $this->sAlgorithm = 'REFS';
} else if ($oImapClient->IsSupported('THREAD=REFERENCES')) { } else if ($oImapClient->hasCapability('THREAD=REFERENCES')) {
$this->sAlgorithm = 'REFERENCES'; $this->sAlgorithm = 'REFERENCES';
} else if ($oImapClient->IsSupported('THREAD=ORDEREDSUBJECT')) { } else if ($oImapClient->hasCapability('THREAD=ORDEREDSUBJECT')) {
$this->sAlgorithm = 'ORDEREDSUBJECT'; $this->sAlgorithm = 'ORDEREDSUBJECT';
} else { } else {
$oImapClient->writeLogException( $oImapClient->writeLogException(
@ -43,7 +43,7 @@ class THREAD extends Request
public function SendRequestIterateResponse() : iterable public function SendRequestIterateResponse() : iterable
{ {
if (!$this->oImapClient->IsSupported(\strtoupper("THREAD={$this->sAlgorithm}"))) { if (!$this->oImapClient->hasCapability(\strtoupper("THREAD={$this->sAlgorithm}"))) {
$this->oImapClient->writeLogException( $this->oImapClient->writeLogException(
new \MailSo\RuntimeException("THREAD={$this->sAlgorithm} is not supported"), new \MailSo\RuntimeException("THREAD={$this->sAlgorithm} is not supported"),
\LOG_ERR, true); \LOG_ERR, true);

View file

@ -156,7 +156,7 @@ abstract class SearchCriterias
$aCriteriasResult[] = $sValue; $aCriteriasResult[] = $sValue;
} }
} else { } else {
if (isset($aLines['IN']) && $oImapClient->IsSupported('MULTISEARCH') && \in_array($aLines['IN'], ['subtree','subtree-one','mailboxes'])) { if (isset($aLines['IN']) && $oImapClient->hasCapability('MULTISEARCH') && \in_array($aLines['IN'], ['subtree','subtree-one','mailboxes'])) {
$aCriteriasResult[] = "IN ({$aLines['IN']} \"{$sFolderName}\")"; $aCriteriasResult[] = "IN ({$aLines['IN']} \"{$sFolderName}\")";
} }

View file

@ -241,7 +241,7 @@ class MailClient
// RFC 3516 // RFC 3516
// Should mailserver decode or PHP? // Should mailserver decode or PHP?
if ($sMailEncoding && $this->oImapClient->IsSupported('BINARY')) { if ($sMailEncoding && $this->oImapClient->hasCapability('BINARY')) {
$sMailEncoding = ''; $sMailEncoding = '';
$sPeek = FetchType::BINARY_PEEK; $sPeek = FetchType::BINARY_PEEK;
} }
@ -320,7 +320,7 @@ class MailClient
$this->oImapClient->FolderSelect($sFromFolder); $this->oImapClient->FolderSelect($sFromFolder);
if ($this->oImapClient->IsSupported('MOVE')) { if ($this->oImapClient->hasCapability('MOVE')) {
$this->oImapClient->MessageMove($sToFolder, $oRange); $this->oImapClient->MessageMove($sToFolder, $oRange);
} else { } else {
$this->oImapClient->MessageCopy($sToFolder, $oRange); $this->oImapClient->MessageCopy($sToFolder, $oRange);
@ -667,7 +667,7 @@ class MailClient
[IMAP] addr-mailbox of the first "To" address. [IMAP] addr-mailbox of the first "To" address.
RFC 5957: RFC 5957:
$this->oImapClient->IsSupported('SORT=DISPLAY') $this->oImapClient->hasCapability('SORT=DISPLAY')
DISPLAYFROM, DISPLAYTO DISPLAYFROM, DISPLAYTO
*/ */
@ -678,7 +678,7 @@ class MailClient
$sSerializedHash = ''; $sSerializedHash = '';
$sSerializedLog = ''; $sSerializedLog = '';
$bUseSortIfSupported = $bUseSortIfSupported && !\strlen($sSearch) && $this->oImapClient->IsSupported('SORT'); $bUseSortIfSupported = $bUseSortIfSupported && !\strlen($sSearch) && $this->oImapClient->hasCapability('SORT');
$sSearchCriterias = \MailSo\Imap\SearchCriterias::fromString($this->oImapClient, $sFolderName, $sSearch, $oParams->bHideDeleted, $bUseCacheAfterSearch); $sSearchCriterias = \MailSo\Imap\SearchCriterias::fromString($this->oImapClient, $sFolderName, $sSearch, $oParams->bHideDeleted, $bUseCacheAfterSearch);
// Disabled for now as there are many cases that change the result // Disabled for now as there are many cases that change the result
@ -709,11 +709,11 @@ class MailClient
if (!$bUidsFromCacher) { if (!$bUidsFromCacher) {
if ($bUseSortIfSupported) { if ($bUseSortIfSupported) {
// $this->oImapClient->IsSupported('ESORT') // $this->oImapClient->hasCapability('ESORT')
// $aResultUids = $this->oImapClient->MessageSimpleESort(array($sSort ?: 'REVERSE DATE'), $sSearchCriterias)['ALL']; // $aResultUids = $this->oImapClient->MessageSimpleESort(array($sSort ?: 'REVERSE DATE'), $sSearchCriterias)['ALL'];
$aResultUids = $this->oImapClient->MessageSimpleSort(array($sSort ?: 'REVERSE DATE'), $sSearchCriterias); $aResultUids = $this->oImapClient->MessageSimpleSort(array($sSort ?: 'REVERSE DATE'), $sSearchCriterias);
} else { } else {
// $this->oImapClient->IsSupported('ESEARCH') // $this->oImapClient->hasCapability('ESEARCH')
// $aResultUids = $this->oImapClient->MessageSimpleESearch($sSearchCriterias, null, true, \MailSo\Base\Utils::IsAscii($sSearchCriterias) ? '' : 'UTF-8') // $aResultUids = $this->oImapClient->MessageSimpleESearch($sSearchCriterias, null, true, \MailSo\Base\Utils::IsAscii($sSearchCriterias) ? '' : 'UTF-8')
$aResultUids = $this->oImapClient->MessageSimpleSearch($sSearchCriterias, true, \MailSo\Base\Utils::IsAscii($sSearchCriterias) ? '' : 'UTF-8'); $aResultUids = $this->oImapClient->MessageSimpleSearch($sSearchCriterias, true, \MailSo\Base\Utils::IsAscii($sSearchCriterias) ? '' : 'UTF-8');
} }
@ -764,7 +764,7 @@ class MailClient
$aAllThreads = []; $aAllThreads = [];
$bUseThreads = $oParams->bUseThreads $bUseThreads = $oParams->bUseThreads
&& ($this->oImapClient->IsSupported('THREAD=REFS') || $this->oImapClient->IsSupported('THREAD=REFERENCES') || $this->oImapClient->IsSupported('THREAD=ORDEREDSUBJECT')); && ($this->oImapClient->hasCapability('THREAD=REFS') || $this->oImapClient->hasCapability('THREAD=REFERENCES') || $this->oImapClient->hasCapability('THREAD=ORDEREDSUBJECT'));
if ($oParams->iThreadUid && !$bUseThreads) { if ($oParams->iThreadUid && !$bUseThreads) {
throw new \InvalidArgumentException('THREAD not supported'); throw new \InvalidArgumentException('THREAD not supported');
} }
@ -811,7 +811,7 @@ class MailClient
} }
} else { } else {
$aUids = []; $aUids = [];
$bUseSortIfSupported = $oParams->bUseSortIfSupported && $this->oImapClient->IsSupported('SORT'); $bUseSortIfSupported = $oParams->bUseSortIfSupported && $this->oImapClient->hasCapability('SORT');
if ($bUseThreads) { if ($bUseThreads) {
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher); $aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher);
$oMessageCollection->totalThreads = \count($aAllThreads); $oMessageCollection->totalThreads = \count($aAllThreads);
@ -908,7 +908,7 @@ class MailClient
public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus) : ?FolderCollection public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus) : ?FolderCollection
{ {
$aImapSubscribedFoldersHelper = null; $aImapSubscribedFoldersHelper = null;
if ($this->oImapClient->IsSupported('LIST-EXTENDED')) { if ($this->oImapClient->hasCapability('LIST-EXTENDED')) {
$bUseListSubscribeStatus = false; $bUseListSubscribeStatus = false;
} else if ($bUseListSubscribeStatus) { } else if ($bUseListSubscribeStatus) {
// $this->oLogger && $this->oLogger->Write('RFC5258 not supported, using LSUB'); // $this->oLogger && $this->oLogger->Write('RFC5258 not supported, using LSUB');
@ -1081,7 +1081,7 @@ class MailClient
throw new \InvalidArgumentException; throw new \InvalidArgumentException;
} }
if ($this->oImapClient->IsSupported('IMAP4rev2')) { if ($this->oImapClient->hasCapability('IMAP4rev2')) {
$oInfo = $this->oImapClient->FolderExamine($sFolderFullName); $oInfo = $this->oImapClient->FolderExamine($sFolderFullName);
} else { } else {
$oInfo = $this->oImapClient->FolderStatus($sFolderFullName); $oInfo = $this->oImapClient->FolderStatus($sFolderFullName);

View file

@ -47,7 +47,7 @@ class Sync
} }
\SnappyMail\Log::notice('SYNC', 'Get oImapSource->FolderList'); \SnappyMail\Log::notice('SYNC', 'Get oImapSource->FolderList');
$bUseListStatus = $this->oImapSource->IsSupported('LIST-EXTENDED'); $bUseListStatus = $this->oImapSource->hasCapability('LIST-EXTENDED');
$aSourceFolders = $this->oImapSource->FolderList($sParent, $sListPattern, false, $bUseListStatus); $aSourceFolders = $this->oImapSource->FolderList($sParent, $sListPattern, false, $bUseListStatus);
if (!$aSourceFolders) { if (!$aSourceFolders) {
return null; return null;
@ -168,7 +168,7 @@ class Sync
// Now copy each message from source to target // Now copy each message from source to target
for ($i = 1; $i <= $oSourceInfo->MESSAGES; ++$i) { for ($i = 1; $i <= $oSourceInfo->MESSAGES; ++$i) {
if (!\in_array($i, $aSourceSkipIDs)) { if (!\in_array($i, $aSourceSkipIDs)) {
$sPeek = $this->oImapSource->IsSupported('BINARY') $sPeek = $this->oImapSource->hasCapability('BINARY')
? FetchType::BINARY_PEEK ? FetchType::BINARY_PEEK
: FetchType::BODY_PEEK; : FetchType::BODY_PEEK;
$iAppendUid = 0; $iAppendUid = 0;