[前][次][番号順一覧][スレッド一覧]

ruby-changes:18087

From: shugo <ko1@a...>
Date: Tue, 7 Dec 2010 17:07:42 +0900 (JST)
Subject: [ruby-changes:18087] Ruby:r30108 (trunk): * lib/net/imap.rb (xlist): supported the XLIST command, which is an

shugo	2010-12-07 17:07:12 +0900 (Tue, 07 Dec 2010)

  New Revision: 30108

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=30108

  Log:
    * lib/net/imap.rb (xlist): supported the XLIST command, which is an
      extension by Apple and Google.  patch by Geoff Youngs.
      [ruby-core:33521]

  Modified files:
    trunk/ChangeLog
    trunk/lib/net/imap.rb
    trunk/test/net/imap/test_imap_response_parser.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 30107)
+++ ChangeLog	(revision 30108)
@@ -1,3 +1,9 @@
+Tue Dec  7 17:03:16 2010  Shugo Maeda  <shugo@r...>
+
+	* lib/net/imap.rb (xlist): supported the XLIST command, which is an
+	  extension by Apple and Google.  patch by Geoff Youngs.
+	  [ruby-core:33521]
+
 Tue Dec  7 08:00:44 2010  Nobuyoshi Nakada  <nobu@r...>
 
 	* configure.in, win32/Makefile.sub (WERRORFLAG): flag to treat
Index: lib/net/imap.rb
===================================================================
--- lib/net/imap.rb	(revision 30107)
+++ lib/net/imap.rb	(revision 30108)
@@ -528,6 +528,38 @@
       end
     end
 
+    # Sends a XLIST command, and returns a subset of names from
+    # the complete set of all names available to the client.
+    # +refname+ provides a context (for instance, a base directory
+    # in a directory-based mailbox hierarchy).  +mailbox+ specifies
+    # a mailbox or (via wildcards) mailboxes under that context.
+    # Two wildcards may be used in +mailbox+: '*', which matches
+    # all characters *including* the hierarchy delimiter (for instance,
+    # '/' on a UNIX-hosted directory-based mailbox hierarchy); and '%',
+    # which matches all characters *except* the hierarchy delimiter.
+    #
+    # If +refname+ is empty, +mailbox+ is used directly to determine
+    # which mailboxes to match.  If +mailbox+ is empty, the root
+    # name of +refname+ and the hierarchy delimiter are returned.
+    #
+    # The XLIST command is like the LIST command except that the flags
+    # returned refer to the function of the folder/mailbox, e.g. :Sent
+    #
+    # The return value is an array of +Net::IMAP::MailboxList+. For example:
+    #
+    #   imap.create("foo/bar")
+    #   imap.create("foo/baz")
+    #   p imap.xlist("", "foo/%")
+    #   #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
+    #        #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
+    #        #<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
+    def xlist(refname, mailbox)
+      synchronize do
+        send_command("XLIST", refname, mailbox)
+        return @responses.delete("XLIST")
+      end
+    end
+
     # Sends the GETQUOTAROOT command along with specified +mailbox+.
     # This command is generally available to both admin and user.
     # If mailbox exists, returns an array containing objects of
@@ -2071,7 +2103,7 @@
             return response_cond
           when /\A(?:FLAGS)\z/ni
             return flags_response
-          when /\A(?:LIST|LSUB)\z/ni
+          when /\A(?:LIST|LSUB|XLIST)\z/ni
             return list_response
           when /\A(?:QUOTA)\z/ni
             return getquota_response
Index: test/net/imap/test_imap_response_parser.rb
===================================================================
--- test/net/imap/test_imap_response_parser.rb	(revision 30107)
+++ test/net/imap/test_imap_response_parser.rb	(revision 30108)
@@ -56,6 +56,15 @@
     end
   end
 
+  def test_flag_xlist_inbox
+    parser = Net::IMAP::ResponseParser.new
+	response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)
+* XLIST (\\Inbox) "." "INBOX"
+EOF
+    assert_equal [:Inbox], response.attr.data
+  end
+
+
   def test_resp_text_code
     parser = Net::IMAP::ResponseParser.new
     response = parser.parse(<<EOF.gsub(/\n/, "\r\n").taint)

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]