@@ -428,16 +428,33 @@ def disconnected?
428
428
# Sends a CAPABILITY command, and returns an array of
429
429
# capabilities that the server supports. Each capability
430
430
# is a string.
431
- # See the {IANA IMAP capabilities registry}[https://www.iana.org/assignments/imap-capabilities/imap-capabilities.xhtml]
432
- # for a list of possible capabilities and their RFCs.
431
+ #
432
+ # See the {IANA IMAP4 capabilities
433
+ # registry}[http://www.iana.org/assignments/imap4-capabilities] for a list
434
+ # of all standard capabilities, and their reference RFCs.
433
435
#
434
436
# >>>
435
- # <em>*Note* that the Net::IMAP class does not modify its
437
+ # <em>*Note* that Net::IMAP does not currently modify its
436
438
# behaviour according to the capabilities of the server;
437
439
# it is up to the user of the class to ensure that
438
440
# a certain capability is supported by a server before
439
441
# using it.</em>
440
442
#
443
+ # Capability requirements—other than +IMAP4rev1+—are listed in the
444
+ # documentation for each command method.
445
+ #
446
+ # ===== Caching +CAPABILITY+ responses
447
+ #
448
+ # Servers may send their capability list, unsolicited, using the
449
+ # +CAPABILITY+ response code or an untagged +CAPABILITY+ response. These
450
+ # responses can be retrieved and cached using #responses or
451
+ # #add_response_handler.
452
+ #
453
+ # But cached capabilities must be discarded after #starttls, #login, or
454
+ # #authenticate. The OK TaggedResponse to #login and #authenticate may
455
+ # include +CAPABILITY+ response code data, but the TaggedResponse for
456
+ # #starttls is sent clear-text and cannot be trusted.
457
+ #
441
458
def capability
442
459
synchronize do
443
460
send_command ( "CAPABILITY" )
@@ -462,6 +479,11 @@ def capability
462
479
# end
463
480
#
464
481
# See [ID[https://tools.ietf.org/html/rfc2971]] for field definitions.
482
+ #
483
+ # ===== Capabilities
484
+ #
485
+ # The server's capabilities must include +ID+
486
+ # [RFC2971[https://tools.ietf.org/html/rfc2971]]
465
487
def id ( client_id = nil )
466
488
synchronize do
467
489
send_command ( "ID" , ClientID . new ( client_id ) )
@@ -481,6 +503,14 @@ def logout
481
503
end
482
504
483
505
# Sends a STARTTLS command to start TLS session.
506
+ # Sends a STARTTLS command to start a TLS session.
507
+ #
508
+ # ===== Capability
509
+ #
510
+ # The server's capabilities must include +STARTTLS+.
511
+ #
512
+ # Server capabilities change after #starttls, #login, and #authenticate. so
513
+ # Cached capabilities must be invalidated after this method completes.
484
514
def starttls ( options = { } , verify = true )
485
515
send_command ( "STARTTLS" ) do |resp |
486
516
if resp . kind_of? ( TaggedResponse ) && resp . name == "OK"
@@ -529,6 +559,18 @@ def starttls(options = {}, verify = true)
529
559
#
530
560
# See Net::IMAP::Authenticators for more information on plugging in your
531
561
# own authenticator.
562
+ #
563
+ # ==== Capabilities
564
+ #
565
+ # Clients MUST NOT attempt to #authenticate or #login when +LOGINDISABLED+
566
+ # is listed with the capabilities.
567
+ #
568
+ # Clients MUST NOT attempt to authenticate with a mechanism unless
569
+ # <tt>"AUTH=#{mechanism}"</tt> for that mechanism is a server capability.
570
+ #
571
+ # Server capabilities may change after #starttls, #login, and #authenticate.
572
+ # Any cached capabilities must be invalidated when this method completes.
573
+ #
532
574
def authenticate ( auth_type , *args )
533
575
authenticator = self . class . authenticator ( auth_type , *args )
534
576
send_command ( "AUTHENTICATE" , auth_type ) do |resp |
@@ -547,6 +589,14 @@ def authenticate(auth_type, *args)
547
589
# of "LOGIN", #login does *not* use the login authenticator.
548
590
#
549
591
# A Net::IMAP::NoResponseError is raised if authentication fails.
592
+ #
593
+ # ==== Capabilities
594
+ # Clients MUST NOT attempt to #authenticate or #login when +LOGINDISABLED+
595
+ # is listed with the capabilities.
596
+ #
597
+ # Server capabilities may change after #starttls, #login, and #authenticate.
598
+ # Cached capabilities must be invalidated when this method completes.
599
+ #
550
600
def login ( user , password )
551
601
send_command ( "LOGIN" , user , password )
552
602
end
@@ -717,7 +767,10 @@ def list(refname, mailbox)
717
767
# end
718
768
# end
719
769
#
720
- # The NAMESPACE extension is described in [NAMESPACE[https://tools.ietf.org/html/rfc2342]]
770
+ # ===== Capabilities
771
+ #
772
+ # The server's capabilities must include +NAMESPACE+
773
+ # [RFC2342[https://tools.ietf.org/html/rfc2342]]
721
774
def namespace
722
775
synchronize do
723
776
send_command ( "NAMESPACE" )
@@ -750,6 +803,16 @@ def namespace
750
803
# #=> [#<Net::IMAP::MailboxList attr=[:Noselect], delim="/", name="foo/">, \\
751
804
# #<Net::IMAP::MailboxList attr=[:Noinferiors, :Marked], delim="/", name="foo/bar">, \\
752
805
# #<Net::IMAP::MailboxList attr=[:Noinferiors], delim="/", name="foo/baz">]
806
+ #
807
+ # ===== Capabilities
808
+ #
809
+ # The server's capabilities must include +XLIST+,
810
+ # a deprecated Gmail extension (replaced by +SPECIAL-USE+).
811
+ #--
812
+ # TODO: Net::IMAP doesn't yet have full SPECIAL-USE support. Supporting
813
+ # servers MAY return SPECIAL-USE attributes, but are not *required* to
814
+ # unless the SPECIAL-USE return option is supplied.
815
+ #++
753
816
def xlist ( refname , mailbox )
754
817
synchronize do
755
818
send_command ( "XLIST" , refname , mailbox )
@@ -762,7 +825,10 @@ def xlist(refname, mailbox)
762
825
# If this mailbox exists, it returns an array containing objects of type
763
826
# MailboxQuotaRoot and MailboxQuota.
764
827
#
765
- # The QUOTA extension is described in [QUOTA[https://tools.ietf.org/html/rfc2087]]
828
+ # ===== Capabilities
829
+ #
830
+ # The server's capabilities must include +QUOTA+
831
+ # [RFC2087[https://tools.ietf.org/html/rfc2087]].
766
832
def getquotaroot ( mailbox )
767
833
synchronize do
768
834
send_command ( "GETQUOTAROOT" , mailbox )
@@ -778,7 +844,10 @@ def getquotaroot(mailbox)
778
844
# MailboxQuota object is returned. This
779
845
# command is generally only available to server admin.
780
846
#
781
- # The QUOTA extension is described in [QUOTA[https://tools.ietf.org/html/rfc2087]]
847
+ # ===== Capabilities
848
+ #
849
+ # The server's capabilities must include +QUOTA+
850
+ # [RFC2087[https://tools.ietf.org/html/rfc2087]].
782
851
def getquota ( mailbox )
783
852
synchronize do
784
853
send_command ( "GETQUOTA" , mailbox )
@@ -791,7 +860,10 @@ def getquota(mailbox)
791
860
# mailbox. Typically one needs to be logged in as a server admin
792
861
# for this to work.
793
862
#
794
- # The QUOTA extension is described in [QUOTA[https://tools.ietf.org/html/rfc2087]]
863
+ # ===== Capabilities
864
+ #
865
+ # The server's capabilities must include +QUOTA+
866
+ # [RFC2087[https://tools.ietf.org/html/rfc2087]].
795
867
def setquota ( mailbox , quota )
796
868
if quota . nil?
797
869
data = '()'
@@ -805,7 +877,10 @@ def setquota(mailbox, quota)
805
877
# +rights+ that user is to have on that mailbox. If +rights+ is nil,
806
878
# then that user will be stripped of any rights to that mailbox.
807
879
#
808
- # The ACL extension is described in [ACL[https://tools.ietf.org/html/rfc4314]]
880
+ # ===== Capabilities
881
+ #
882
+ # The server's capabilities must include +ACL+
883
+ # [RFC4314[https://tools.ietf.org/html/rfc4314]].
809
884
def setacl ( mailbox , user , rights )
810
885
if rights . nil?
811
886
send_command ( "SETACL" , mailbox , user , "" )
@@ -818,7 +893,10 @@ def setacl(mailbox, user, rights)
818
893
# If this mailbox exists, an array containing objects of
819
894
# MailboxACLItem will be returned.
820
895
#
821
- # The ACL extension is described in [ACL[https://tools.ietf.org/html/rfc4314]]
896
+ # ===== Capabilities
897
+ #
898
+ # The server's capabilities must include +ACL+
899
+ # [RFC4314[https://tools.ietf.org/html/rfc4314]].
822
900
def getacl ( mailbox )
823
901
synchronize do
824
902
send_command ( "GETACL" , mailbox )
@@ -945,10 +1023,10 @@ def expunge
945
1023
# #responses and this method returns them as an array of
946
1024
# <em>sequence number</em> integers.
947
1025
#
948
- # ===== Capability requirement
1026
+ # ===== Capabilities
949
1027
#
950
- # +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] must be
951
- # supported by the server .
1028
+ # The server's capabilities must include +UIDPLUS+
1029
+ # [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] .
952
1030
def uid_expunge ( uid_set )
953
1031
synchronize do
954
1032
send_command ( "UID EXPUNGE" , MessageSet . new ( uid_set ) )
@@ -1107,10 +1185,10 @@ def uid_copy(set, mailbox)
1107
1185
# a number, an array of numbers, or a Range object. The number is
1108
1186
# a message sequence number.
1109
1187
#
1110
- # ===== Capabilities requirements
1188
+ # ===== Capabilities
1111
1189
#
1112
- # +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must be supported by
1113
- # the server .
1190
+ # The server's capabilities must include +MOVE+
1191
+ # [RFC6851[https://tools.ietf.org/html/rfc6851]] .
1114
1192
#
1115
1193
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
1116
1194
# also supported, the server's response should include a +COPYUID+ response
@@ -1123,11 +1201,11 @@ def move(set, mailbox)
1123
1201
1124
1202
# Similar to #move, but +set+ contains unique identifiers.
1125
1203
#
1126
- # ===== Capabilities requirements
1204
+ # ===== Capabilities
1127
1205
#
1128
- # Same as #move: +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must
1129
- # be supported by the server. +UIDPLUS+ also affects #uid_move the same way
1130
- # it affects #move.
1206
+ # Same as #move: The server's capabilities must include +MOVE+
1207
+ # [RFC6851[https://tools.ietf.org/html/rfc6851]]. +UIDPLUS+ also affects
1208
+ # #uid_move the same way it affects #move.
1131
1209
def uid_move ( set , mailbox )
1132
1210
copy_internal ( "UID MOVE" , set , mailbox )
1133
1211
end
@@ -1140,14 +1218,20 @@ def uid_move(set, mailbox)
1140
1218
# p imap.sort(["DATE"], ["SUBJECT", "hello"], "US-ASCII")
1141
1219
# #=> [6, 7, 8, 1]
1142
1220
#
1143
- # The SORT extension is described in [SORT[https://tools.ietf.org/html/rfc5256]].
1221
+ # ===== Capabilities
1222
+ #
1223
+ # The server's capabilities must include +SORT+
1224
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1144
1225
def sort ( sort_keys , search_keys , charset )
1145
1226
return sort_internal ( "SORT" , sort_keys , search_keys , charset )
1146
1227
end
1147
1228
1148
1229
# Similar to #sort, but returns an array of unique identifiers.
1149
1230
#
1150
- # The SORT extension is described in [SORT[https://tools.ietf.org/html/rfc5256]].
1231
+ # ===== Capabilities
1232
+ #
1233
+ # The server's capabilities must include +SORT+
1234
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1151
1235
def uid_sort ( sort_keys , search_keys , charset )
1152
1236
return sort_internal ( "UID SORT" , sort_keys , search_keys , charset )
1153
1237
end
@@ -1185,15 +1269,21 @@ def remove_response_handler(handler)
1185
1269
# Unlike #search, +charset+ is a required argument. US-ASCII
1186
1270
# and UTF-8 are sample values.
1187
1271
#
1188
- # The THREAD extension is described in [THREAD[https://tools.ietf.org/html/rfc5256]].
1272
+ # ===== Capabilities
1273
+ #
1274
+ # The server's capabilities must include +THREAD+
1275
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1189
1276
def thread ( algorithm , search_keys , charset )
1190
1277
return thread_internal ( "THREAD" , algorithm , search_keys , charset )
1191
1278
end
1192
1279
1193
1280
# Similar to #thread, but returns unique identifiers instead of
1194
1281
# message sequence numbers.
1195
1282
#
1196
- # The THREAD extension is described in [THREAD[https://tools.ietf.org/html/rfc5256]].
1283
+ # ===== Capabilities
1284
+ #
1285
+ # The server's capabilities must include +THREAD+
1286
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1197
1287
def uid_thread ( algorithm , search_keys , charset )
1198
1288
return thread_internal ( "UID THREAD" , algorithm , search_keys , charset )
1199
1289
end
@@ -1212,6 +1302,11 @@ def uid_thread(algorithm, search_keys, charset)
1212
1302
# ...
1213
1303
# end
1214
1304
# end
1305
+ #
1306
+ # ===== Capabilities
1307
+ #
1308
+ # The server's capabilities must include +IDLE+
1309
+ # [RFC2177[https://tools.ietf.org/html/rfc2177]].
1215
1310
def idle ( timeout = nil , &response_handler )
1216
1311
raise LocalJumpError , "no block given" unless response_handler
1217
1312
0 commit comments