mirror of
https://github.com/processone/ejabberd.git
synced 2024-11-24 16:23:40 +01:00
*** empty log message ***
SVN Revision: 19
This commit is contained in:
parent
00a923b14a
commit
0e363bf8cb
@ -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,7 +546,14 @@ 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.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -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.
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user