Comparison

plugins/muc/muc.lib.lua @ 2503:bb6b0bd7f2cf

MUC: Converted some local functions into methods.
author Waqas Hussain <waqas20@gmail.com>
date Tue, 26 Jan 2010 02:29:32 +0500
parent 2416:89be536aae25
child 2504:8b12ee9a5027
comparison
equal deleted inserted replaced
2502:ec3eaf54bbd4 2503:bb6b0bd7f2cf
181 if self._data['subject'] then 181 if self._data['subject'] then
182 self:_route_stanza(st.message({type='groupchat', from=self.jid, to=to}):tag("subject"):text(self._data['subject'])); 182 self:_route_stanza(st.message({type='groupchat', from=self.jid, to=to}):tag("subject"):text(self._data['subject']));
183 end 183 end
184 end 184 end
185 185
186 local function room_get_disco_info(self, stanza) 186 function room_mt:get_disco_info(stanza)
187 return st.reply(stanza):query("http://jabber.org/protocol/disco#info") 187 return st.reply(stanza):query("http://jabber.org/protocol/disco#info")
188 :tag("identity", {category="conference", type="text"}):up() 188 :tag("identity", {category="conference", type="text"}):up()
189 :tag("feature", {var="http://jabber.org/protocol/muc"}); 189 :tag("feature", {var="http://jabber.org/protocol/muc"});
190 end 190 end
191 local function room_get_disco_items(self, stanza) 191 function room_mt:get_disco_items(stanza)
192 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items"); 192 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items");
193 for room_jid in pairs(self._occupants) do 193 for room_jid in pairs(self._occupants) do
194 reply:tag("item", {jid = room_jid, name = room_jid:match("/(.*)")}):up(); 194 reply:tag("item", {jid = room_jid, name = room_jid:match("/(.*)")}):up();
195 end 195 end
196 return reply; 196 return reply;
500 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc 500 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc
501 local type = stanza.attr.type; 501 local type = stanza.attr.type;
502 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; 502 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns;
503 if stanza.name == "iq" then 503 if stanza.name == "iq" then
504 if xmlns == "http://jabber.org/protocol/disco#info" and type == "get" then 504 if xmlns == "http://jabber.org/protocol/disco#info" and type == "get" then
505 origin.send(room_get_disco_info(self, stanza)); 505 origin.send(self:get_disco_info(stanza));
506 elseif xmlns == "http://jabber.org/protocol/disco#items" and type == "get" then 506 elseif xmlns == "http://jabber.org/protocol/disco#items" and type == "get" then
507 origin.send(room_get_disco_items(self, stanza)); 507 origin.send(self:get_disco_items(stanza));
508 elseif xmlns == "http://jabber.org/protocol/muc#admin" then 508 elseif xmlns == "http://jabber.org/protocol/muc#admin" then
509 local actor = stanza.attr.from; 509 local actor = stanza.attr.from;
510 local affiliation = self:get_affiliation(actor); 510 local affiliation = self:get_affiliation(actor);
511 local current_nick = self._jid_nick[actor]; 511 local current_nick = self._jid_nick[actor];
512 local role = current_nick and self._occupants[current_nick].role or self:get_default_role(affiliation); 512 local role = current_nick and self._occupants[current_nick].role or self:get_default_role(affiliation);