summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Shchepin <alexey@process-one.net>2003-02-24 20:39:14 +0000
committerAlexey Shchepin <alexey@process-one.net>2003-02-24 20:39:14 +0000
commit65fb70c11f6913fb25960136ed483f1c1b95ff02 (patch)
tree2ce509d841865a519be53571ef5acd38cfe1c3a0
parent* src/mod_irc/: Added configuration interface (diff)
* src/mod_irc/mod_irc_connection.erl: /kick support
SVN Revision: 83
-rw-r--r--ChangeLog4
-rw-r--r--src/mod_irc/mod_irc_connection.erl94
-rw-r--r--src/namespaces.hrl2
3 files changed, 100 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 54668582..0a49caeb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+2003-02-24 Alexey Shchepin <alexey@sevcom.net>
+
+ * src/mod_irc/mod_irc_connection.erl: /kick support
+
2003-02-23 Alexey Shchepin <alexey@sevcom.net>
* src/mod_irc/: Added configuration interface
diff --git a/src/mod_irc/mod_irc_connection.erl b/src/mod_irc/mod_irc_connection.erl
index ed1a46e7..2e2a4eb8 100644
--- a/src/mod_irc/mod_irc_connection.erl
+++ b/src/mod_irc/mod_irc_connection.erl
@@ -257,6 +257,26 @@ handle_info({route_chan, Channel, Resource,
end,
{next_state, StateName, NewStateData};
+
+handle_info({route_chan, Channel, Resource,
+ {xmlelement, "iq", Attrs, Els} = El},
+ StateName, StateData) ->
+ From = StateData#state.user,
+ To = {lists:concat([Channel, "%", StateData#state.server]),
+ StateData#state.myname, StateData#state.nick},
+ case jlib:iq_query_info(El) of
+ {iq, ID, Type, ?NS_MUC_ADMIN = XMLNS, SubEl} ->
+ iq_admin(StateData, Channel,
+ From,
+ To,
+ ID, XMLNS, Type, SubEl);
+ _ ->
+ Err = jlib:make_error_reply(
+ El, "503", "Service Unavailable"),
+ ejabberd_router:route(To, From, Err)
+ end,
+ {next_state, StateName, StateData};
+
handle_info({route_chan, Channel, Resource, Packet}, StateName, StateData) ->
{next_state, StateName, StateData};
@@ -737,3 +757,77 @@ remove_element(E, Set) ->
_ ->
Set
end.
+
+
+
+iq_admin(StateData, Channel, From, To, ID, XMLNS, Type, SubEl) ->
+ case catch process_iq_admin(StateData, Channel, Type, SubEl) of
+ {'EXIT', Reason} ->
+ ?ERROR_MSG("~p", [Reason]);
+ Res ->
+ if
+ Res /= ignore ->
+ ResIQ = case Res of
+ {result, ResEls} ->
+ {iq, ID, result, XMLNS,
+ [{xmlelement, "query",
+ [{"xmlns", XMLNS}],
+ ResEls
+ }]};
+ {error, Code, Desc} ->
+ {iq, ID, error, XMLNS,
+ [SubEl, {xmlelement, "error",
+ [{"code", Code}],
+ [{xmlcdata, Desc}]}]}
+ end,
+ ejabberd_router:route(To, From,
+ jlib:iq_to_xml(ResIQ));
+ true ->
+ ok
+ end
+ end.
+
+
+process_iq_admin(StateData, Channel, set, SubEl) ->
+ case xml:get_subtag(SubEl, "item") of
+ false ->
+ {error, "400", "Bad Request"};
+ ItemEl ->
+ Nick = xml:get_tag_attr_s("nick", ItemEl),
+ Affiliation = xml:get_tag_attr_s("affiliation", ItemEl),
+ Role = xml:get_tag_attr_s("role", ItemEl),
+ Reason = xml:get_path_s(ItemEl, [{elem, "reason"}, cdata]),
+ process_admin(StateData, Channel, Nick, Affiliation, Role, Reason)
+ end;
+process_iq_admin(StateData, Channel, get, SubEl) ->
+ {error, "501", "Not Implemented"}.
+
+
+
+process_admin(StateData, Channel, "", Affiliation, Role, Reason) ->
+ {error, "501", "Not Implemented"};
+
+process_admin(StateData, Channel, Nick, Affiliation, "none", Reason) ->
+ case Reason of
+ "" ->
+ send_text(StateData,
+ io_lib:format("KICK #~s ~s\r\n",
+ [Channel, Nick]));
+ _ ->
+ send_text(StateData,
+ io_lib:format("KICK #~s ~s :~s\r\n",
+ [Channel, Nick, Reason]))
+ end,
+ {result, []};
+
+
+
+process_admin(StateData, Channel, Nick, Affiliation, Role, Reason) ->
+ {error, "501", "Not Implemented"}.
+
+
+
+
+
+
+
diff --git a/src/namespaces.hrl b/src/namespaces.hrl
index 397ee782..c134a62b 100644
--- a/src/namespaces.hrl
+++ b/src/namespaces.hrl
@@ -22,5 +22,7 @@
-define(NS_STATS, "http://jabber.org/protocol/stats").
-define(NS_MUC, "http://jabber.org/protocol/muc").
-define(NS_MUC_USER, "http://jabber.org/protocol/muc#user").
+-define(NS_MUC_ADMIN, "http://jabber.org/protocol/muc#admin").
+-define(NS_MUC_OWNER, "http://jabber.org/protocol/muc#owner").