Skip to content

Commit 8c443ec

Browse files
committed
Minor fixes
1 parent 1513fa7 commit 8c443ec

File tree

5 files changed

+34
-10
lines changed

5 files changed

+34
-10
lines changed

src/imap/imapCommands.ml

+27
Original file line numberDiff line numberDiff line change
@@ -1122,8 +1122,35 @@ module Namespace = struct
11221122
ImapParser.(register_parser {parse})
11231123
end
11241124

1125+
(*
1126+
command-auth =/ compress
1127+
1128+
compress = "COMPRESS" SP algorithm
1129+
1130+
capability =/ "COMPRESS=" algorithm
1131+
;; multiple COMPRESS capabilities allowed
1132+
1133+
algorithm = "DEFLATE"
1134+
1135+
resp-text-code =/ "COMPRESSIONACTIVE"
1136+
*)
1137+
11251138
module Compress = struct
1139+
type resp_text_code_extension +=
1140+
RESP_TEXT_CODE_COMPRESSIONACTIVE
1141+
1142+
let parse : type a. a extension_kind -> a ImapParser.t = fun kind ->
1143+
let open ImapParser in
1144+
match kind with
1145+
RESP_TEXT_CODE ->
1146+
str "COMPRESSIONACTIVE" >> ret RESP_TEXT_CODE_COMPRESSIONACTIVE
1147+
| _ ->
1148+
fail
1149+
11261150
let compress = std_command (send "COMPRESS DEFLATE")
1151+
1152+
let _ =
1153+
ImapParser.(register_parser {parse})
11271154
end
11281155

11291156
module Idle = struct

src/imap/imapCore.ml

-4
Original file line numberDiff line numberDiff line change
@@ -89,8 +89,6 @@ let resp_text_store s {rsp_code; rsp_text} =
8989
{s with sel_info = {s.sel_info with sel_uidvalidity = uid}}
9090
| RESP_TEXT_CODE_UNSEEN unseen ->
9191
{s with sel_info = {s.sel_info with sel_first_unseen = unseen}}
92-
(* | RESP_TEXT_CODE_COMPRESSIONACTIVE -> *)
93-
(* {s with rsp_info = {s.rsp_info with rsp_compressionactive = true}} *)
9492
| RESP_TEXT_CODE_EXTENSION e ->
9593
extension_data_store s RESP_TEXT_CODE e
9694
| RESP_TEXT_CODE_OTHER other ->
@@ -157,8 +155,6 @@ let response_data_store s =
157155
{s with cap_info}
158156
| RESP_DATA_EXTENSION_DATA e ->
159157
extension_data_store s RESPONSE_DATA e
160-
(* | `NAMESPACE (pers, other, shared) -> *)
161-
(* {s with rsp_info = {s.rsp_info with rsp_namespace = pers, other, shared}} *)
162158

163159
let response_tagged_store s {rsp_cond_state = r} =
164160
resp_cond_state_store s r

src/imap/imapTypes.mli

+1-5
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ type flag =
3838
| FLAG_KEYWORD of string
3939
(** keyword flag *)
4040
| FLAG_EXTENSION of string
41-
(* (\** \extension flag *\) ] with sexp *)
41+
(** \extension flag *)
4242

4343
type flag_fetch =
4444
FLAG_FETCH_RECENT
@@ -214,10 +214,6 @@ type fetch_att =
214214
| FETCH_ATT_FLAGS
215215
(** Message flags *)
216216
| FETCH_ATT_EXTENSION of string
217-
(* | `X_GM_MSGID *)
218-
(* (\** Gmail message ID. *\) *)
219-
(* | `X_GM_THRID *)
220-
(* (\** Gmail thread ID. *\) *)
221217

222218
type fetch_type =
223219
FETCH_TYPE_ALL

src/lwt/imapSession.ml

+5-1
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ module type IndexSet = sig
5656
val until : elt -> t
5757
val all : t
5858
val index : elt -> t
59+
val length : t -> int
5960
val add_range : elt -> elt -> t -> t
6061
val add : elt -> t -> t
6162
val remove_range : elt -> elt -> t -> t
@@ -83,6 +84,9 @@ end = struct
8384
let until l = if cmp l Uint32.zero = 0 then [] else (Uint32.one, l) :: []
8485
let all = from Uint32.one
8586
let index n = range n n
87+
let length s =
88+
let l (l, r) = succ Uint32.(sub r l) |> Uint32.to_int in
89+
List.fold_left (fun acc x -> acc + (l x)) 0 s
8690
let add_range l r s =
8791
let l, r = if cmp l r <= 0 then l, r else r, l in
8892
let rec loop l r = function
@@ -1624,7 +1628,7 @@ let idle s ~folder ?(last_known_uid = Uid.zero) () =
16241628
else
16251629
Session.with_folder s folder begin fun ci ->
16261630
lwt () = Conn.run ImapCommands.Idle.idle_start ci in
1627-
ci.idling <- Some waker;
1631+
ci.Conn.idling <- Some waker;
16281632
try_lwt
16291633
lwt () = Lwt.pick [ Conn.wait_read ci; Lwt_unix.sleep (29. *. 60.); waiter ] in
16301634
Conn.run ImapCommands.Idle.idle_done ci

src/lwt/imapSession.mli

+1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@ module type IndexSet = sig
2929
val until : elt -> t
3030
val all : t
3131
val index : elt -> t
32+
val length : t -> int
3233
val add_range : elt -> elt -> t -> t
3334
val add : elt -> t -> t
3435
val remove_range : elt -> elt -> t -> t

0 commit comments

Comments
 (0)