From 9a86292bcf4180c7bacee9f1101a45b9af81bb08 Mon Sep 17 00:00:00 2001 From: Sebastian Krupinski Date: Fri, 25 Sep 2026 11:32:25 -0400 Subject: [PATCH] refactor: re-organize files Signed-off-by: Sebastian Krupinski --- lib/Client/Client.php | 15 ++-- lib/Client/ClientInterface.php | 6 +- lib/Client/IdentifierMode.php | 16 ----- lib/Client/Mailbox.php | 2 +- .../{ => Protocol}/Command/AppendCommand.php | 6 +- .../Command/Argument}/FetchOptions.php | 2 +- .../Command/Argument}/ListReturnOptions.php | 4 +- .../Argument}/ListSelectionOptions.php | 4 +- .../Command/Argument/MessageTarget.php} | 12 ++-- .../Argument}/SearchCriteriaBuilder.php | 4 +- .../Command/CapabilityCommand.php | 8 +-- .../Command/CommandInterface.php | 6 +- .../{ => Protocol}/Command/CopyCommand.php | 12 ++-- .../{ => Protocol}/Command/CreateCommand.php | 8 +-- .../{ => Protocol}/Command/DeleteCommand.php | 8 +-- .../{ => Protocol}/Command/ExpungeCommand.php | 20 +++--- .../Command/FetchManyCommand.php | 29 ++++---- .../Command/FetchOneCommand.php | 23 +++--- .../{ => Protocol}/Command/ListCommand.php | 11 +-- .../{ => Protocol}/Command/LoginCommand.php | 8 +-- .../{ => Protocol}/Command/LogoutCommand.php | 8 +-- .../Command/MessageTransferCommand.php | 24 +++---- .../{ => Protocol}/Command/MoveCommand.php | 12 ++-- .../{ => Protocol}/Command/NoopCommand.php | 8 +-- .../{ => Protocol}/Command/RenameCommand.php | 8 +-- .../{ => Protocol}/Command/SearchCommand.php | 12 ++-- .../{ => Protocol}/Command/SelectCommand.php | 6 +- .../{ => Protocol}/Command/SortCommand.php | 12 ++-- .../Command/StartTlsCommand.php | 8 +-- .../{ => Protocol}/Command/StatusCommand.php | 9 +-- .../{ => Protocol}/Command/StoreCommand.php | 24 +++---- lib/Client/Protocol/CommandExecutor.php | 10 +-- lib/Client/Protocol/IdentifierMode.php | 11 +++ .../Parser}/FetchResponseParser.php | 4 +- .../{ => Protocol/Parser}/MessageParser.php | 6 +- .../Parser}/StatusResponseParser.php | 2 +- lib/Client/{ => Protocol}/SequenceSet.php | 2 +- lib/Client/{ => Protocol}/SessionContext.php | 4 +- lib/Client/{ => Protocol}/SessionState.php | 2 +- .../{Command => }/Result/CapabilityResult.php | 2 +- .../Result/CommandStatusResult.php | 2 +- .../Result/MessageTransferResult.php | 2 +- .../{Command => }/Result/SearchResult.php | 4 +- .../{Command => }/Result/SortResult.php | 4 +- .../{Command => }/Result/StatusResult.php | 2 +- lib/Console/TestCommand.php | 10 +-- lib/Service/Remote/RemoteMailService.php | 70 +++++++++---------- 47 files changed, 244 insertions(+), 228 deletions(-) delete mode 100644 lib/Client/IdentifierMode.php rename lib/Client/{ => Protocol}/Command/AppendCommand.php (94%) rename lib/Client/{ => Protocol/Command/Argument}/FetchOptions.php (98%) rename lib/Client/{ => Protocol/Command/Argument}/ListReturnOptions.php (97%) rename lib/Client/{ => Protocol/Command/Argument}/ListSelectionOptions.php (96%) rename lib/Client/{FetchTarget.php => Protocol/Command/Argument/MessageTarget.php} (86%) rename lib/Client/{ => Protocol/Command/Argument}/SearchCriteriaBuilder.php (98%) rename lib/Client/{ => Protocol}/Command/CapabilityCommand.php (88%) rename lib/Client/{ => Protocol}/Command/CommandInterface.php (77%) rename lib/Client/{ => Protocol}/Command/CopyCommand.php (74%) rename lib/Client/{ => Protocol}/Command/CreateCommand.php (88%) rename lib/Client/{ => Protocol}/Command/DeleteCommand.php (88%) rename lib/Client/{ => Protocol}/Command/ExpungeCommand.php (81%) rename lib/Client/{ => Protocol}/Command/FetchManyCommand.php (57%) rename lib/Client/{ => Protocol}/Command/FetchOneCommand.php (62%) rename lib/Client/{ => Protocol}/Command/ListCommand.php (95%) rename lib/Client/{ => Protocol}/Command/LoginCommand.php (88%) rename lib/Client/{ => Protocol}/Command/LogoutCommand.php (87%) rename lib/Client/{ => Protocol}/Command/MessageTransferCommand.php (90%) rename lib/Client/{ => Protocol}/Command/MoveCommand.php (74%) rename lib/Client/{ => Protocol}/Command/NoopCommand.php (86%) rename lib/Client/{ => Protocol}/Command/RenameCommand.php (89%) rename lib/Client/{ => Protocol}/Command/SearchCommand.php (90%) rename lib/Client/{ => Protocol}/Command/SelectCommand.php (95%) rename lib/Client/{ => Protocol}/Command/SortCommand.php (92%) rename lib/Client/{ => Protocol}/Command/StartTlsCommand.php (86%) rename lib/Client/{ => Protocol}/Command/StatusCommand.php (91%) rename lib/Client/{ => Protocol}/Command/StoreCommand.php (80%) create mode 100644 lib/Client/Protocol/IdentifierMode.php rename lib/Client/{Command => Protocol/Parser}/FetchResponseParser.php (93%) rename lib/Client/{ => Protocol/Parser}/MessageParser.php (99%) rename lib/Client/{Command => Protocol/Parser}/StatusResponseParser.php (98%) rename lib/Client/{ => Protocol}/SequenceSet.php (98%) rename lib/Client/{ => Protocol}/SessionContext.php (95%) rename lib/Client/{ => Protocol}/SessionState.php (84%) rename lib/Client/{Command => }/Result/CapabilityResult.php (90%) rename lib/Client/{Command => }/Result/CommandStatusResult.php (89%) rename lib/Client/{Command => }/Result/MessageTransferResult.php (98%) rename lib/Client/{Command => }/Result/SearchResult.php (85%) rename lib/Client/{Command => }/Result/SortResult.php (85%) rename lib/Client/{Command => }/Result/StatusResult.php (94%) diff --git a/lib/Client/Client.php b/lib/Client/Client.php index deda273..9396162 100644 --- a/lib/Client/Client.php +++ b/lib/Client/Client.php @@ -4,11 +4,14 @@ declare(strict_types=1); namespace KTXM\ProviderImap\Client; -use KTXM\ProviderImap\Client\Command\CapabilityCommand; -use KTXM\ProviderImap\Client\Command\CommandInterface; -use KTXM\ProviderImap\Client\FetchTarget; -use KTXM\ProviderImap\Client\Command\LoginCommand; -use KTXM\ProviderImap\Client\Command\StartTlsCommand; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; + +use KTXM\ProviderImap\Client\Protocol\Command\CapabilityCommand; +use KTXM\ProviderImap\Client\Protocol\Command\CommandInterface; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; +use KTXM\ProviderImap\Client\Protocol\Command\LoginCommand; +use KTXM\ProviderImap\Client\Protocol\Command\StartTlsCommand; use KTXM\ProviderImap\Client\Protocol\CommandExecutor; use KTXM\ProviderImap\Client\Protocol\ProtocolReader; use KTXM\ProviderImap\Client\Protocol\ProtocolWriter; @@ -87,7 +90,7 @@ final class Client implements ClientInterface return $this->executor->perform($command, $this->session); } - public function download(FetchTarget $target, string $section, int $chunkSize = 8192): \Generator + public function download(MessageTarget $target, string $section, int $chunkSize = 8192): \Generator { if ($this->session === null || $this->executor === null) { throw new ImapException('IMAP client is not connected.'); diff --git a/lib/Client/ClientInterface.php b/lib/Client/ClientInterface.php index eb69753..88e9680 100644 --- a/lib/Client/ClientInterface.php +++ b/lib/Client/ClientInterface.php @@ -4,8 +4,8 @@ declare(strict_types=1); namespace KTXM\ProviderImap\Client; -use KTXM\ProviderImap\Client\Command\CommandInterface; -use KTXM\ProviderImap\Client\FetchTarget; +use KTXM\ProviderImap\Client\Protocol\Command\CommandInterface; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; interface ClientInterface { @@ -28,5 +28,5 @@ interface ClientInterface * * @return \Generator raw (transfer-encoded) bytes from the socket */ - public function download(FetchTarget $target, string $section, int $chunkSize = 8192): \Generator; + public function download(MessageTarget $target, string $section, int $chunkSize = 8192): \Generator; } \ No newline at end of file diff --git a/lib/Client/IdentifierMode.php b/lib/Client/IdentifierMode.php deleted file mode 100644 index de086e4..0000000 --- a/lib/Client/IdentifierMode.php +++ /dev/null @@ -1,16 +0,0 @@ -identifierMode; } - public function toCommand(): string - { - return $this->identifierMode->toCommand(); - } - private static function coerceSequenceSet(int|string|SequenceSet $target): SequenceSet { return match (true) { diff --git a/lib/Client/SearchCriteriaBuilder.php b/lib/Client/Protocol/Command/Argument/SearchCriteriaBuilder.php similarity index 98% rename from lib/Client/SearchCriteriaBuilder.php rename to lib/Client/Protocol/Command/Argument/SearchCriteriaBuilder.php index 6aa912d..705e204 100644 --- a/lib/Client/SearchCriteriaBuilder.php +++ b/lib/Client/Protocol/Command/Argument/SearchCriteriaBuilder.php @@ -2,7 +2,9 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client; +namespace KTXM\ProviderImap\Client\Protocol\Command\Argument; + +use KTXM\ProviderImap\Client\Protocol\SequenceSet; use DateTimeInterface; use InvalidArgumentException; diff --git a/lib/Client/Command/CapabilityCommand.php b/lib/Client/Protocol/Command/CapabilityCommand.php similarity index 88% rename from lib/Client/Command/CapabilityCommand.php rename to lib/Client/Protocol/Command/CapabilityCommand.php index b052586..14b86a9 100644 --- a/lib/Client/Command/CapabilityCommand.php +++ b/lib/Client/Protocol/Command/CapabilityCommand.php @@ -2,16 +2,16 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CapabilityResult; +use KTXM\ProviderImap\Client\Result\CapabilityResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/CommandInterface.php b/lib/Client/Protocol/Command/CommandInterface.php similarity index 77% rename from lib/Client/Command/CommandInterface.php rename to lib/Client/Protocol/Command/CommandInterface.php index 472a66f..9cad50d 100644 --- a/lib/Client/Command/CommandInterface.php +++ b/lib/Client/Protocol/Command/CommandInterface.php @@ -2,12 +2,12 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @template TResult diff --git a/lib/Client/Command/CopyCommand.php b/lib/Client/Protocol/Command/CopyCommand.php similarity index 74% rename from lib/Client/Command/CopyCommand.php rename to lib/Client/Protocol/Command/CopyCommand.php index a0ce31d..d933b48 100644 --- a/lib/Client/Command/CopyCommand.php +++ b/lib/Client/Protocol/Command/CopyCommand.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\MessageTransferResult; -use KTXM\ProviderImap\Client\FetchTarget; +use KTXM\ProviderImap\Client\Result\MessageTransferResult; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SequenceSet; -use KTXM\ProviderImap\Client\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SequenceSet; +use KTXM\ProviderImap\Client\Protocol\SessionContext; /** * @implements CommandInterface @@ -19,7 +19,7 @@ final class CopyCommand implements CommandInterface private readonly MessageTransferCommand $command; public function __construct( - FetchTarget|string|SequenceSet|null $target = null, + MessageTarget|string|SequenceSet|null $target = null, string $destinationMailbox = '', ) { $this->command = new MessageTransferCommand('COPY', $target, $destinationMailbox); diff --git a/lib/Client/Command/CreateCommand.php b/lib/Client/Protocol/Command/CreateCommand.php similarity index 88% rename from lib/Client/Command/CreateCommand.php rename to lib/Client/Protocol/Command/CreateCommand.php index 7427387..c64c2ca 100644 --- a/lib/Client/Command/CreateCommand.php +++ b/lib/Client/Protocol/Command/CreateCommand.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/DeleteCommand.php b/lib/Client/Protocol/Command/DeleteCommand.php similarity index 88% rename from lib/Client/Command/DeleteCommand.php rename to lib/Client/Protocol/Command/DeleteCommand.php index 4dfcd29..6f104df 100644 --- a/lib/Client/Command/DeleteCommand.php +++ b/lib/Client/Protocol/Command/DeleteCommand.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/ExpungeCommand.php b/lib/Client/Protocol/Command/ExpungeCommand.php similarity index 81% rename from lib/Client/Command/ExpungeCommand.php rename to lib/Client/Protocol/Command/ExpungeCommand.php index a5ccec7..6e67a43 100644 --- a/lib/Client/Command/ExpungeCommand.php +++ b/lib/Client/Protocol/Command/ExpungeCommand.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\FetchTarget; -use KTXM\ProviderImap\Client\IdentifierMode; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SequenceSet; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SequenceSet; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface> @@ -22,7 +22,7 @@ final class ExpungeCommand implements CommandInterface { private readonly ?SequenceSet $sequenceSet; - public function __construct(FetchTarget|string|SequenceSet|null $target = null) + public function __construct(MessageTarget|string|SequenceSet|null $target = null) { if ($target === null) { $this->sequenceSet = null; @@ -31,9 +31,9 @@ final class ExpungeCommand implements CommandInterface } $resolvedTarget = match (true) { - $target instanceof FetchTarget => $target, - $target instanceof SequenceSet => FetchTarget::sequence($target), - is_string($target) => FetchTarget::sequence($target), + $target instanceof MessageTarget => $target, + $target instanceof SequenceSet => MessageTarget::sequence($target), + is_string($target) => MessageTarget::sequence($target), default => null, }; diff --git a/lib/Client/Command/FetchManyCommand.php b/lib/Client/Protocol/Command/FetchManyCommand.php similarity index 57% rename from lib/Client/Command/FetchManyCommand.php rename to lib/Client/Protocol/Command/FetchManyCommand.php index 4c38cef..eb7d658 100644 --- a/lib/Client/Command/FetchManyCommand.php +++ b/lib/Client/Protocol/Command/FetchManyCommand.php @@ -2,34 +2,37 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; + +use KTXM\ProviderImap\Client\Protocol\Parser\FetchResponseParser; use Generator; -use KTXM\ProviderImap\Client\FetchTarget; -use KTXM\ProviderImap\Client\FetchOptions; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\FetchOptions; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Message; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SequenceSet; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SequenceSet; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface> */ final class FetchManyCommand implements CommandInterface { - private readonly FetchTarget $target; + private readonly MessageTarget $target; private readonly FetchOptions $options; - public function __construct(FetchTarget|string|SequenceSet|null $target = null, ?FetchOptions $options = null) + public function __construct(MessageTarget|string|SequenceSet|null $target = null, ?FetchOptions $options = null) { $this->target = match (true) { - $target instanceof FetchTarget => $target, - $target instanceof SequenceSet => FetchTarget::sequence($target), - is_string($target) => FetchTarget::sequence($target), - default => FetchTarget::all(), + $target instanceof MessageTarget => $target, + $target instanceof SequenceSet => MessageTarget::sequence($target), + is_string($target) => MessageTarget::sequence($target), + default => MessageTarget::all(), }; $this->options = $options ?? FetchOptions::default(); } @@ -50,7 +53,7 @@ final class FetchManyCommand implements CommandInterface return new RequestFrame(sprintf( '%s %s (%s)', - $this->target->toCommand(), + $this->target->identifierMode() === IdentifierMode::Uid ? 'UID FETCH' : 'FETCH', $this->target->sequenceSet()->toCommand(), $this->options->toCommand(), )); diff --git a/lib/Client/Command/FetchOneCommand.php b/lib/Client/Protocol/Command/FetchOneCommand.php similarity index 62% rename from lib/Client/Command/FetchOneCommand.php rename to lib/Client/Protocol/Command/FetchOneCommand.php index 60cb278..38edd7b 100644 --- a/lib/Client/Command/FetchOneCommand.php +++ b/lib/Client/Protocol/Command/FetchOneCommand.php @@ -2,30 +2,33 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\FetchTarget; -use KTXM\ProviderImap\Client\FetchOptions; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; + +use KTXM\ProviderImap\Client\Protocol\Parser\FetchResponseParser; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\FetchOptions; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Message; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface */ final class FetchOneCommand implements CommandInterface { - private readonly FetchTarget $target; + private readonly MessageTarget $target; private readonly FetchOptions $options; - public function __construct(FetchTarget|int|string $target, ?FetchOptions $options = null) + public function __construct(MessageTarget|int|string $target, ?FetchOptions $options = null) { - $this->target = $target instanceof FetchTarget + $this->target = $target instanceof MessageTarget ? $target - : FetchTarget::sequence($target); + : MessageTarget::sequence($target); $this->options = $options ?? FetchOptions::default(); } @@ -45,7 +48,7 @@ final class FetchOneCommand implements CommandInterface return new RequestFrame(sprintf( '%s %s (%s)', - $this->target->toCommand(), + $this->target->identifierMode() === IdentifierMode::Uid ? 'UID FETCH' : 'FETCH', $this->target->sequenceSet()->toCommand(), $this->options->toCommand(), )); diff --git a/lib/Client/Command/ListCommand.php b/lib/Client/Protocol/Command/ListCommand.php similarity index 95% rename from lib/Client/Command/ListCommand.php rename to lib/Client/Protocol/Command/ListCommand.php index cef1828..765bea9 100644 --- a/lib/Client/Command/ListCommand.php +++ b/lib/Client/Protocol/Command/ListCommand.php @@ -2,19 +2,20 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; +use KTXM\ProviderImap\Client\Protocol\Parser\StatusResponseParser; use Generator; use KTXM\ProviderImap\Client\ImapException; -use KTXM\ProviderImap\Client\ListReturnOptions; -use KTXM\ProviderImap\Client\ListSelectionOptions; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\ListReturnOptions; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\ListSelectionOptions; use KTXM\ProviderImap\Client\Mailbox; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface> diff --git a/lib/Client/Command/LoginCommand.php b/lib/Client/Protocol/Command/LoginCommand.php similarity index 88% rename from lib/Client/Command/LoginCommand.php rename to lib/Client/Protocol/Command/LoginCommand.php index 45fddce..14aa885 100644 --- a/lib/Client/Command/LoginCommand.php +++ b/lib/Client/Protocol/Command/LoginCommand.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/LogoutCommand.php b/lib/Client/Protocol/Command/LogoutCommand.php similarity index 87% rename from lib/Client/Command/LogoutCommand.php rename to lib/Client/Protocol/Command/LogoutCommand.php index 5d54f42..c933024 100644 --- a/lib/Client/Command/LogoutCommand.php +++ b/lib/Client/Protocol/Command/LogoutCommand.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/MessageTransferCommand.php b/lib/Client/Protocol/Command/MessageTransferCommand.php similarity index 90% rename from lib/Client/Command/MessageTransferCommand.php rename to lib/Client/Protocol/Command/MessageTransferCommand.php index 52d351e..9e9e658 100644 --- a/lib/Client/Command/MessageTransferCommand.php +++ b/lib/Client/Protocol/Command/MessageTransferCommand.php @@ -2,19 +2,19 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\MessageTransferResult; -use KTXM\ProviderImap\Client\FetchTarget; -use KTXM\ProviderImap\Client\IdentifierMode; +use KTXM\ProviderImap\Client\Result\MessageTransferResult; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SequenceSet; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SequenceSet; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface @@ -27,14 +27,14 @@ final class MessageTransferCommand implements CommandInterface public function __construct( string $operation, - FetchTarget|string|SequenceSet|null $target = null, + MessageTarget|string|SequenceSet|null $target = null, private readonly string $destinationMailbox = '', ) { $resolvedTarget = match (true) { - $target instanceof FetchTarget => $target, - $target instanceof SequenceSet => FetchTarget::sequence($target), - is_string($target) => FetchTarget::sequence($target), - default => FetchTarget::all(), + $target instanceof MessageTarget => $target, + $target instanceof SequenceSet => MessageTarget::sequence($target), + is_string($target) => MessageTarget::sequence($target), + default => MessageTarget::all(), }; $this->operation = strtoupper(trim($operation)); diff --git a/lib/Client/Command/MoveCommand.php b/lib/Client/Protocol/Command/MoveCommand.php similarity index 74% rename from lib/Client/Command/MoveCommand.php rename to lib/Client/Protocol/Command/MoveCommand.php index ee0a1c0..ccd95a0 100644 --- a/lib/Client/Command/MoveCommand.php +++ b/lib/Client/Protocol/Command/MoveCommand.php @@ -2,14 +2,14 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\MessageTransferResult; -use KTXM\ProviderImap\Client\FetchTarget; +use KTXM\ProviderImap\Client\Result\MessageTransferResult; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SequenceSet; -use KTXM\ProviderImap\Client\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SequenceSet; +use KTXM\ProviderImap\Client\Protocol\SessionContext; /** * @implements CommandInterface @@ -19,7 +19,7 @@ final class MoveCommand implements CommandInterface private readonly MessageTransferCommand $command; public function __construct( - FetchTarget|string|SequenceSet|null $target = null, + MessageTarget|string|SequenceSet|null $target = null, string $destinationMailbox = '', ) { $this->command = new MessageTransferCommand('MOVE', $target, $destinationMailbox); diff --git a/lib/Client/Command/NoopCommand.php b/lib/Client/Protocol/Command/NoopCommand.php similarity index 86% rename from lib/Client/Command/NoopCommand.php rename to lib/Client/Protocol/Command/NoopCommand.php index 7268bf7..09f9a73 100644 --- a/lib/Client/Command/NoopCommand.php +++ b/lib/Client/Protocol/Command/NoopCommand.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/RenameCommand.php b/lib/Client/Protocol/Command/RenameCommand.php similarity index 89% rename from lib/Client/Command/RenameCommand.php rename to lib/Client/Protocol/Command/RenameCommand.php index 1a29929..e04b1a4 100644 --- a/lib/Client/Command/RenameCommand.php +++ b/lib/Client/Protocol/Command/RenameCommand.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/SearchCommand.php b/lib/Client/Protocol/Command/SearchCommand.php similarity index 90% rename from lib/Client/Command/SearchCommand.php rename to lib/Client/Protocol/Command/SearchCommand.php index 612ad13..54f15bf 100644 --- a/lib/Client/Command/SearchCommand.php +++ b/lib/Client/Protocol/Command/SearchCommand.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\SearchResult; -use KTXM\ProviderImap\Client\IdentifierMode; +use KTXM\ProviderImap\Client\Result\SearchResult; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; use KTXM\ProviderImap\Client\ImapException; -use KTXM\ProviderImap\Client\SearchCriteriaBuilder; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\SearchCriteriaBuilder; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/SelectCommand.php b/lib/Client/Protocol/Command/SelectCommand.php similarity index 95% rename from lib/Client/Command/SelectCommand.php rename to lib/Client/Protocol/Command/SelectCommand.php index 8e28cb1..a3dc846 100644 --- a/lib/Client/Command/SelectCommand.php +++ b/lib/Client/Protocol/Command/SelectCommand.php @@ -2,7 +2,7 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Mailbox; @@ -10,8 +10,8 @@ use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/SortCommand.php b/lib/Client/Protocol/Command/SortCommand.php similarity index 92% rename from lib/Client/Command/SortCommand.php rename to lib/Client/Protocol/Command/SortCommand.php index 1758868..3d66ddd 100644 --- a/lib/Client/Command/SortCommand.php +++ b/lib/Client/Protocol/Command/SortCommand.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\SortResult; -use KTXM\ProviderImap\Client\IdentifierMode; +use KTXM\ProviderImap\Client\Result\SortResult; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SearchCriteriaBuilder; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\SearchCriteriaBuilder; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/StartTlsCommand.php b/lib/Client/Protocol/Command/StartTlsCommand.php similarity index 86% rename from lib/Client/Command/StartTlsCommand.php rename to lib/Client/Protocol/Command/StartTlsCommand.php index 7dcfad6..bcc1b9b 100644 --- a/lib/Client/Command/StartTlsCommand.php +++ b/lib/Client/Protocol/Command/StartTlsCommand.php @@ -2,15 +2,15 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/StatusCommand.php b/lib/Client/Protocol/Command/StatusCommand.php similarity index 91% rename from lib/Client/Command/StatusCommand.php rename to lib/Client/Protocol/Command/StatusCommand.php index 09a99ad..68470f8 100644 --- a/lib/Client/Command/StatusCommand.php +++ b/lib/Client/Protocol/Command/StatusCommand.php @@ -2,16 +2,17 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\StatusResult; +use KTXM\ProviderImap\Client\Protocol\Parser\StatusResponseParser; +use KTXM\ProviderImap\Client\Result\StatusResult; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface diff --git a/lib/Client/Command/StoreCommand.php b/lib/Client/Protocol/Command/StoreCommand.php similarity index 80% rename from lib/Client/Command/StoreCommand.php rename to lib/Client/Protocol/Command/StoreCommand.php index 9187c8b..32fd15a 100644 --- a/lib/Client/Command/StoreCommand.php +++ b/lib/Client/Protocol/Command/StoreCommand.php @@ -2,18 +2,18 @@ declare(strict_types=1); -namespace KTXM\ProviderImap\Client\Command; +namespace KTXM\ProviderImap\Client\Protocol\Command; -use KTXM\ProviderImap\Client\Command\Result\CommandStatusResult; -use KTXM\ProviderImap\Client\FetchTarget; -use KTXM\ProviderImap\Client\IdentifierMode; +use KTXM\ProviderImap\Client\Result\CommandStatusResult; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\RequestFrame; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\ResponseStream; -use KTXM\ProviderImap\Client\SequenceSet; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SequenceSet; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; /** * @implements CommandInterface @@ -27,16 +27,16 @@ final class StoreCommand implements CommandInterface * @param list $flags */ public function __construct( - FetchTarget|string|SequenceSet|null $target = null, + MessageTarget|string|SequenceSet|null $target = null, private array $flags = [], private string $action = '', private bool $silent = true, ) { $resolvedTarget = match (true) { - $target instanceof FetchTarget => $target, - $target instanceof SequenceSet => FetchTarget::sequence($target), - is_string($target) => FetchTarget::sequence($target), - default => FetchTarget::all(), + $target instanceof MessageTarget => $target, + $target instanceof SequenceSet => MessageTarget::sequence($target), + is_string($target) => MessageTarget::sequence($target), + default => MessageTarget::all(), }; $normalizedAction = trim($this->action); diff --git a/lib/Client/Protocol/CommandExecutor.php b/lib/Client/Protocol/CommandExecutor.php index 582a77a..a7276a0 100644 --- a/lib/Client/Protocol/CommandExecutor.php +++ b/lib/Client/Protocol/CommandExecutor.php @@ -5,14 +5,14 @@ declare(strict_types=1); namespace KTXM\ProviderImap\Client\Protocol; use Generator; -use KTXM\ProviderImap\Client\Command\CommandInterface; -use KTXM\ProviderImap\Client\FetchTarget; +use KTXM\ProviderImap\Client\Protocol\Command\CommandInterface; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; use KTXM\ProviderImap\Client\ImapException; use KTXM\ProviderImap\Client\Protocol\Response\TaggedResponse; use KTXM\ProviderImap\Client\Protocol\Response\UntaggedResponse; use KTXM\ProviderImap\Client\Protocol\RequestFrame; -use KTXM\ProviderImap\Client\SessionContext; -use KTXM\ProviderImap\Client\SessionState; +use KTXM\ProviderImap\Client\Protocol\SessionContext; +use KTXM\ProviderImap\Client\Protocol\SessionState; use Psr\Log\LoggerInterface; final class CommandExecutor @@ -62,7 +62,7 @@ final class CommandExecutor * * @return \Generator raw (transfer-encoded) bytes from the socket */ - public function download(FetchTarget $target, string $section, int $chunkSize, SessionContext $context): \Generator + public function download(MessageTarget $target, string $section, int $chunkSize, SessionContext $context): \Generator { $this->assertState([SessionState::Selected], $context->state(), 'FETCH (download)'); diff --git a/lib/Client/Protocol/IdentifierMode.php b/lib/Client/Protocol/IdentifierMode.php new file mode 100644 index 0000000..7fefe30 --- /dev/null +++ b/lib/Client/Protocol/IdentifierMode.php @@ -0,0 +1,11 @@ +messageList( $mailboxName, - FetchTarget::sequence(SequenceSet::range($startSequence, $totalMessages)), + MessageTarget::sequence(SequenceSet::range($startSequence, $totalMessages)), FetchOptions::message(), ) as $message) { $messageRows[] = [ diff --git a/lib/Service/Remote/RemoteMailService.php b/lib/Service/Remote/RemoteMailService.php index 7129a2b..5ad3737 100644 --- a/lib/Service/Remote/RemoteMailService.php +++ b/lib/Service/Remote/RemoteMailService.php @@ -13,32 +13,32 @@ use DateTimeImmutable; use Generator; use KTXC\Logger\PlainFileLogger; use KTXM\ProviderImap\Client\Client as ImapClient; -use KTXM\ProviderImap\Client\Command\AppendCommand; -use KTXM\ProviderImap\Client\Command\FetchManyCommand; -use KTXM\ProviderImap\Client\Command\FetchOneCommand; -use KTXM\ProviderImap\Client\Command\ExpungeCommand; -use KTXM\ProviderImap\Client\Command\ListCommand; -use KTXM\ProviderImap\Client\Command\SearchCommand; -use KTXM\ProviderImap\Client\Command\SelectCommand; -use KTXM\ProviderImap\Client\Command\SortCommand; -use KTXM\ProviderImap\Client\Command\StatusCommand; -use KTXM\ProviderImap\Client\Command\StoreCommand; -use KTXM\ProviderImap\Client\Command\CopyCommand; -use KTXM\ProviderImap\Client\Command\CreateCommand; -use KTXM\ProviderImap\Client\Command\RenameCommand; -use KTXM\ProviderImap\Client\Command\DeleteCommand; -use KTXM\ProviderImap\Client\FetchTarget; -use KTXM\ProviderImap\Client\FetchOptions; -use KTXM\ProviderImap\Client\IdentifierMode; +use KTXM\ProviderImap\Client\Protocol\Command\AppendCommand; +use KTXM\ProviderImap\Client\Protocol\Command\FetchManyCommand; +use KTXM\ProviderImap\Client\Protocol\Command\FetchOneCommand; +use KTXM\ProviderImap\Client\Protocol\Command\ExpungeCommand; +use KTXM\ProviderImap\Client\Protocol\Command\ListCommand; +use KTXM\ProviderImap\Client\Protocol\Command\SearchCommand; +use KTXM\ProviderImap\Client\Protocol\Command\SelectCommand; +use KTXM\ProviderImap\Client\Protocol\Command\SortCommand; +use KTXM\ProviderImap\Client\Protocol\Command\StatusCommand; +use KTXM\ProviderImap\Client\Protocol\Command\StoreCommand; +use KTXM\ProviderImap\Client\Protocol\Command\CopyCommand; +use KTXM\ProviderImap\Client\Protocol\Command\CreateCommand; +use KTXM\ProviderImap\Client\Protocol\Command\RenameCommand; +use KTXM\ProviderImap\Client\Protocol\Command\DeleteCommand; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\MessageTarget; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\FetchOptions; +use KTXM\ProviderImap\Client\Protocol\IdentifierMode; use KTXM\ProviderImap\Client\ImapException; -use KTXM\ProviderImap\Client\ListReturnOptions; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\ListReturnOptions; use KTXM\ProviderImap\Client\Mailbox; use KTXM\ProviderImap\Client\Message; use KTXM\ProviderImap\Client\MessageAddress; use KTXM\ProviderImap\Client\MessagePart; -use KTXM\ProviderImap\Client\Command\MoveCommand; -use KTXM\ProviderImap\Client\SearchCriteriaBuilder; -use KTXM\ProviderImap\Client\SequenceSet; +use KTXM\ProviderImap\Client\Protocol\Command\MoveCommand; +use KTXM\ProviderImap\Client\Protocol\Command\Argument\SearchCriteriaBuilder; +use KTXM\ProviderImap\Client\Protocol\SequenceSet; use KTXF\Mail\Collection\CollectionRoles; use KTXF\Resource\Filter\IFilter; use KTXF\Resource\Filter\FilterComparisonOperator; @@ -327,7 +327,7 @@ class RemoteMailService } yield from $this->imapClient()->perform(new FetchManyCommand( - FetchTarget::all(), + MessageTarget::all(), $options, )); @@ -360,7 +360,7 @@ class RemoteMailService $this->imapClient()->perform(new SelectCommand($collection, true)); $request = new FetchManyCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $options, ); @@ -392,7 +392,7 @@ class RemoteMailService } else { // Fetch BODYSTRUCTURE first to determine metadata (no body bytes transferred) $message = $this->imapClient()->perform(new FetchOneCommand( - FetchTarget::uid(SequenceSet::items($uid)), + MessageTarget::uid(SequenceSet::items($uid)), FetchOptions::of('BODYSTRUCTURE'), )); $bodyStructure = $message->bodyStructure(); @@ -407,7 +407,7 @@ class RemoteMailService // Start download stream $stream = $this->decodeStream( - $this->imapClient()->download(FetchTarget::uid(SequenceSet::items($uid)), $partId ?? ''), + $this->imapClient()->download(MessageTarget::uid(SequenceSet::items($uid)), $partId ?? ''), $encoding ); @@ -543,7 +543,7 @@ class RemoteMailService $this->imapClient()->perform(new SelectCommand($collection, false)); $this->imapClient()->perform(new StoreCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $flags, $action, )); @@ -558,7 +558,7 @@ class RemoteMailService return []; } - $target = FetchTarget::uid(SequenceSet::items(...array_values($uids))); + $target = MessageTarget::uid(SequenceSet::items(...array_values($uids))); $this->imapClient()->perform(new SelectCommand($collection, false)); $this->imapClient()->perform(new StoreCommand($target, ['\\Deleted'], '+')); @@ -581,7 +581,7 @@ class RemoteMailService if (!empty($flagsToAdd)) { $this->imapClient()->perform(new StoreCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $flagsToAdd, '+', )); @@ -589,7 +589,7 @@ class RemoteMailService if (!empty($flagsToRemove)) { $this->imapClient()->perform(new StoreCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $flagsToRemove, '-', )); @@ -608,23 +608,23 @@ class RemoteMailService if ($rfc6851) { $this->imapClient()->perform(new SelectCommand($sourceCollection, false)); $response = $this->imapClient()->perform(new MoveCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $targetCollection, )); } else { $this->imapClient()->perform(new SelectCommand($sourceCollection, false)); $response = $this->imapClient()->perform(new CopyCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $targetCollection, )); if ($response->isOk()) { $this->imapClient()->perform(new StoreCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), ['\\Deleted'], '+', )); $this->imapClient()->perform(new ExpungeCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), )); } } @@ -656,7 +656,7 @@ class RemoteMailService $this->imapClient()->perform(new SelectCommand($sourceCollection, false)); $response = $this->imapClient()->perform(new CopyCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $targetCollection, )); @@ -881,7 +881,7 @@ class RemoteMailService } $messages = iterator_to_array($this->imapClient()->perform(new FetchManyCommand( - FetchTarget::uid(SequenceSet::items(...array_values($uids))), + MessageTarget::uid(SequenceSet::items(...array_values($uids))), $options, )));