Comparison

plugins/muc/muc.lib.lua @ 1764:c00d4ba8d2f3

MUC: Removed commented code.
author Waqas Hussain <waqas20@gmail.com>
date Wed, 09 Sep 2009 19:14:12 +0500
parent 1757:157e438823ba
child 1768:802c40384dd0
comparison
equal deleted inserted replaced
1763:9e4ff3b66ed1 1764:c00d4ba8d2f3
583 _affiliations = {}; 583 _affiliations = {};
584 }, room_mt); 584 }, room_mt);
585 end 585 end
586 586
587 return _M; 587 return _M;
588
589 --[[function get_disco_info(stanza)
590 return st.iq({type='result', id=stanza.attr.id, from=muc_domain, to=stanza.attr.from}):query("http://jabber.org/protocol/disco#info")
591 :tag("identity", {category='conference', type='text', name=muc_name}):up()
592 :tag("feature", {var="http://jabber.org/protocol/muc"}); -- TODO cache disco reply
593 end
594 function get_disco_items(stanza)
595 local reply = st.iq({type='result', id=stanza.attr.id, from=muc_domain, to=stanza.attr.from}):query("http://jabber.org/protocol/disco#items");
596 for room in pairs(rooms_info:get()) do
597 reply:tag("item", {jid=room, name=rooms_info:get(room, "name")}):up();
598 end
599 return reply; -- TODO cache disco reply
600 end]]
601
602 --[[function handle_to_domain(origin, stanza)
603 local type = stanza.attr.type;
604 if type == "error" or type == "result" then return; end
605 if stanza.name == "iq" and type == "get" then
606 local xmlns = stanza.tags[1].attr.xmlns;
607 if xmlns == "http://jabber.org/protocol/disco#info" then
608 origin.send(get_disco_info(stanza));
609 elseif xmlns == "http://jabber.org/protocol/disco#items" then
610 origin.send(get_disco_items(stanza));
611 else
612 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- TODO disco/etc
613 end
614 else
615 origin.send(st.error_reply(stanza, "cancel", "service-unavailable", "The muc server doesn't deal with messages and presence directed at it"));
616 end
617 end
618
619 register_component(muc_domain, function(origin, stanza)
620 local to_node, to_host, to_resource = jid_split(stanza.attr.to);
621 if to_resource and not to_node then
622 if type == "error" or type == "result" then return; end
623 origin.send(st.error_reply(stanza, "cancel", "service-unavailable")); -- host/resource
624 elseif to_resource then
625 handle_to_occupant(origin, stanza);
626 elseif to_node then
627 handle_to_room(origin, stanza)
628 else -- to the main muc domain
629 if type == "error" or type == "result" then return; end
630 handle_to_domain(origin, stanza);
631 end
632 end);]]
633
634 --[[module.unload = function()
635 deregister_component(muc_domain);
636 end
637 module.save = function()
638 return {rooms = rooms.data; jid_nick = jid_nick.data; rooms_info = rooms_info.data; persist_list = persist_list};
639 end
640 module.restore = function(data)
641 rooms.data, jid_nick.data, rooms_info.data, persist_list =
642 data.rooms or {}, data.jid_nick or {}, data.rooms_info or {}, data.persist_list or {};
643 end]]