@@ -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 )
@@ -959,10 +1037,10 @@ def expunge
959
1037
# #responses and this method returns them as an array of
960
1038
# <em>sequence number</em> integers.
961
1039
#
962
- # ===== Capability requirement
1040
+ # ===== Capabilities
963
1041
#
964
- # +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] must be
965
- # supported by the server .
1042
+ # The server's capabilities must include +UIDPLUS+
1043
+ # [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] .
966
1044
def uid_expunge ( uid_set )
967
1045
synchronize do
968
1046
send_command ( "UID EXPUNGE" , MessageSet . new ( uid_set ) )
@@ -1121,10 +1199,10 @@ def uid_copy(set, mailbox)
1121
1199
# a number, an array of numbers, or a Range object. The number is
1122
1200
# a message sequence number.
1123
1201
#
1124
- # ===== Capabilities requirements
1202
+ # ===== Capabilities
1125
1203
#
1126
- # +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must be supported by
1127
- # the server .
1204
+ # The server's capabilities must include +MOVE+
1205
+ # [RFC6851[https://tools.ietf.org/html/rfc6851]] .
1128
1206
#
1129
1207
# If +UIDPLUS+ [RFC4315[https://www.rfc-editor.org/rfc/rfc4315.html]] is
1130
1208
# also supported, the server's response should include a +COPYUID+ response
@@ -1137,11 +1215,11 @@ def move(set, mailbox)
1137
1215
1138
1216
# Similar to #move, but +set+ contains unique identifiers.
1139
1217
#
1140
- # ===== Capabilities requirements
1218
+ # ===== Capabilities
1141
1219
#
1142
- # Same as #move: +MOVE+ [RFC6851[https://tools.ietf.org/html/rfc6851]] must
1143
- # be supported by the server. +UIDPLUS+ also affects #uid_move the same way
1144
- # it affects #move.
1220
+ # Same as #move: The server's capabilities must include +MOVE+
1221
+ # [RFC6851[https://tools.ietf.org/html/rfc6851]]. +UIDPLUS+ also affects
1222
+ # #uid_move the same way it affects #move.
1145
1223
def uid_move ( set , mailbox )
1146
1224
copy_internal ( "UID MOVE" , set , mailbox )
1147
1225
end
@@ -1154,14 +1232,20 @@ def uid_move(set, mailbox)
1154
1232
# p imap.sort(["DATE"], ["SUBJECT", "hello"], "US-ASCII")
1155
1233
# #=> [6, 7, 8, 1]
1156
1234
#
1157
- # The SORT extension is described in [SORT[https://tools.ietf.org/html/rfc5256]].
1235
+ # ===== Capabilities
1236
+ #
1237
+ # The server's capabilities must include +SORT+
1238
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1158
1239
def sort ( sort_keys , search_keys , charset )
1159
1240
return sort_internal ( "SORT" , sort_keys , search_keys , charset )
1160
1241
end
1161
1242
1162
1243
# Similar to #sort, but returns an array of unique identifiers.
1163
1244
#
1164
- # The SORT extension is described in [SORT[https://tools.ietf.org/html/rfc5256]].
1245
+ # ===== Capabilities
1246
+ #
1247
+ # The server's capabilities must include +SORT+
1248
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1165
1249
def uid_sort ( sort_keys , search_keys , charset )
1166
1250
return sort_internal ( "UID SORT" , sort_keys , search_keys , charset )
1167
1251
end
@@ -1199,15 +1283,21 @@ def remove_response_handler(handler)
1199
1283
# Unlike #search, +charset+ is a required argument. US-ASCII
1200
1284
# and UTF-8 are sample values.
1201
1285
#
1202
- # The THREAD extension is described in [THREAD[https://tools.ietf.org/html/rfc5256]].
1286
+ # ===== Capabilities
1287
+ #
1288
+ # The server's capabilities must include +THREAD+
1289
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1203
1290
def thread ( algorithm , search_keys , charset )
1204
1291
return thread_internal ( "THREAD" , algorithm , search_keys , charset )
1205
1292
end
1206
1293
1207
1294
# Similar to #thread, but returns unique identifiers instead of
1208
1295
# message sequence numbers.
1209
1296
#
1210
- # The THREAD extension is described in [THREAD[https://tools.ietf.org/html/rfc5256]].
1297
+ # ===== Capabilities
1298
+ #
1299
+ # The server's capabilities must include +THREAD+
1300
+ # [RFC5256[https://tools.ietf.org/html/rfc5256]].
1211
1301
def uid_thread ( algorithm , search_keys , charset )
1212
1302
return thread_internal ( "UID THREAD" , algorithm , search_keys , charset )
1213
1303
end
@@ -1226,6 +1316,11 @@ def uid_thread(algorithm, search_keys, charset)
1226
1316
# ...
1227
1317
# end
1228
1318
# end
1319
+ #
1320
+ # ===== Capabilities
1321
+ #
1322
+ # The server's capabilities must include +IDLE+
1323
+ # [RFC2177[https://tools.ietf.org/html/rfc2177]].
1229
1324
def idle ( timeout = nil , &response_handler )
1230
1325
raise LocalJumpError , "no block given" unless response_handler
1231
1326
0 commit comments