mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-20 17:27:00 +01:00
Removed unneeded use of length function + Remove trailing spaces
SVN Revision: 2610
This commit is contained in:
parent
d6f63ceec5
commit
325660a547
@ -48,7 +48,7 @@
|
||||
|
||||
-define(SETS, gb_sets).
|
||||
|
||||
-record(state, {socket, encoding, port, password,
|
||||
-record(state, {socket, encoding, port, password,
|
||||
queue, user, host, server, nick,
|
||||
channels = dict:new(),
|
||||
nickchannel,
|
||||
@ -83,7 +83,7 @@ start_link(From, Host, Server, Username, Encoding, Port, Password) ->
|
||||
%% Returns: {ok, StateName, StateData} |
|
||||
%% {ok, StateName, StateData, Timeout} |
|
||||
%% ignore |
|
||||
%% {stop, StopReason}
|
||||
%% {stop, StopReason}
|
||||
%%----------------------------------------------------------------------
|
||||
init([From, Host, Server, Username, Encoding, Port, Password]) ->
|
||||
gen_fsm:send_event(self(), init),
|
||||
@ -100,7 +100,7 @@ init([From, Host, Server, Username, Encoding, Port, Password]) ->
|
||||
%% Func: StateName/2
|
||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData}
|
||||
%% {stop, Reason, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
open_socket(init, StateData) ->
|
||||
Addr = StateData#state.server,
|
||||
@ -109,8 +109,8 @@ open_socket(init, StateData) ->
|
||||
case gen_tcp:connect(Addr, Port, [binary, {packet, 0}]) of
|
||||
{ok, Socket} ->
|
||||
NewStateData = StateData#state{socket = Socket},
|
||||
if
|
||||
StateData#state.password /= "" ->
|
||||
if
|
||||
StateData#state.password /= "" ->
|
||||
send_text(NewStateData,
|
||||
io_lib:format("PASS ~s\r\n", [StateData#state.password]));
|
||||
true -> true
|
||||
@ -159,7 +159,7 @@ stream_established(closed, StateData) ->
|
||||
%% {reply, Reply, NextStateName, NextStateData} |
|
||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData} |
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
%state_name(Event, From, StateData) ->
|
||||
% Reply = ok,
|
||||
@ -169,7 +169,7 @@ stream_established(closed, StateData) ->
|
||||
%% Func: handle_event/3
|
||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData}
|
||||
%% {stop, Reason, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
handle_event(_Event, StateName, StateData) ->
|
||||
{next_state, StateName, StateData}.
|
||||
@ -181,7 +181,7 @@ handle_event(_Event, StateName, StateData) ->
|
||||
%% {reply, Reply, NextStateName, NextStateData} |
|
||||
%% {reply, Reply, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData} |
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%% {stop, Reason, Reply, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
handle_sync_event(_Event, _From, StateName, StateData) ->
|
||||
Reply = ok,
|
||||
@ -203,7 +203,7 @@ code_change(_OldVsn, StateName, StateData, _Extra) ->
|
||||
%% Func: handle_info/3
|
||||
%% Returns: {next_state, NextStateName, NextStateData} |
|
||||
%% {next_state, NextStateName, NextStateData, Timeout} |
|
||||
%% {stop, Reason, NewStateData}
|
||||
%% {stop, Reason, NewStateData}
|
||||
%%----------------------------------------------------------------------
|
||||
handle_info({route_chan, Channel, Resource,
|
||||
{xmlelement, "presence", Attrs, _Els}},
|
||||
@ -249,11 +249,9 @@ handle_info({route_chan, Channel, Resource,
|
||||
NewStateData == stop ->
|
||||
{stop, normal, StateData};
|
||||
true ->
|
||||
case length(dict:fetch_keys(NewStateData#state.channels)) of
|
||||
0 ->
|
||||
{stop, normal, NewStateData};
|
||||
_ ->
|
||||
{next_state, StateName, NewStateData}
|
||||
case dict:fetch_keys(NewStateData#state.channels) of
|
||||
[] -> {stop, normal, NewStateData};
|
||||
_ -> {next_state, StateName, NewStateData}
|
||||
end
|
||||
end;
|
||||
|
||||
@ -787,7 +785,7 @@ process_channel_topic_who(StateData, Chan, String) ->
|
||||
Msg1 = case Words of
|
||||
[_, "333", _, _Chan, Whoset , Timeset] ->
|
||||
case string:to_integer(Timeset) of
|
||||
{Unixtimeset, _Rest} ->
|
||||
{Unixtimeset, _Rest} ->
|
||||
"Topic for #" ++ Chan ++ " set by " ++ Whoset ++
|
||||
" at " ++ unixtime2string(Unixtimeset);
|
||||
_->
|
||||
@ -1007,7 +1005,7 @@ process_topic(StateData, Chan, From, String) ->
|
||||
|
||||
process_part(StateData, Chan, From, String) ->
|
||||
[FromUser | FromIdent] = string:tokens(From, "!"),
|
||||
{ok, Msg, _} = regexp:sub(String, ".*PART[^:]*:", ""),
|
||||
{ok, Msg, _} = regexp:sub(String, ".*PART[^:]*:", ""),
|
||||
Msg1 = filter_message(Msg),
|
||||
ejabberd_router:route(
|
||||
jlib:make_jid(lists:concat([Chan, "%", StateData#state.server]),
|
||||
@ -1035,7 +1033,7 @@ process_part(StateData, Chan, From, String) ->
|
||||
|
||||
process_quit(StateData, From, String) ->
|
||||
[FromUser | FromIdent] = string:tokens(From, "!"),
|
||||
|
||||
|
||||
{ok, Msg, _} = regexp:sub(String, ".*QUIT[^:]*:", ""),
|
||||
Msg1 = filter_message(Msg),
|
||||
%%NewChans =
|
||||
@ -1301,7 +1299,7 @@ unixtime2string(Unixtime) ->
|
||||
Secs = Unixtime + calendar:datetime_to_gregorian_seconds(
|
||||
{{1970, 1, 1}, {0,0,0}}),
|
||||
case calendar:universal_time_to_local_time(
|
||||
calendar:gregorian_seconds_to_datetime(Secs)) of
|
||||
calendar:gregorian_seconds_to_datetime(Secs)) of
|
||||
{{Year, Month, Day}, {Hour, Minute, Second}} ->
|
||||
lists:flatten(
|
||||
io_lib:format("~4..0w-~2..0w-~2..0w ~2..0w:~2..0w:~2..0w",
|
||||
@ -1319,4 +1317,3 @@ toupper([C | Cs]) ->
|
||||
end;
|
||||
toupper([]) ->
|
||||
[].
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user