Comparison

plugins/muc/muc.lib.lua @ 3507:b639042bb0d5

MUC: Added a 'Name' property (muc#roomconfig_roomname)
author Kim Alvefur <zash@zash.se>
date Fri, 24 Sep 2010 21:16:38 +0200
parent 3446:9c0b3cd890e9
child 3508:9e4c2b048f9a
comparison
equal deleted inserted replaced
3505:eb2f36dc0369 3507:b639042bb0d5
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()
249 end 249 end
250 return st.presence({type='unavailable', from=stanza.attr.from, to=stanza.attr.to}) 250 return st.presence({type='unavailable', from=stanza.attr.from, to=stanza.attr.to})
251 :tag('status'):text(error_message); 251 :tag('status'):text(error_message);
252 end 252 end
253 253
254 function room_mt:set_name(name)
255 if name == "" or type(name) ~= "string" then name = nil; end
256 if self._data.name ~= name then
257 self._data.name = name;
258 if self.save then self:save(true); end
259 end
260 end
261 function room_mt:get_name()
262 return self._data.name;
263 end
254 function room_mt:set_password(password) 264 function room_mt:set_password(password)
255 if password == "" or type(password) ~= "string" then password = nil; end 265 if password == "" or type(password) ~= "string" then password = nil; end
256 if self._data.password ~= password then 266 if self._data.password ~= password then
257 self._data.password = password; 267 self._data.password = password;
258 if self.save then self:save(true); end 268 if self.save then self:save(true); end
499 local title = "Configuration for "..self.jid; 509 local title = "Configuration for "..self.jid;
500 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner") 510 origin.send(st.reply(stanza):query("http://jabber.org/protocol/muc#owner")
501 :tag("x", {xmlns='jabber:x:data', type='form'}) 511 :tag("x", {xmlns='jabber:x:data', type='form'})
502 :tag("title"):text(title):up() 512 :tag("title"):text(title):up()
503 :tag("instructions"):text(title):up() 513 :tag("instructions"):text(title):up()
514 :tag("field", {type='text-single', label='Room Title', var='muc#roomconfig_roomname'})
515 :tag("value"):text(self:get_name() or ""):up()
516 :up()
504 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up() 517 :tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up()
505 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'}) 518 :tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'})
506 :tag("value"):text(self:is_persistent() and "1" or "0"):up() 519 :tag("value"):text(self:is_persistent() and "1" or "0"):up()
507 :up() 520 :up()
508 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'}) 521 :tag("field", {type='boolean', label='Make Room Publicly Searchable?', var='muc#roomconfig_publicroom'})
548 end 561 end
549 end 562 end
550 if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end 563 if fields.FORM_TYPE ~= "http://jabber.org/protocol/muc#roomconfig" then origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end
551 564
552 local dirty = false 565 local dirty = false
566
567 local name = fields['muc#roomconfig_roomname'];
568 if name then
569 self:set_name(name);
570 end
553 571
554 local persistent = fields['muc#roomconfig_persistentroom']; 572 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; 573 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 574 else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end
557 dirty = dirty or (self:is_persistent() ~= persistent) 575 dirty = dirty or (self:is_persistent() ~= persistent)