From fdf2b7dfc34dc7965b3512177bca90a5c1518f84 Mon Sep 17 00:00:00 2001 From: nick evans Date: Mon, 19 Dec 2022 09:52:06 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=8E=A8=20Move=20response=20handlers=20aft?= =?UTF-8?q?er=20IMAP=20commands?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/net/imap.rb | 44 ++++++++++++++++++++++---------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 5cc9fa81..fab9e62b 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -1850,28 +1850,6 @@ def uid_sort(sort_keys, search_keys, charset) return sort_internal("UID SORT", sort_keys, search_keys, charset) end - # Adds a response handler. For example, to detect when - # the server sends a new EXISTS response (which normally - # indicates new messages being added to the mailbox), - # add the following handler after selecting the - # mailbox: - # - # imap.add_response_handler { |resp| - # if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS" - # puts "Mailbox now has #{resp.data} messages" - # end - # } - # - def add_response_handler(handler = nil, &block) - raise ArgumentError, "two Procs are passed" if handler && block - @response_handlers.push(block || handler) - end - - # Removes the response handler. - def remove_response_handler(handler) - @response_handlers.delete(handler) - end - # Sends a {THREAD command [RFC5256 ยง3]}[https://www.rfc-editor.org/rfc/rfc5256#section-3] # to search a mailbox and return message sequence numbers in threaded # format, as a ThreadMember tree. +search_keys+ are interpreted the same as @@ -1975,6 +1953,28 @@ def idle_done end end + # Adds a response handler. For example, to detect when + # the server sends a new EXISTS response (which normally + # indicates new messages being added to the mailbox), + # add the following handler after selecting the + # mailbox: + # + # imap.add_response_handler { |resp| + # if resp.kind_of?(Net::IMAP::UntaggedResponse) and resp.name == "EXISTS" + # puts "Mailbox now has #{resp.data} messages" + # end + # } + # + def add_response_handler(handler = nil, &block) + raise ArgumentError, "two Procs are passed" if handler && block + @response_handlers.push(block || handler) + end + + # Removes the response handler. + def remove_response_handler(handler) + @response_handlers.delete(handler) + end + private CRLF = "\r\n" # :nodoc: