25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-22 16:20:52 +01:00

*** empty log message ***

SVN Revision: 19
This commit is contained in:
Alexey Shchepin 2002-12-18 20:26:08 +00:00
parent 00a923b14a
commit 0e363bf8cb
2 changed files with 69 additions and 6 deletions

View File

@ -181,7 +181,8 @@ session_established({xmlstreamelement, El}, StateData) ->
[FromJID, El, StateData]), [FromJID, El, StateData]),
presence_update(FromJID, El, StateData); presence_update(FromJID, El, StateData);
_ -> _ ->
StateData ejabberd_router:route(FromJID, ToJID, El),
presence_track(FromJID, ToJID, El, StateData)
end; end;
_ -> _ ->
ejabberd_router:route(FromJID, ToJID, El), ejabberd_router:route(FromJID, ToJID, El),
@ -245,7 +246,7 @@ handle_info({send_text, Text}, StateName, StateData) ->
{next_state, StateName, StateData}; {next_state, StateName, StateData};
handle_info({route, From, To, Packet}, StateName, StateData) -> handle_info({route, From, To, Packet}, StateName, StateData) ->
{xmlelement, Name, Attrs, Els} = Packet, {xmlelement, Name, Attrs, Els} = Packet,
% TODO {FU, FS, FR} = From,
{Pass, NewAttrs, NewState} = {Pass, NewAttrs, NewState} =
case Name of case Name of
"presence" -> "presence" ->
@ -266,10 +267,24 @@ handle_info({route, From, To, Packet}, StateName, StateData) ->
Attrs1 = lists:keydelete("type", 1, Attrs), Attrs1 = lists:keydelete("type", 1, Attrs),
{true, [{"type", "unavailable"} | Attrs1], StateData}; {true, [{"type", "unavailable"} | Attrs1], StateData};
"subscribe" -> "subscribe" ->
% TODO mod_roster:in_subscription(StateData#state.user,
{FU, FS, ""},
subscribe),
{true, Attrs, StateData};
"subscribed" ->
mod_roster:in_subscription(StateData#state.user,
{FU, FS, ""},
subscribed),
{true, Attrs, StateData}; {true, Attrs, StateData};
"unsubscribe" -> "unsubscribe" ->
% TODO mod_roster:in_subscription(StateData#state.user,
{FU, FS, ""},
unsubscribe),
{true, Attrs, StateData};
"unsubscribed" ->
mod_roster:in_subscription(StateData#state.user,
{FU, FS, ""},
unsubscribed),
{true, Attrs, StateData}; {true, Attrs, StateData};
_ -> _ ->
{true, Attrs, StateData} {true, Attrs, StateData}
@ -462,6 +477,33 @@ presence_update(From, Packet, StateData) ->
} }
end. end.
presence_track(From, To, Packet, StateData) ->
{xmlelement, Name, Attrs, Els} = Packet,
case xml:get_attr_s("type", Attrs) of
"unavailable" ->
I = remove_element(To, StateData#state.pres_i),
A = remove_element(To, StateData#state.pres_a),
StateData#state{pres_i = I,
pres_a = A};
"invisible" ->
I = ?SETS:add_element(To, StateData#state.pres_i),
A = remove_element(To, StateData#state.pres_a),
StateData#state{pres_i = I,
pres_a = A};
"subscribe" ->
StateData;
"subscribed" ->
StateData;
"unsubscribe" ->
StateData;
"unsubscribed" ->
StateData;
_ ->
I = remove_element(To, StateData#state.pres_i),
A = ?SETS:add_element(To, StateData#state.pres_a),
StateData#state{pres_i = I,
pres_a = A}
end.
presence_broadcast(From, JIDSet, Packet) -> presence_broadcast(From, JIDSet, Packet) ->
lists:foreach(fun(JID) -> lists:foreach(fun(JID) ->
@ -504,6 +546,13 @@ presence_broadcast_first(From, StateData, Packet) ->
end. end.
remove_element(E, Set) ->
case ?SETS:is_element(E, Set) of
true ->
?SETS:del_element(E, Set);
_ ->
Set
end.

View File

@ -14,7 +14,8 @@
-export([start/0, init/0, -export([start/0, init/0,
process_iq/3, process_iq/3,
get_subscription_lists/1]). get_subscription_lists/1,
in_subscription/3]).
-include_lib("mnemosyne/include/mnemosyne.hrl"). -include_lib("mnemosyne/include/mnemosyne.hrl").
-include("ejabberd.hrl"). -include("ejabberd.hrl").
@ -273,3 +274,16 @@ fill_subscription_lists([], F, T) ->
{F, T}. {F, T}.
in_subscription(User, From, Type) ->
LUser = jlib:tolower(User),
F = fun() ->
mnesia:read({roster, LUser})
end,
case mnesia:transaction(F) of
{atomic, Items} ->
% TODO
ok;
_ ->
ok
end.