diff options
author | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-07-30 02:15:13 +0000 |
---|---|---|
committer | shugo <shugo@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2001-07-30 02:15:13 +0000 |
commit | 67d433a5e62fdbfa73f688c59af111bd67aefa24 (patch) | |
tree | 0485a95dd1034c4a4aaefd2ef01a742bc478407c /lib/net | |
parent | 0abedcd80770841475006342c96d348d78f91ab8 (diff) | |
download | ruby-67d433a5e62fdbfa73f688c59af111bd67aefa24.tar.gz |
* lib/net/imap.rb: added new commands for managing folder quotas
and folder ACLs.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@1654 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/net')
-rw-r--r-- | lib/net/imap.rb | 79 |
1 files changed, 79 insertions, 0 deletions
diff --git a/lib/net/imap.rb b/lib/net/imap.rb index 371fca1024..8445e2cda8 100644 --- a/lib/net/imap.rb +++ b/lib/net/imap.rb @@ -796,6 +796,29 @@ module Net end end + def getquota(mailbox) + synchronize do + send_command("GETQUOTA", mailbox) + return @responses.delete("QUOTA") + end + end + + def setquota(mailbox, quota) + data = '(STORAGE ' + quota.to_s + ')' + send_command("SETQUOTA", mailbox, RawData.new(data)) + end + + def setacl(mailbox, user, acl) + send_command("SETACL", mailbox, user, acl) + end + + def getacl(mailbox) + synchronize do + send_command("GETACL", mailbox) + return @responses.delete("ACL")[-1] + end + end + def lsub(refname, mailbox) synchronize do send_command("LSUB", refname, mailbox) @@ -1237,6 +1260,7 @@ module Net ResponseText = Struct.new(:code, :text) ResponseCode = Struct.new(:name, :data) MailboxList = Struct.new(:attr, :delim, :name) + MailboxQuota = Struct.new(:mailbox, :usage, :quota) StatusData = Struct.new(:mailbox, :attr) FetchData = Struct.new(:seqno, :attr) Envelope = Struct.new(:date, :subject, :from, :sender, :reply_to, @@ -1418,6 +1442,10 @@ module Net return flags_response when /\A(?:LIST|LSUB)\z/ni return list_response + when /\A(?:QUOTA)\z/ni + return getquota_response + when /\A(?:ACL)\z/ni + return getacl_response when /\A(?:SEARCH|SORT)\z/ni return search_response when /\A(?:STATUS)\z/ni @@ -1946,6 +1974,57 @@ module Net return MailboxList.new(attr, delim, name) end + def getquota_response + # If no quota set, get back + # `NO Quota root does not exist'. + token = match(T_ATOM) + name = token.value.upcase + match(T_SPACE) + token = match(T_ATOM) + mailbox = token.value + match(T_SPACE) + match(T_LPAR) + match(T_ATOM) + match(T_SPACE) + token = match(T_NUMBER) + usage = token.value + match(T_SPACE) + token = match(T_NUMBER) + quota = token.value + match(T_RPAR) + data = MailboxQuota.new(mailbox, usage, quota) + return UntaggedResponse.new(name, data, @str) + end + + def getacl_response + token = match(T_ATOM) + name = token.value.upcase + match(T_SPACE) + token = match(T_ATOM) + mailbox = token.value + token = lookahead + if token.symbol == T_SPACE + shift_token + data = [] + while true + token = lookahead + case token.symbol + when T_CRLF + break + when T_SPACE + shift_token + end + user = astring + match(T_SPACE) + acl = astring + data.push([user, acl]) + end + else + data = [] + end + return UntaggedResponse.new(name, data, @str) + end + def search_response token = match(T_ATOM) name = token.value.upcase |