Changeset View
Changeset View
Standalone View
Standalone View
apps/kolab_guam/src/rules/kolab_guam_rule_filter_groupware.erl
Show All 10 Lines | |||||
%% but WITHOUT ANY WARRANTY; without even the implied warranty of | %% but WITHOUT ANY WARRANTY; without even the implied warranty of | ||||
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | %% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||||
%% GNU General Public License for more details. | %% GNU General Public License for more details. | ||||
%% | %% | ||||
%% You should have received a copy of the GNU General Public License | %% You should have received a copy of the GNU General Public License | ||||
%% along with this program. If not, see <http://www.gnu.org/licenses/>. | %% along with this program. If not, see <http://www.gnu.org/licenses/>. | ||||
-module(kolab_guam_rule_filter_groupware). | -module(kolab_guam_rule_filter_groupware). | ||||
-export([new/1, applies/3, imap_data/3, apply_to_client_message/3, apply_to_server_message/3]). | -export([new/1, applies/4, imap_data/3, apply_to_client_message/4, apply_to_server_message/3]). | ||||
-behavior(kolab_guam_rule). | -behavior(kolab_guam_rule). | ||||
-record(state, { blacklist = [], tag = <<>>, active = false, last_chunk = <<>>, | -record(state, { blacklist = [], tag = <<>>, active = false, last_chunk = <<>>, | ||||
trigger_commands = [<<"LIST">>, <<"list">>, <<"XLIST">>, <<"xlist">>, <<"LSUB">>, <<"lsub">>]}). | trigger_commands = [<<"LIST">>, <<"list">>, <<"XLIST">>, <<"xlist">>, <<"LSUB">>, <<"lsub">>]}). | ||||
new(_Config) -> #state { blacklist = undefined }. | new(_Config) -> #state { blacklist = undefined }. | ||||
applies(_ConnectionDetails, Buffer, State) -> | applies(_ConnectionDetails, _Buffer, { _Tag, Command, Data }, State) -> | ||||
{ _Tag, Command, Data } = eimap_utils:split_command_into_components(Buffer), | Applies = apply_if_id_matches(Command, Data, State), | ||||
%lager:debug("********** Checking ...~n Command: ~s ~s", [Command, Data]), | %lager:debug("********** Checking ...~n Command: ~s ~s, Result ~p", [Command, Data, Applies]), | ||||
{ apply_if_id_matches(Command, Data, State), State }. | { Applies, State }. | ||||
apply_to_client_message(ImapSession, Buffer, State) -> | apply_to_client_message(ImapSession, Buffer, { Tag, Command, Data }, State) -> | ||||
{ Tag, Command, Data } = eimap_utils:split_command_into_components(Buffer), | |||||
{ Active, StateTag }= | { Active, StateTag } = | ||||
case is_triggering_command(Command, Data, State) of | case is_triggering_command(Command, Data, State) of | ||||
true -> fetch_metadata(ImapSession, State), { true, Tag }; | true -> fetch_metadata(ImapSession, State), { true, Tag }; | ||||
_ -> { false, <<>> } | _ -> { false, <<>> } | ||||
end, | end, | ||||
%lager:info("Client sent: ~s ~s ~p", [Command, Data, Active]), | %lager:info("Client sent: ~s ~s ~p", [Command, Data, Active]), | ||||
{ Buffer, State#state{ active = Active, tag = StateTag }}. | { Buffer, State#state{ active = Active, tag = StateTag }}. | ||||
apply_to_server_message(_ImapSession, Buffer, #state{ active = true } = State) -> | apply_to_server_message(_ImapSession, Buffer, #state{ active = true } = State) -> | ||||
▲ Show 20 Lines • Show All 99 Lines • Show Last 20 Lines |