Comparison

plugins/muc/muc.lib.lua @ 3259:a5b9209efb23

MUC: Replaced direct access of room's internal persistence state with :set_persistent(boolean) and :is_persistent() in various functions.
author Waqas Hussain <waqas20@gmail.com>
date Sun, 13 Jun 2010 21:41:49 +0500
parent 3258:bc07564bec6d
child 3260:19b655a8671c
comparison
equal deleted inserted replaced
3258:bc07564bec6d 3259:a5b9209efb23
480 :tag("x", {xmlns='jabber:x:data', type='form'}) 480 :tag("x", {xmlns='jabber:x:data', type='form'})
481 :tag("title"):text(title):up() 481 :tag("title"):text(title):up()
482 :tag("instructions"):text(title):up() 482 :tag("instructions"):text(title):up()
483 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up() 483 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up()
484 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'}) 484 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'})
485 :tag("value"):text(self._data.persistent and "1" or "0"):up() 485 :tag("value"):text(self:is_persistent() and "1" or "0"):up()
486 :up() 486 :up()
487 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'}) 487 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'})
488 :tag("value"):text(self._data.hidden and "0" or "1"):up() 488 :tag("value"):text(self._data.hidden and "0" or "1"):up()
489 :up() 489 :up()
490 :tag("field", {type='list-single', label='Who May Discover Real JIDs?', var='muc#roomconfig_whois'}) 490 :tag("field", {type='list-single', label='Who May Discover Real JIDs?', var='muc#roomconfig_whois'})
531 local dirty = false 531 local dirty = false
532 532
533 local persistent = fields['muc#roomconfig_persistentroom']; 533 local persistent = fields['muc#roomconfig_persistentroom'];
534 if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true; 534 if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true;
535 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end 535 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end
536 dirty = dirty or (self._data.persistent ~= persistent) 536 dirty = dirty or (self:is_persistent() ~= persistent)
537 self._data.persistent = persistent;
538 module:log("debug", "persistent=%s", tostring(persistent)); 537 module:log("debug", "persistent=%s", tostring(persistent));
539 538
540 local moderated = fields['muc#roomconfig_moderatedroom']; 539 local moderated = fields['muc#roomconfig_moderatedroom'];
541 if moderated == "0" or moderated == "false" then moderated = nil; elseif moderated == "1" or moderated == "true" then moderated = true; 540 if moderated == "0" or moderated == "false" then moderated = nil; elseif moderated == "1" or moderated == "true" then moderated = true;
542 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end 541 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end
568 if password then 567 if password then
569 self:set_password(password); 568 self:set_password(password);
570 end 569 end
571 self:set_moderated(moderated); 570 self:set_moderated(moderated);
572 self:set_members_only(membersonly); 571 self:set_members_only(membersonly);
572 self:set_persistent(persistent);
573 573
574 if self.save then self:save(true); end 574 if self.save then self:save(true); end
575 origin.send(st.reply(stanza)); 575 origin.send(st.reply(stanza));
576 576
577 if dirty or whois_changed then 577 if dirty or whois_changed then
604 self:_route_stanza(pr); 604 self:_route_stanza(pr);
605 self._jid_nick[jid] = nil; 605 self._jid_nick[jid] = nil;
606 end 606 end
607 self._occupants[nick] = nil; 607 self._occupants[nick] = nil;
608 end 608 end
609 self._data.persistent = nil; 609 self:set_persistent(false);
610 if self.save then self:save(true); end
611 end 610 end
612 611
613 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc 612 function room_mt:handle_to_room(origin, stanza) -- presence changes and groupchat messages, along with disco/etc
614 local type = stanza.attr.type; 613 local type = stanza.attr.type;
615 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns; 614 local xmlns = stanza.tags[1] and stanza.tags[1].attr.xmlns;