Changeset

3509:72cb8b6536b9

Merge with trunk.
author Waqas Hussain <waqas20@gmail.com>
date Mon, 27 Sep 2010 19:51:14 +0500
parents 3506:0f46acca11cc (current diff) 3508:9e4c2b048f9a (diff)
children 3510:711eb5bf94b4
files plugins/muc/muc.lib.lua
diffstat 1 files changed, 45 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/plugins/muc/muc.lib.lua	Mon Sep 27 19:00:11 2010 +0500
+++ b/plugins/muc/muc.lib.lua	Mon Sep 27 19:51:14 2010 +0500
@@ -212,7 +212,7 @@
 
 function room_mt:get_disco_info(stanza)
 	return st.reply(stanza):query("http://jabber.org/protocol/disco#info")
-		:tag("identity", {category="conference", type="text"}):up()
+		:tag("identity", {category="conference", type="text", name=self:get_name()}):up()
 		:tag("feature", {var="http://jabber.org/protocol/muc"}):up()
 		:tag("feature", {var=self:get_password() and "muc_passwordprotected" or "muc_unsecured"}):up()
 		:tag("feature", {var=self:is_moderated() and "muc_moderated" or "muc_unmoderated"}):up()
@@ -220,6 +220,14 @@
 		:tag("feature", {var=self:is_persistent() and "muc_persistent" or "muc_temporary"}):up()
 		:tag("feature", {var=self:is_hidden() and "muc_hidden" or "muc_public"}):up()
 		:tag("feature", {var=self._data.whois ~= "anyone" and "muc_semianonymous" or "muc_nonanonymous"}):up()
+		:tag("x", {xmlns="jabber:x:data", type="result"})
+			:tag("field", {var="FORM_TYPE", type="hidden"})
+				:tag("value"):text("http://jabber.org/protocol/muc#roominfo"):up()
+			:up()
+			:tag("field", {var="muc#roominfo_description", label="Description"})
+				:tag("value"):text(self:get_description()):up()
+			:up()
+		:up()	
 	;
 end
 function room_mt:get_disco_items(stanza)
@@ -251,6 +259,26 @@
 		:tag('status'):text(error_message);
 end
 
+function room_mt:set_name(name)
+	if name == "" or type(name) ~= "string" then name = nil; end
+	if self._data.name ~= name then
+		self._data.name = name;
+		if self.save then self:save(true); end
+	end
+end
+function room_mt:get_name()
+	return self._data.name;
+end
+function room_mt:set_description(description)
+	if description == "" or type(description) ~= "string" then description = nil; end
+	if self._data.description ~= description then
+		self._data.description = description;
+		if self.save then self:save(true); end
+	end
+end
+function room_mt:get_description()
+	return self._data.description;
+end
 function room_mt:set_password(password)
 	if password == "" or type(password) ~= "string" then password = nil; end
 	if self._data.password ~= password then
@@ -502,6 +530,12 @@
 			:tag("title"):text(title):up()
 			:tag("instructions"):text(title):up()
 			:tag("field", {type='hidden', var='FORM_TYPE'}):tag("value"):text("http://jabber.org/protocol/muc#roomconfig"):up():up()
+			:tag("field", {type='text-single', label='Name', var='muc#roomconfig_roomname'})
+				:tag("value"):text(self:get_name() or ""):up()
+			:up()
+			:tag("field", {type='text-single', label='Description', var='muc#roomconfig_roomdesc'})
+				:tag("value"):text(self:get_description() or ""):up()
+			:up()
 			:tag("field", {type='boolean', label='Make Room Persistent?', var='muc#roomconfig_persistentroom'})
 				:tag("value"):text(self:is_persistent() and "1" or "0"):up()
 			:up()
@@ -551,6 +585,16 @@
 
 	local dirty = false
 
+	local name = fields['muc#roomconfig_roomname'];
+	if name then
+		self:set_name(name);
+	end
+
+	local description = fields['muc#roomconfig_roomdesc'];
+	if description then
+		self:set_description(description);
+	end
+
 	local persistent = fields['muc#roomconfig_persistentroom'];
 	if persistent == "0" or persistent == "false" then persistent = nil; elseif persistent == "1" or persistent == "true" then persistent = true;
 	else origin.send(st.error_reply(stanza, "cancel", "bad-request")); return; end