-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
94 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import Foundation | ||
import NIOIMAPCore | ||
|
||
/** | ||
Command to unselect the currently selected mailbox without expunging deleted messages | ||
|
||
The UNSELECT command is an extension to the core IMAP protocol defined in RFC 3691. | ||
It allows a client to deselect the current mailbox without implicitly causing an expunge | ||
of messages marked for deletion, as the CLOSE command does. | ||
*/ | ||
public struct UnselectCommand: IMAPCommand { | ||
public typealias ResultType = Void | ||
public typealias HandlerType = UnselectHandler | ||
|
||
public var handlerType: HandlerType.Type { | ||
return UnselectHandler.self | ||
} | ||
|
||
public init() {} | ||
|
||
public func validate() throws { | ||
// No validation needed for UNSELECT command | ||
} | ||
|
||
public func toTaggedCommand(tag: String) -> TaggedCommand { | ||
// Using a raw string command since UNSELECT is not in the standard Command enum | ||
// The UNSELECT command takes no parameters | ||
return TaggedCommand(tag: tag, command: .unselect) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
import Foundation | ||
import NIOIMAPCore | ||
import NIO | ||
import Logging | ||
|
||
/** | ||
Handler for the UNSELECT command | ||
|
||
This handler processes responses from the IMAP server to the UNSELECT command. | ||
The UNSELECT command is an extension to IMAP defined in RFC 3691 that allows | ||
a client to deselect the current mailbox without expunging deleted messages. | ||
*/ | ||
public final class UnselectHandler: BaseIMAPCommandHandler<Void>, IMAPCommandHandler { | ||
public typealias ResultType = Void | ||
public typealias InboundIn = Response | ||
public typealias InboundOut = Never | ||
|
||
override public func processResponse(_ response: Response) -> Bool { | ||
// Call the base class implementation to buffer the response | ||
let handled = super.processResponse(response) | ||
|
||
// Process the response | ||
if case .tagged(let tagged) = response, tagged.tag == commandTag { | ||
// This is our tagged response, handle it | ||
switch tagged.state { | ||
case .ok: | ||
// UNSELECT succeeded | ||
succeedWithResult(()) | ||
case .no(let text): | ||
// UNSELECT failed with NO response | ||
failWithError(IMAPError.commandFailed("NO response: \(text)")) | ||
case .bad(let text): | ||
// UNSELECT failed with BAD response (likely not supported) | ||
failWithError(IMAPError.commandFailed("BAD response: \(text)")) | ||
} | ||
return true | ||
} | ||
|
||
return handled | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters