Skip to content
This repository has been archived by the owner on Dec 5, 2023. It is now read-only.

Commit

Permalink
Start enthusiasticly fleshing the API
Browse files Browse the repository at this point in the history
  • Loading branch information
ConradIrwin committed Apr 14, 2011
1 parent 9f4ae60 commit 2cf31f4
Showing 1 changed file with 54 additions and 4 deletions.
58 changes: 54 additions & 4 deletions lib/imap.rb
Expand Up @@ -10,10 +10,57 @@ def initialize(connection)
@connection = connection
end

def disconnect
@connection.close_connection
end

## 6.1 Client commands - any state.

def capability
one_data_response("CAPABILITY")
end

def noop
tagged_response("NOOP")
end

# Logout and close the connection.
def logout
tagged_response("LOGOUT").errback do |e|
if e.is_a? Net::IMAP::ByeResponseError
# RFC 3501 says the server MUST send a BYE response and then close the connection.
disconnect
succeed
end
end.callback do |response|
fail Net::IMAP::ResponseParseError.new("Received the wrong response to LOGOUT: #{response}")
end
end

## 6.2 Client commands - "Not authenticated" state

def starttls
raise NotImplementedError
end

def authenticate(auth_type, *args)
auth_type = auth_type.upcase
raise "bleargh"
end


def create(mailbox)
tagged_response("CREATE")
end

def delete(mailbox)
tagged_response("DELETE")
end

def examine(mailbox)
tagged_response("EXAMINE")
end

def login(username, password)
tagged_response("LOGIN", username, password)
end
Expand All @@ -22,14 +69,17 @@ def logout
tagged_response("LOGOUT")
end

def noop
tagged_response("NOOP")
end

def select(mailbox)
tagged_response("SELECT", mailbox)
end

def subscribe(mailbox)
send_command("SUBSCRIBE", mailbox)
end

def rename(mailbox, newname)
tagged_response("RENAME", mailbox, newname)
end

private

Expand Down

0 comments on commit 2cf31f4

Please sign in to comment.