summaryrefslogtreecommitdiff
path: root/src/mod_muc
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2003-12-17 20:13:21 +0000
committerAlexey Shchepin <alexey@process-one.net>2003-12-17 20:13:21 +0000
commitb3b09bcfd83ce7afe5349259a421e6424440df1c (patch)
tree2156729d2e4843e1eb0a262aa14664c76a35595e /src/mod_muc
parent* src/ejabberd_local.erl: Replaced register_local_route to (diff)
* src/jlib.hrl: Added declaration of "iq" record
* (all): Updated to use "iq" record SVN Revision: 186
Diffstat (limited to 'src/mod_muc')
-rw-r--r--src/mod_muc/mod_muc.erl77
-rw-r--r--src/mod_muc/mod_muc_room.erl15
2 files changed, 52 insertions, 40 deletions
diff --git a/src/mod_muc/mod_muc.erl b/src/mod_muc/mod_muc.erl
index 7f1c5360..cda26eb6 100644
--- a/src/mod_muc/mod_muc.erl
+++ b/src/mod_muc/mod_muc.erl
@@ -19,7 +19,7 @@
store_room/2,
restore_room/1,
forget_room/1,
- process_iq_disco_items/5,
+ process_iq_disco_items/4,
can_use_nick/2]).
-include("ejabberd.hrl").
@@ -84,36 +84,44 @@ do_route(Host, From, To, Packet) ->
case Name of
"iq" ->
case jlib:iq_query_info(Packet) of
- {iq, ID, get, ?NS_DISCO_INFO = XMLNS, SubEl} ->
- Res = {iq, ID, result, XMLNS,
- [{xmlelement, "query",
- [{"xmlns", XMLNS}],
- iq_disco_info()}]},
+ #iq{type = get, xmlns = ?NS_DISCO_INFO = XMLNS,
+ sub_el = SubEl} = IQ ->
+ Res = IQ#iq{type = result,
+ sub_el = [{xmlelement, "query",
+ [{"xmlns", XMLNS}],
+ iq_disco_info()}]},
ejabberd_router:route(To,
From,
jlib:iq_to_xml(Res));
- {iq, ID, get, ?NS_DISCO_ITEMS = XMLNS, SubEl} ->
+ #iq{type = get,
+ xmlns = ?NS_DISCO_ITEMS} = IQ ->
spawn(?MODULE,
process_iq_disco_items,
- [Host, From, To, ID, SubEl]);
- {iq, ID, get, ?NS_REGISTER = XMLNS, SubEl} ->
+ [Host, From, To, IQ]);
+ #iq{type = get,
+ xmlns = ?NS_REGISTER = XMLNS,
+ sub_el = SubEl} = IQ ->
Lang = xml:get_tag_attr_s(
"xml:lang", SubEl),
- Res = {iq, ID, result, XMLNS,
- [{xmlelement, "query",
- [{"xmlns", XMLNS}],
- iq_get_register_info(
- From, Lang)}]},
+ Res = IQ#iq{type = result,
+ sub_el =
+ [{xmlelement, "query",
+ [{"xmlns", XMLNS}],
+ iq_get_register_info(
+ From, Lang)}]},
ejabberd_router:route(To,
From,
jlib:iq_to_xml(Res));
- {iq, ID, set, ?NS_REGISTER = XMLNS, SubEl} ->
+ #iq{type = set,
+ xmlns = ?NS_REGISTER = XMLNS,
+ sub_el = SubEl} = IQ ->
case process_iq_register_set(From, SubEl) of
{result, IQRes} ->
- Res = {iq, ID, result, XMLNS,
- [{xmlelement, "query",
- [{"xmlns", XMLNS}],
- IQRes}]},
+ Res = IQ#iq{type = result,
+ sub_el =
+ [{xmlelement, "query",
+ [{"xmlns", XMLNS}],
+ IQRes}]},
ejabberd_router:route(
To, From, jlib:iq_to_xml(Res));
{error, Error} ->
@@ -122,23 +130,26 @@ do_route(Host, From, To, Packet) ->
ejabberd_router:route(
To, From, Err)
end;
- {iq, ID, get, ?NS_VCARD = XMLNS, SubEl} ->
+ #iq{type = get,
+ xmlns = ?NS_VCARD = XMLNS,
+ sub_el = SubEl} = IQ ->
Lang = xml:get_tag_attr_s(
"xml:lang", SubEl),
- Res = {iq, ID, result, XMLNS,
- [{xmlelement, "query",
- [{"xmlns", XMLNS}],
- iq_get_vcard(Lang)}]},
+ Res = IQ#iq{type = result,
+ sub_el =
+ [{xmlelement, "query",
+ [{"xmlns", XMLNS}],
+ iq_get_vcard(Lang)}]},
ejabberd_router:route(To,
From,
jlib:iq_to_xml(Res));
- reply ->
- ok;
- _ ->
+ #iq{} ->
Err = jlib:make_error_reply(
Packet,
?ERR_FEATURE_NOT_IMPLEMENTED),
- ejabberd_router:route(To, From, Err)
+ ejabberd_router:route(To, From, Err);
+ _ ->
+ ok
end;
"message" ->
case xml:get_attr_s("type", Attrs) of
@@ -265,11 +276,11 @@ iq_disco_info() ->
{xmlelement, "feature", [{"var", ?NS_VCARD}], []}].
-process_iq_disco_items(Host, From, To, ID, SubEl) ->
- Res = {iq, ID, result, ?NS_DISCO_ITEMS,
- [{xmlelement, "query",
- [{"xmlns", ?NS_DISCO_ITEMS}],
- iq_disco_items(Host, From)}]},
+process_iq_disco_items(Host, From, To, IQ) ->
+ Res = IQ#iq{type = result,
+ sub_el = [{xmlelement, "query",
+ [{"xmlns", ?NS_DISCO_ITEMS}],
+ iq_disco_items(Host, From)}]},
ejabberd_router:route(To,
From,
jlib:iq_to_xml(Res)).
diff --git a/src/mod_muc/mod_muc_room.erl b/src/mod_muc/mod_muc_room.erl
index f9affed9..d8af30c3 100644
--- a/src/mod_muc/mod_muc_room.erl
+++ b/src/mod_muc/mod_muc_room.erl
@@ -271,7 +271,7 @@ normal_state({route, From, "",
{xmlelement, "iq", Attrs, Els} = Packet},
StateData) ->
case jlib:iq_query_info(Packet) of
- {iq, ID, Type, XMLNS, SubEl} when
+ #iq{type = Type, xmlns = XMLNS, sub_el = SubEl} = IQ when
(XMLNS == ?NS_MUC_ADMIN) or
(XMLNS == ?NS_MUC_OWNER) or
(XMLNS == ?NS_DISCO_INFO) or
@@ -289,14 +289,15 @@ normal_state({route, From, "",
{IQRes, NewStateData} =
case Res1 of
{result, Res, SD} ->
- {{iq, ID, result, XMLNS,
- [{xmlelement, "query", [{"xmlns", XMLNS}],
- Res
- }]},
+ {IQ#iq{type = result,
+ sub_el = [{xmlelement, "query",
+ [{"xmlns", XMLNS}],
+ Res
+ }]},
SD};
{error, Error} ->
- {{iq, ID, error, XMLNS,
- [SubEl, Error]},
+ {IQ#iq{type = error,
+ sub_el = [SubEl, Error]},
StateData}
end,
ejabberd_router:route(StateData#state.jid,