mirror of
https://github.com/the-djmaze/snappymail.git
synced 2026-08-27 11:09:20 +03:00
Rename ImapClient::IsSupported() to ImapClient::hasCapability()
This commit is contained in:
parent
3fdb2e7698
commit
19bc530879
13 changed files with 71 additions and 67 deletions
|
|
@ -24,7 +24,7 @@ trait ACL
|
|||
*/
|
||||
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) {
|
||||
return true;
|
||||
}
|
||||
|
|
@ -129,7 +129,7 @@ trait ACL
|
|||
public function FolderMyRights(string $sFolderName) : ?ACLResponse
|
||||
{
|
||||
// if ($this->ACLAllow($sFolderName, 'MYRIGHTS')) {
|
||||
// if ($this->IsSupported('ACL')) {
|
||||
// if ($this->hasCapability('ACL')) {
|
||||
$oResponses = $this->SendRequestGetResponse('MYRIGHTS', array($this->EscapeString($sFolderName)));
|
||||
foreach ($oResponses as $oResponse) {
|
||||
if (\MailSo\Imap\Enumerations\ResponseType::UNTAGGED === $oResponse->ResponseType
|
||||
|
|
|
|||
|
|
@ -113,23 +113,23 @@ trait Folders
|
|||
FolderStatus::UIDVALIDITY
|
||||
);
|
||||
// RFC 4551
|
||||
if ($this->IsSupported('CONDSTORE')) {
|
||||
if ($this->hasCapability('CONDSTORE')) {
|
||||
$aStatusItems[] = FolderStatus::HIGHESTMODSEQ;
|
||||
}
|
||||
// RFC 7889
|
||||
if ($this->IsSupported('APPENDLIMIT')) {
|
||||
if ($this->hasCapability('APPENDLIMIT')) {
|
||||
$aStatusItems[] = FolderStatus::APPENDLIMIT;
|
||||
}
|
||||
// RFC 8474
|
||||
if ($this->IsSupported('OBJECTID')) {
|
||||
if ($this->hasCapability('OBJECTID')) {
|
||||
$aStatusItems[] = FolderStatus::MAILBOXID;
|
||||
/*
|
||||
} else if ($this->IsSupported('X-DOVECOT')) {
|
||||
} else if ($this->hasCapability('X-DOVECOT')) {
|
||||
$aStatusItems[] = 'X-GUID';
|
||||
*/
|
||||
}
|
||||
/* // STATUS SIZE can take a significant amount of time, therefore not active
|
||||
if ($this->IsSupported('IMAP4rev2')) {
|
||||
if ($this->hasCapability('IMAP4rev2')) {
|
||||
$aStatusItems[] = FolderStatus::SIZE;
|
||||
}
|
||||
*/
|
||||
|
|
@ -156,7 +156,7 @@ trait Folders
|
|||
* 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'];
|
||||
}
|
||||
return $oFolderInfo;
|
||||
|
|
@ -235,7 +235,7 @@ trait Folders
|
|||
public function FolderUnselect() : self
|
||||
{
|
||||
if ($this->IsSelected()) {
|
||||
if ($this->IsSupported('UNSELECT')) {
|
||||
if ($this->hasCapability('UNSELECT')) {
|
||||
$this->SendRequestGetResponse('UNSELECT');
|
||||
$this->oCurrentFolderInfo = null;
|
||||
} else {
|
||||
|
|
@ -266,7 +266,7 @@ trait Folders
|
|||
$sCmd = 'EXPUNGE';
|
||||
$aArguments = array();
|
||||
|
||||
if ($oUidRange && \count($oUidRange) && $oUidRange->UID && $this->IsSupported('UIDPLUS')) {
|
||||
if ($oUidRange && \count($oUidRange) && $oUidRange->UID && $this->hasCapability('UIDPLUS')) {
|
||||
$sCmd = 'UID '.$sCmd;
|
||||
$aArguments = array((string) $oUidRange);
|
||||
}
|
||||
|
|
@ -344,7 +344,7 @@ trait Folders
|
|||
|
||||
/*
|
||||
// RFC 5162
|
||||
if ($this->IsSupported('QRESYNC')) {
|
||||
if ($this->hasCapability('QRESYNC')) {
|
||||
$this->Enable(['QRESYNC', 'CONDSTORE']);
|
||||
- the last known UIDVALIDITY,
|
||||
- the last known modification sequence,
|
||||
|
|
@ -355,7 +355,7 @@ trait Folders
|
|||
}
|
||||
|
||||
// RFC 4551
|
||||
if ($this->IsSupported('CONDSTORE')) {
|
||||
if ($this->hasCapability('CONDSTORE')) {
|
||||
$aSelectParams[] = 'CONDSTORE';
|
||||
}
|
||||
|
||||
|
|
@ -409,7 +409,7 @@ trait Folders
|
|||
// IMAP4rev2 deprecated
|
||||
$oResult->UNSEEN = null;
|
||||
/*
|
||||
if ($this->IsSupported('ESEARCH')) {
|
||||
if ($this->hasCapability('ESEARCH')) {
|
||||
$oResult->UNSEEN = $this->MessageSimpleESearch('UNSEEN', ['COUNT'])['COUNT'];
|
||||
}
|
||||
*/
|
||||
|
|
@ -433,7 +433,7 @@ trait Folders
|
|||
if ($bIsSubscribeList) {
|
||||
// IMAP4rev2 deprecated
|
||||
$sCmd = 'LSUB';
|
||||
} else if ($this->IsSupported('LIST-EXTENDED')) {
|
||||
} else if ($this->hasCapability('LIST-EXTENDED')) {
|
||||
// RFC 5258
|
||||
$aReturnParams[] = 'SUBSCRIBED';
|
||||
// $aReturnParams[] = 'CHILDREN';
|
||||
|
|
@ -443,7 +443,7 @@ trait Folders
|
|||
// $aParameters[0] = '()';
|
||||
}
|
||||
// RFC 6154
|
||||
if ($this->IsSupported('SPECIAL-USE')) {
|
||||
if ($this->hasCapability('SPECIAL-USE')) {
|
||||
$aReturnParams[] = 'SPECIAL-USE';
|
||||
}
|
||||
}
|
||||
|
|
@ -453,7 +453,7 @@ trait Folders
|
|||
// $aParameters[] = $this->EscapeString(\strlen(\trim($sListPattern)) ? $sListPattern : '*');
|
||||
|
||||
// RFC 5819
|
||||
if ($bUseListStatus && !$bIsSubscribeList && $this->IsSupported('LIST-STATUS'))
|
||||
if ($bUseListStatus && !$bIsSubscribeList && $this->hasCapability('LIST-STATUS'))
|
||||
{
|
||||
$aReturnParams[] = 'STATUS';
|
||||
$aReturnParams[] = $this->FolderStatusItems();
|
||||
|
|
@ -473,7 +473,7 @@ trait Folders
|
|||
$aReturn = array();
|
||||
|
||||
// RFC 5464
|
||||
$bMetadata = !$bIsSubscribeList && $this->IsSupported('METADATA');
|
||||
$bMetadata = !$bIsSubscribeList && $this->hasCapability('METADATA');
|
||||
$aMetadata = null;
|
||||
if ($bMetadata) {
|
||||
// Dovecot supports fetching all METADATA at once
|
||||
|
|
|
|||
|
|
@ -77,20 +77,20 @@ trait Messages
|
|||
break;
|
||||
}
|
||||
}
|
||||
if ($this->IsSupported('OBJECTID')) {
|
||||
if ($this->hasCapability('OBJECTID')) {
|
||||
$aFetchItems[] = FetchType::EMAILID;
|
||||
$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
|
||||
$aFetchItems[] = 'X-GM-MSGID';
|
||||
$aFetchItems[] = 'X-GM-THRID';
|
||||
/*
|
||||
} else if ($this->IsSupported('X-DOVECOT')) {
|
||||
} else if ($this->hasCapability('X-DOVECOT')) {
|
||||
$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';
|
||||
}
|
||||
*/
|
||||
|
|
@ -147,7 +147,7 @@ trait Messages
|
|||
|
||||
/*
|
||||
// RFC 3516 || RFC 6855 section-4
|
||||
if ($this->IsSupported('BINARY') || $this->IsSupported('UTF8=ACCEPT')) {
|
||||
if ($this->hasCapability('BINARY') || $this->hasCapability('UTF8=ACCEPT')) {
|
||||
$aParams[] = '~{'.$iStreamSize.'}';
|
||||
}
|
||||
*/
|
||||
|
|
@ -220,7 +220,7 @@ trait Messages
|
|||
$this->writeLogException(new \InvalidArgumentException, \LOG_ERR, true);
|
||||
}
|
||||
|
||||
if (!$this->IsSupported('MOVE')) {
|
||||
if (!$this->hasCapability('MOVE')) {
|
||||
$this->writeLogException(
|
||||
new \MailSo\RuntimeException('Move is not supported'),
|
||||
\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
|
||||
{
|
||||
if (1 > $iUid || !$this->IsSupported('REPLACE')) {
|
||||
if (1 > $iUid || !$this->hasCapability('REPLACE')) {
|
||||
$this->FolderSelect($sFolderName);
|
||||
$iNewUid = $this->MessageAppendStream($sFolderName, $rMessageStream, $iStreamSize, $aFlagsList, $iDateTime);
|
||||
if ($iUid) {
|
||||
|
|
@ -271,7 +271,7 @@ trait Messages
|
|||
|
||||
/*
|
||||
// RFC 3516 || RFC 6855 section-4
|
||||
if ($this->IsSupported('BINARY') || $this->IsSupported('UTF8=ACCEPT')) {
|
||||
if ($this->hasCapability('BINARY') || $this->hasCapability('UTF8=ACCEPT')) {
|
||||
$aParams[] = '~{'.$iStreamSize.'}';
|
||||
}
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -96,21 +96,21 @@ trait Metadata
|
|||
|
||||
public function ServerGetMetadata(array $aEntries, array $aOptions = []) : array
|
||||
{
|
||||
return $this->IsSupported('METADATA-SERVER')
|
||||
return $this->hasCapability('METADATA-SERVER')
|
||||
? $this->getMetadata('', $aEntries, $aOptions)
|
||||
: [];
|
||||
}
|
||||
|
||||
public function FolderGetMetadata(string $sFolderName, array $aEntries, array $aOptions = []) : array
|
||||
{
|
||||
return $this->IsSupported('METADATA')
|
||||
return $this->hasCapability('METADATA')
|
||||
? $this->getMetadata($sFolderName, $aEntries, $aOptions)
|
||||
: [];
|
||||
}
|
||||
|
||||
public function FolderSetMetadata(string $sFolderName, array $aEntries) : void
|
||||
{
|
||||
if ($this->IsSupported('METADATA')) {
|
||||
if ($this->hasCapability('METADATA')) {
|
||||
if (!$aEntries) {
|
||||
throw new \MailSo\Base\Exceptions\InvalidArgumentException("Wrong argument for SETMETADATA command");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ trait Quota
|
|||
// * QUOTA "User quota" (STORAGE 1284645 2097152)\r\n
|
||||
private function getQuota(bool $root, string $sFolderName) : ?array
|
||||
{
|
||||
if (!$this->IsSupported('QUOTA')) {
|
||||
if (!$this->hasCapability('QUOTA')) {
|
||||
return null;
|
||||
}
|
||||
$oResponseCollection = $this->SendRequest(($root?'GETQUOTAROOT':'GETQUOTA') . " {$this->EscapeFolderName($sFolderName)}");
|
||||
|
|
|
|||
|
|
@ -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
|
||||
$rights = $this->ImapClient->FolderMyRights($this->FolderName);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -74,14 +74,14 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$this->setCapabilities($this->getResponse('*'));
|
||||
|
||||
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();
|
||||
}
|
||||
}
|
||||
|
||||
private function StartTLS() : void
|
||||
{
|
||||
if ($this->IsSupported('STARTTLS')) {
|
||||
if ($this->hasCapability('STARTTLS')) {
|
||||
$this->SendRequestGetResponse('STARTTLS');
|
||||
$this->EnableCrypto();
|
||||
$this->aCapabilityItems = null;
|
||||
|
|
@ -121,17 +121,17 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
|
||||
$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;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// 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';
|
||||
}
|
||||
if (!$type) {
|
||||
if (!$this->Encrypted() && $this->IsSupported('STARTTLS')) {
|
||||
if (!$this->Encrypted() && $this->hasCapability('STARTTLS')) {
|
||||
$this->StartTLS();
|
||||
return $this->Login($oSettings);
|
||||
}
|
||||
|
|
@ -170,7 +170,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
{
|
||||
$sAuth = $SASL->authenticate($sLogin, $sPassword);
|
||||
$this->oLogger && $this->oLogger->AddSecret($sAuth);
|
||||
if ($this->IsSupported('SASL-IR')) {
|
||||
if ($this->hasCapability('SASL-IR')) {
|
||||
$oResponse = $this->SendRequestGetResponse('AUTHENTICATE', array($type, $sAuth));
|
||||
} else {
|
||||
$this->SendRequestGetResponse('AUTHENTICATE', array($type));
|
||||
|
|
@ -192,7 +192,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
$oResponse = $this->getResponse();
|
||||
}
|
||||
}
|
||||
else if ($this->IsSupported('LOGINDISABLED'))
|
||||
else if ($this->hasCapability('LOGINDISABLED'))
|
||||
{
|
||||
$sB64 = $this->getResponseValue($this->SendRequestGetResponse('AUTHENTICATE', array($type)), Enumerations\ResponseType::CONTINUATION);
|
||||
$this->sendRaw($SASL->authenticate($sLogin, $sPassword, $sB64), true);
|
||||
|
|
@ -221,12 +221,12 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
}
|
||||
/*
|
||||
// TODO: RFC 9051
|
||||
if ($this->IsSupported('IMAP4rev2')) {
|
||||
if ($this->hasCapability('IMAP4rev2')) {
|
||||
$this->Enable('IMAP4rev1');
|
||||
}
|
||||
*/
|
||||
// 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) {
|
||||
$this->Enable('UTF8=ACCEPT');
|
||||
}
|
||||
|
|
@ -334,11 +334,15 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
* @throws \MailSo\Net\Exceptions\*
|
||||
* @throws \MailSo\Imap\Exceptions\*
|
||||
*/
|
||||
public function IsSupported(string $sExtentionName) : bool
|
||||
public function hasCapability(string $sExtentionName) : bool
|
||||
{
|
||||
$sExtentionName = \trim($sExtentionName);
|
||||
return $sExtentionName && \in_array(\strtoupper($sExtentionName), $this->Capability() ?: []);
|
||||
}
|
||||
public function IsSupported(string $sExtentionName) : bool
|
||||
{
|
||||
return $this->hasCapability($sExtentionName);
|
||||
}
|
||||
|
||||
/**
|
||||
* RFC 5161
|
||||
|
|
@ -360,7 +364,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
*/
|
||||
public function GetNamespace() : ?NamespaceResult
|
||||
{
|
||||
if (!$this->IsSupported('NAMESPACE')) {
|
||||
if (!$this->hasCapability('NAMESPACE')) {
|
||||
return null;
|
||||
}
|
||||
|
||||
|
|
@ -637,7 +641,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
*/
|
||||
public function ServerID() : string
|
||||
{
|
||||
if ($this->IsSupported('ID')) {
|
||||
if ($this->hasCapability('ID')) {
|
||||
foreach ($this->SendRequestGetResponse('ID', [null]) as $oResponse) {
|
||||
if ('ID' === $oResponse->ResponseList[1] && \is_array($oResponse->ResponseList[2])) {
|
||||
$c = \count($oResponse->ResponseList[2]);
|
||||
|
|
@ -659,7 +663,7 @@ class ImapClient extends \MailSo\Net\NetClient
|
|||
public function Compress() : bool
|
||||
{
|
||||
try {
|
||||
if ($this->IsSupported('COMPRESS=DEFLATE')) {
|
||||
if ($this->hasCapability('COMPRESS=DEFLATE')) {
|
||||
$this->SendRequestGetResponse('COMPRESS', ['DEFLATE']);
|
||||
\stream_filter_append($this->ConnectionResource(), 'zlib.inflate');
|
||||
\stream_filter_append($this->ConnectionResource(), 'zlib.deflate', STREAM_FILTER_WRITE, array(
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class ESEARCH extends Request
|
|||
|
||||
function __construct(\MailSo\Imap\ImapClient $oImapClient)
|
||||
{
|
||||
if (!$oImapClient->IsSupported('ESEARCH')) {
|
||||
if (!$oImapClient->hasCapability('ESEARCH')) {
|
||||
$oImapClient->writeLogException(
|
||||
new \MailSo\RuntimeException('ESEARCH is not supported'),
|
||||
\LOG_ERR, true);
|
||||
|
|
@ -66,7 +66,7 @@ class ESEARCH extends Request
|
|||
$aRequest = array();
|
||||
|
||||
/* // 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(
|
||||
new \MailSo\RuntimeException('SEARCH=FUZZY is not supported'),
|
||||
\LOG_ERR, true);
|
||||
|
|
@ -87,7 +87,7 @@ class ESEARCH extends Request
|
|||
$aFolders[] = $this->aSubtreesOne;
|
||||
}
|
||||
if ($aFolders) {
|
||||
if (!$this->oImapClient->IsSupported('MULTISEARCH')) {
|
||||
if (!$this->oImapClient->hasCapability('MULTISEARCH')) {
|
||||
$this->oImapClient->writeLogException(
|
||||
new \MailSo\RuntimeException('MULTISEARCH is not supported'),
|
||||
\LOG_ERR, true);
|
||||
|
|
@ -105,7 +105,7 @@ class ESEARCH extends Request
|
|||
$aRequest[] = 'RETURN';
|
||||
if ($this->aReturn) {
|
||||
// RFC 5267 checks
|
||||
if (!$this->oImapClient->IsSupported('CONTEXT=SEARCH')) {
|
||||
if (!$this->oImapClient->hasCapability('CONTEXT=SEARCH')) {
|
||||
foreach ($this->aReturn as $sReturn) {
|
||||
if (\preg_match('/PARTIAL|UPDATE|CONTEXT/i', $sReturn)) {
|
||||
$this->oImapClient->writeLogException(
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ class SORT extends Request
|
|||
|
||||
function __construct(\MailSo\Imap\ImapClient $oImapClient)
|
||||
{
|
||||
if (!$oImapClient->IsSupported('SORT')) {
|
||||
if (!$oImapClient->hasCapability('SORT')) {
|
||||
$oImapClient->writeLogException(
|
||||
new \MailSo\RuntimeException('SORT is not supported'),
|
||||
\LOG_ERR, true);
|
||||
|
|
@ -73,12 +73,12 @@ class SORT extends Request
|
|||
|
||||
if ($this->aReturn) {
|
||||
// RFC 5267 checks
|
||||
if (!$this->oImapClient->IsSupported('ESORT')) {
|
||||
if (!$this->oImapClient->hasCapability('ESORT')) {
|
||||
$this->oImapClient->writeLogException(
|
||||
new \MailSo\RuntimeException('ESORT is not supported'),
|
||||
\LOG_ERR, true);
|
||||
}
|
||||
if (!$this->oImapClient->IsSupported('CONTEXT=SORT')) {
|
||||
if (!$this->oImapClient->hasCapability('CONTEXT=SORT')) {
|
||||
foreach ($this->aReturn as $sReturn) {
|
||||
if (\preg_match('/PARTIAL|UPDATE|CONTEXT/i', $sReturn)) {
|
||||
$this->oImapClient->writeLogException(
|
||||
|
|
|
|||
|
|
@ -27,11 +27,11 @@ class THREAD extends Request
|
|||
|
||||
function __construct(\MailSo\Imap\ImapClient $oImapClient)
|
||||
{
|
||||
if ($oImapClient->IsSupported('THREAD=REFS')) {
|
||||
if ($oImapClient->hasCapability('THREAD=REFS')) {
|
||||
$this->sAlgorithm = 'REFS';
|
||||
} else if ($oImapClient->IsSupported('THREAD=REFERENCES')) {
|
||||
} else if ($oImapClient->hasCapability('THREAD=REFERENCES')) {
|
||||
$this->sAlgorithm = 'REFERENCES';
|
||||
} else if ($oImapClient->IsSupported('THREAD=ORDEREDSUBJECT')) {
|
||||
} else if ($oImapClient->hasCapability('THREAD=ORDEREDSUBJECT')) {
|
||||
$this->sAlgorithm = 'ORDEREDSUBJECT';
|
||||
} else {
|
||||
$oImapClient->writeLogException(
|
||||
|
|
@ -43,7 +43,7 @@ class THREAD extends Request
|
|||
|
||||
public function SendRequestIterateResponse() : iterable
|
||||
{
|
||||
if (!$this->oImapClient->IsSupported(\strtoupper("THREAD={$this->sAlgorithm}"))) {
|
||||
if (!$this->oImapClient->hasCapability(\strtoupper("THREAD={$this->sAlgorithm}"))) {
|
||||
$this->oImapClient->writeLogException(
|
||||
new \MailSo\RuntimeException("THREAD={$this->sAlgorithm} is not supported"),
|
||||
\LOG_ERR, true);
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ abstract class SearchCriterias
|
|||
$aCriteriasResult[] = $sValue;
|
||||
}
|
||||
} 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}\")";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -241,7 +241,7 @@ class MailClient
|
|||
|
||||
// RFC 3516
|
||||
// Should mailserver decode or PHP?
|
||||
if ($sMailEncoding && $this->oImapClient->IsSupported('BINARY')) {
|
||||
if ($sMailEncoding && $this->oImapClient->hasCapability('BINARY')) {
|
||||
$sMailEncoding = '';
|
||||
$sPeek = FetchType::BINARY_PEEK;
|
||||
}
|
||||
|
|
@ -320,7 +320,7 @@ class MailClient
|
|||
|
||||
$this->oImapClient->FolderSelect($sFromFolder);
|
||||
|
||||
if ($this->oImapClient->IsSupported('MOVE')) {
|
||||
if ($this->oImapClient->hasCapability('MOVE')) {
|
||||
$this->oImapClient->MessageMove($sToFolder, $oRange);
|
||||
} else {
|
||||
$this->oImapClient->MessageCopy($sToFolder, $oRange);
|
||||
|
|
@ -667,7 +667,7 @@ class MailClient
|
|||
[IMAP] addr-mailbox of the first "To" address.
|
||||
|
||||
RFC 5957:
|
||||
$this->oImapClient->IsSupported('SORT=DISPLAY')
|
||||
$this->oImapClient->hasCapability('SORT=DISPLAY')
|
||||
DISPLAYFROM, DISPLAYTO
|
||||
*/
|
||||
|
||||
|
|
@ -678,7 +678,7 @@ class MailClient
|
|||
$sSerializedHash = '';
|
||||
$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);
|
||||
// Disabled for now as there are many cases that change the result
|
||||
|
|
@ -709,11 +709,11 @@ class MailClient
|
|||
|
||||
if (!$bUidsFromCacher) {
|
||||
if ($bUseSortIfSupported) {
|
||||
// $this->oImapClient->IsSupported('ESORT')
|
||||
// $this->oImapClient->hasCapability('ESORT')
|
||||
// $aResultUids = $this->oImapClient->MessageSimpleESort(array($sSort ?: 'REVERSE DATE'), $sSearchCriterias)['ALL'];
|
||||
$aResultUids = $this->oImapClient->MessageSimpleSort(array($sSort ?: 'REVERSE DATE'), $sSearchCriterias);
|
||||
} 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->MessageSimpleSearch($sSearchCriterias, true, \MailSo\Base\Utils::IsAscii($sSearchCriterias) ? '' : 'UTF-8');
|
||||
}
|
||||
|
|
@ -764,7 +764,7 @@ class MailClient
|
|||
$aAllThreads = [];
|
||||
|
||||
$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) {
|
||||
throw new \InvalidArgumentException('THREAD not supported');
|
||||
}
|
||||
|
|
@ -811,7 +811,7 @@ class MailClient
|
|||
}
|
||||
} else {
|
||||
$aUids = [];
|
||||
$bUseSortIfSupported = $oParams->bUseSortIfSupported && $this->oImapClient->IsSupported('SORT');
|
||||
$bUseSortIfSupported = $oParams->bUseSortIfSupported && $this->oImapClient->hasCapability('SORT');
|
||||
if ($bUseThreads) {
|
||||
$aAllThreads = $this->MessageListThreadsMap($oMessageCollection->FolderName, $oMessageCollection->FolderHash, $oParams->oCacher);
|
||||
$oMessageCollection->totalThreads = \count($aAllThreads);
|
||||
|
|
@ -908,7 +908,7 @@ class MailClient
|
|||
public function Folders(string $sParent, string $sListPattern, bool $bUseListSubscribeStatus) : ?FolderCollection
|
||||
{
|
||||
$aImapSubscribedFoldersHelper = null;
|
||||
if ($this->oImapClient->IsSupported('LIST-EXTENDED')) {
|
||||
if ($this->oImapClient->hasCapability('LIST-EXTENDED')) {
|
||||
$bUseListSubscribeStatus = false;
|
||||
} else if ($bUseListSubscribeStatus) {
|
||||
// $this->oLogger && $this->oLogger->Write('RFC5258 not supported, using LSUB');
|
||||
|
|
@ -1081,7 +1081,7 @@ class MailClient
|
|||
throw new \InvalidArgumentException;
|
||||
}
|
||||
|
||||
if ($this->oImapClient->IsSupported('IMAP4rev2')) {
|
||||
if ($this->oImapClient->hasCapability('IMAP4rev2')) {
|
||||
$oInfo = $this->oImapClient->FolderExamine($sFolderFullName);
|
||||
} else {
|
||||
$oInfo = $this->oImapClient->FolderStatus($sFolderFullName);
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ class Sync
|
|||
}
|
||||
|
||||
\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);
|
||||
if (!$aSourceFolders) {
|
||||
return null;
|
||||
|
|
@ -168,7 +168,7 @@ class Sync
|
|||
// Now copy each message from source to target
|
||||
for ($i = 1; $i <= $oSourceInfo->MESSAGES; ++$i) {
|
||||
if (!\in_array($i, $aSourceSkipIDs)) {
|
||||
$sPeek = $this->oImapSource->IsSupported('BINARY')
|
||||
$sPeek = $this->oImapSource->hasCapability('BINARY')
|
||||
? FetchType::BINARY_PEEK
|
||||
: FetchType::BODY_PEEK;
|
||||
$iAppendUid = 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue