Comparison

plugins/muc/muc.lib.lua @ 3509:72cb8b6536b9

Merge with trunk.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 27 Sep 2010 19:51:14 +0500
parent 3506:0f46acca11cc
parent 3508:9e4c2b048f9a
child 3510:711eb5bf94b4
comparison
equal deleted inserted replaced
3506:0f46acca11cc 3509:72cb8b6536b9
210 end 210 end
211 end 211 end
212 212
213 function room_mt:get_disco_info(stanza) 213 function room_mt:get_disco_info(stanza)
214 return st.reply(stanza):query("http://jabber.org/protocol/disco#info") 214 return st.reply(stanza):query("http://jabber.org/protocol/disco#info")
215 :tag("identity", {category="conference", type="text"}):up() 215 :tag("identity", {category="conference", type="text", name=self:get_name()}):up()
216 :tag("feature", {var="http://jabber.org/protocol/muc"}):up() 216 :tag("feature", {var="http://jabber.org/protocol/muc"}):up()
217 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up() 217 :tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up()
218 :tag("feature", {var=self:is_moderated() and "muc_moderated" or "muc_unmoderated"}):up() 218 :tag("feature", {var=self:is_moderated() and "muc_moderated" or "muc_unmoderated"}):up()
219 :tag("feature", {var=self:is_members_only() and "muc_membersonly" or "muc_open"}):up() 219 :tag("feature", {var=self:is_members_only() and "muc_membersonly" or "muc_open"}):up()
220 :tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up() 220 :tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up()
221 :tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up() 221 :tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up()
222 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up() 222 :tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up()
223 :tag("x", {xmlns="jabber:x:data", type="result"})
224 :tag("field", {var="FORM_TYPE", type="hidden"})
225 :tag("value"):text("http://jabber.org/protocol/muc#roominfo"):up()
226 :up()
227 :tag("field", {var="muc#roominfo_description", label="Description"})
228 :tag("value"):text(self:get_description()):up()
229 :up()
230 :up()
223 ; 231 ;
224 end 232 end
225 function room_mt:get_disco_items(stanza) 233 function room_mt:get_disco_items(stanza)
226 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items"); 234 local reply = st.reply(stanza):query("http://jabber.org/protocol/disco#items");
227 for room_jid in pairs(self._occupants) do 235 for room_jid in pairs(self._occupants) do
249 end 257 end
250 return st.presence({type='unavailable', from=stanza.attr.from, to=stanza.attr.to}) 258 return st.presence({type='unavailable', from=stanza.attr.from, to=stanza.attr.to})
251 :tag('status'):text(error_message); 259 :tag('status'):text(error_message);
252 end 260 end
253 261
262 function room_mt:set_name(name)
263 if name == "" or type(name) ~= "string" then name = nil; end
264 if self._data.name ~= name then
265 self._data.name = name;
266 if self.save then self:save(true); end
267 end
268 end
269 function room_mt:get_name()
270 return self._data.name;
271 end
272 function room_mt:set_description(description)
273 if description == "" or type(description) ~= "string" then description = nil; end
274 if self._data.description ~= description then
275 self._data.description = description;
276 if self.save then self:save(true); end
277 end
278 end
279 function room_mt:get_description()
280 return self._data.description;
281 end
254 function room_mt:set_password(password) 282 function room_mt:set_password(password)
255 if password == "" or type(password) ~= "string" then password = nil; end 283 if password == "" or type(password) ~= "string" then password = nil; end
256 if self._data.password ~= password then 284 if self._data.password ~= password then
257 self._data.password = password; 285 self._data.password = password;
258 if self.save then self:save(true); end 286 if self.save then self:save(true); end
500 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner") 528 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner")
501 :tag("x", {xmlns='jabber:x:data', type='form'}) 529 :tag("x", {xmlns='jabber:x:data', type='form'})
502 :tag("title"):text(title):up() 530 :tag("title"):text(title):up()
503 :tag("instructions"):text(title):up() 531 :tag("instructions"):text(title):up()
504 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up() 532 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up()
533 :tag("field", {type='text-single', label='Name', var='muc#roomconfig_roomname'})
534 :tag("value"):text(self:get_name() or ""):up()
535 :up()
536 :tag("field", {type='text-single', label='Description', var='muc#roomconfig_roomdesc'})
537 :tag("value"):text(self:get_description() or ""):up()
538 :up()
505 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'}) 539 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'})
506 :tag("value"):text(self:is_persistent() and "1" or "0"):up() 540 :tag("value"):text(self:is_persistent() and "1" or "0"):up()
507 :up() 541 :up()
508 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'}) 542 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'})
509 :tag("value"):text(self:is_hidden() and "0" or "1"):up() 543 :tag("value"):text(self:is_hidden() and "0" or "1"):up()
548 end 582 end
549 end 583 end
550 if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end 584 if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end
551 585
552 local dirty = false 586 local dirty = false
587
588 local name = fields['muc#roomconfig_roomname'];
589 if name then
590 self:set_name(name);
591 end
592
593 local description = fields['muc#roomconfig_roomdesc'];
594 if description then
595 self:set_description(description);
596 end
553 597
554 local persistent = fields['muc#roomconfig_persistentroom']; 598 local persistent = fields['muc#roomconfig_persistentroom'];
555 if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true; 599 if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true;
556 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end 600 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end
557 dirty = dirty or (self:is_persistent() ~= persistent) 601 dirty = dirty or (self:is_persistent() ~= persistent)