end
def handle_tagged_response(resp, req)
- return unless req.is_a?(LoginRequest)
-
- case resp.status
- when :ok
- @state = :logged_in
-
- @mboxes.each { |mb| query_status(mb) }
- else
- raise(LoginError, "cannot login - #{resp.data}")
+ case req
+ when LoginRequest
+ case resp.status
+ when :ok
+ @state = :logged_in
+
+ @mboxes.each { |mb| query_status(mb) }
+ else
+ raise(LoginError, "cannot login - #{resp.data}")
+ end
+ when StatusRequest
+ @mboxes.delete(req.mailbox)
+
+ if @mboxes.empty?
+ @status = :done
+ logout
+ end
end
end
name, count = md.captures.first, md.captures.last.to_i
MailboxStatusEvent.raise(name, count)
- @mboxes.delete(name)
-
- if @mboxes.empty?
- @status = :done
- logout
- end
end
end
end
class StatusRequest < Request
+ attr_reader :mailbox
+
def initialize(session, mailbox)
super(session)