  Copyright 2014 Kolab Systems AG (  )
%%
    ( Kolab Systems ) < seigo a kolabsys.com >
%%
%% This program is free software: you can redistribute it and/or modify
  it under the terms of the GNU Library General Public License as published by
  the Free Software Foundation , either version 3 of the License , or
%% (at your option) any later version.
%%
%% This program is distributed in the hope that it will be useful,
%% but WITHOUT ANY WARRANTY; without even the implied warranty of
%% MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
%% GNU Library General Public License for more details.
%%
  You should have received a copy of the GNU Library General Public License
%% along with this program.  If not, see </>.

-module(eimap_command_login).
-behavior(eimap_command).
-export([new_command/1, process_line/2, formulate_response/2]).

%% 

%% Public API
new_command({ User, Password }) ->
    UserBin = eimap_utils:ensure_binary(User),
    PasswordBin = eimap_utils:ensure_binary(Password),
    { <<"LOGIN ", UserBin/binary, " ", PasswordBin/binary>>, multiline_response }.

process_line(_Data, Acc) -> Acc.

%% Private API
formulate_response(ok, _Acc) -> { fini, authed };
formulate_response({ _, Reason }, _Acc) -> { error, Reason }.




 This program is free software: you can redistribute it and/or modify
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU Library General Public License for more details.

 along with this program.  If not, see </>.
 
 Public API
 Private API
  Copyright 2014 Kolab Systems AG (  )
    ( Kolab Systems ) < seigo a kolabsys.com >
  it under the terms of the GNU Library General Public License as published by
  the Free Software Foundation , either version 3 of the License , or
  You should have received a copy of the GNU Library General Public License

-module(eimap_command_login).
-behavior(eimap_command).
-export([new_command/1, process_line/2, formulate_response/2]).


new_command({ User, Password }) ->
    UserBin = eimap_utils:ensure_binary(User),
    PasswordBin = eimap_utils:ensure_binary(Password),
    { <<"LOGIN ", UserBin/binary, " ", PasswordBin/binary>>, multiline_response }.

process_line(_Data, Acc) -> Acc.

formulate_response(ok, _Acc) -> { fini, authed };
formulate_response({ _, Reason }, _Acc) -> { error, Reason }.

