Changeset View
Changeset View
Standalone View
Standalone View
apps/kolab_guam/src/rules/kolab_guam_rule_filter_groupware.erl
Show First 20 Lines • Show All 71 Lines • ▼ Show 20 Lines | apply_if_id_matches(Command, Data, State) -> | ||||
case is_triggering_command(Command, Data, State) of | case is_triggering_command(Command, Data, State) of | ||||
true -> true; | true -> true; | ||||
_ -> notyet | _ -> notyet | ||||
end. | end. | ||||
apply_if_found_kolab(0) -> true; | apply_if_found_kolab(0) -> true; | ||||
apply_if_found_kolab(_) -> false. | apply_if_found_kolab(_) -> false. | ||||
possibly_append_newline(<<>>) -> <<>> ; | |||||
possibly_append_newline(Response) -> <<Response/binary, "\r\n">> . | |||||
filter_folders(<<>>, State) -> | filter_folders(<<>>, State) -> | ||||
{ <<>>, State#state{ active = true } }; | { <<>>, State#state{ active = true } }; | ||||
filter_folders(Buffer, #state{ last_chunk = LeftOvers } = State) -> | filter_folders(Buffer, #state{ last_chunk = LeftOvers } = State) -> | ||||
% Add the left overs from the previous buffer to the current buffer | |||||
FullBuffer = <<LeftOvers/binary, Buffer/binary>>, | FullBuffer = <<LeftOvers/binary, Buffer/binary>>, | ||||
% From that buffer, only take the complete lines and save off the remainder. | |||||
{ FullLinesBuffer, LastChunk } = eimap_utils:only_full_lines(FullBuffer), | { FullLinesBuffer, LastChunk } = eimap_utils:only_full_lines(FullBuffer), | ||||
% Create a list so we can filter the individual folders | |||||
ListResponses = binary:split(FullLinesBuffer, <<"\r\n">>, [ global ]), | ListResponses = binary:split(FullLinesBuffer, <<"\r\n">>, [ global ]), | ||||
{ Response, More } = filter_folders(State, ListResponses, { <<>>, true }), | { Response, More } = filter_folders(State, ListResponses, { <<>>, true }), | ||||
%io:format("Filtered ... ~p~n", [Response]), | %io:format("Filtered ... ~p~n", [Response]), | ||||
{ <<Response/binary, "\r\n">>, State#state { active = More, last_chunk = LastChunk } }. | %Note that the last list item does not contain \r\n, so that needs to be added unless we filtered the complete content. | ||||
{ possibly_append_newline(Response), State#state { active = More, last_chunk = LastChunk } }. | |||||
mollekopf: would prefer something like:
{ possibly_append_newline(Response), State#state { active = More… | |||||
filter_folders(_State, [], Return) -> Return; | filter_folders(_State, [], Return) -> Return; | ||||
filter_folders(_State, _Folders, { Acc, false }) -> { Acc, false }; | filter_folders(_State, _Folders, { Acc, false }) -> { Acc, false }; | ||||
filter_folders(State, [Unfiltered|Folders], { Acc, _More }) -> filter_folders(State, Folders, filter_folder(State, Unfiltered, Acc)). | filter_folders(State, [Unfiltered|Folders], { Acc, _More }) -> filter_folders(State, Folders, filter_folder(State, Unfiltered, Acc)). | ||||
filter_folder(_State, <<>>, Acc) -> { Acc, true }; | filter_folder(_State, <<>>, Acc) -> { Acc, true }; | ||||
filter_folder(State, <<"* LIST ", Details/binary>> = Response, Acc) -> { filter_on_details(State, Response, Acc, Details), true }; | filter_folder(State, <<"* LIST ", Details/binary>> = Response, Acc) -> { filter_on_details(State, Response, Acc, Details), true }; | ||||
filter_folder(State, <<"* XLIST ", Details/binary>> = Response, Acc) -> { filter_on_details(State, Response, Acc, Details), true }; | filter_folder(State, <<"* XLIST ", Details/binary>> = Response, Acc) -> { filter_on_details(State, Response, Acc, Details), true }; | ||||
▲ Show 20 Lines • Show All 46 Lines • Show Last 20 Lines |
would prefer something like:
{ possibly_append_newline(Response), State#state { active = More, last_chunk = LastChunk } }.
possibly_append_newline(