IQOwnerHandler.java 28.7 KB
Newer Older
1 2 3 4
/**
 * $Revision: 1623 $
 * $Date: 2005-07-12 18:40:57 -0300 (Tue, 12 Jul 2005) $
 *
5
 * Copyright (C) 2004-2008 Jive Software. All rights reserved.
6
 *
7 8 9 10 11 12 13 14 15 16 17
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
18 19
 */

20 21
package org.jivesoftware.openfire.muc.spi;

22 23 24 25
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

26 27 28 29
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.QName;
import org.jivesoftware.openfire.PacketRouter;
30 31 32 33
import org.jivesoftware.openfire.group.Group;
import org.jivesoftware.openfire.group.GroupJID;
import org.jivesoftware.openfire.group.GroupManager;
import org.jivesoftware.openfire.group.GroupNotFoundException;
34
import org.jivesoftware.openfire.muc.CannotBeInvitedException;
35 36 37
import org.jivesoftware.openfire.muc.ConflictException;
import org.jivesoftware.openfire.muc.ForbiddenException;
import org.jivesoftware.openfire.muc.MUCRole;
38
import org.jivesoftware.openfire.muc.cluster.RoomUpdatedEvent;
39
import org.jivesoftware.util.JiveGlobals;
40 41
import org.jivesoftware.util.LocaleUtils;
import org.jivesoftware.util.cache.CacheFactory;
42 43
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
44 45 46
import org.xmpp.forms.DataForm;
import org.xmpp.forms.FormField;
import org.xmpp.forms.FormField.Type;
47
import org.xmpp.packet.IQ;
48
import org.xmpp.packet.JID;
49
import org.xmpp.packet.PacketError;
50 51
import org.xmpp.packet.Presence;

52 53 54 55 56 57 58 59
/**
 * A handler for the IQ packet with namespace http://jabber.org/protocol/muc#owner. This kind of 
 * packets are usually sent by room owners. So this handler provides the necessary functionality
 * to support owner requirements such as: room configuration and room destruction.
 *
 * @author Gaston Dombiak
 */
public class IQOwnerHandler {
60 61 62
	
	private static final Logger Log = LoggerFactory.getLogger(IQOwnerHandler.class);

63
    private final LocalMUCRoom room;
64

65
    private final PacketRouter router;
66

67
    private DataForm configurationForm;
68 69 70

    private Element probeResult;

71
    private final boolean skipInvite;
72

73
    public IQOwnerHandler(LocalMUCRoom chatroom, PacketRouter packetRouter) {
74 75
        this.room = chatroom;
        this.router = packetRouter;
76 77
        this.skipInvite = JiveGlobals.getBooleanProperty(
                "xmpp.muc.skipInvite", false);
78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99
        init();
    }

    /**
     * Handles the IQ packet sent by an owner of the room. Possible actions are:
     * <ul>
     * <li>Return the list of owners</li>
     * <li>Return the list of admins</li>
     * <li>Change user's affiliation to owner</li>
     * <li>Change user's affiliation to admin</li>
     * <li>Change user's affiliation to member</li>
     * <li>Change user's affiliation to none</li>
     * <li>Destroy the room</li>
     * <li>Return the room configuration within a dataform</li>
     * <li>Update the room configuration based on the sent dataform</li>
     * </ul>
     *
     * @param packet the IQ packet sent by an owner of the room.
     * @param role the role of the user that sent the packet.
     * @throws ForbiddenException if the user does not have enough permissions (ie. is not an owner).
     * @throws ConflictException If the room was going to lose all of its owners.
     */
100 101
    @SuppressWarnings("unchecked")
	public void handleIQ(IQ packet, MUCRole role) throws ForbiddenException, ConflictException, CannotBeInvitedException {
102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117
        // Only owners can send packets with the namespace "http://jabber.org/protocol/muc#owner"
        if (MUCRole.Affiliation.owner != role.getAffiliation()) {
            throw new ForbiddenException();
        }

        IQ reply = IQ.createResultIQ(packet);
        Element element = packet.getChildElement();

        // Analyze the action to perform based on the included element
        Element formElement = element.element(QName.get("x", "jabber:x:data"));
        if (formElement != null) {
            handleDataFormElement(role, formElement);
        }
        else {
            Element destroyElement = element.element("destroy");
            if (destroyElement != null) {
118 119 120 121 122 123 124
                if (((MultiUserChatServiceImpl)room.getMUCService()).getMUCDelegate() != null) {
                    if (!((MultiUserChatServiceImpl)room.getMUCService()).getMUCDelegate().destroyingRoom(room.getName(), role.getUserAddress())) {
                        // Delegate said no, reject destroy request.
                        throw new ForbiddenException();
                    }
                }

125 126 127 128 129 130
                JID alternateJID = null;
                final String jid = destroyElement.attributeValue("jid");
                if (jid != null) {
                    alternateJID = new JID(jid);
                }
                room.destroyRoom(alternateJID, destroyElement.elementTextTrim("reason"));
131 132
            }
            else {
133 134 135 136 137
                // If no element was included in the query element then answer the
                // configuration form
                if (!element.elementIterator().hasNext()) {
                    refreshConfigurationFormValues();
                    reply.setChildElement(probeResult.createCopy());
138
                }
139 140
                // An unknown and possibly incorrect element was included in the query
                // element so answer a BAD_REQUEST error
141
                else {
142 143
                    reply.setChildElement(packet.getChildElement().createCopy());
                    reply.setError(PacketError.Condition.bad_request);
144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164
                }
            }
        }
        if (reply.getTo() != null) {
            // Send a reply only if the sender of the original packet was from a real JID. (i.e. not
            // a packet generated locally)
            router.route(reply);
        }
    }

    /**
     * Handles packets that includes a data form. The data form was sent using an element with name
     * "x" and namespace "jabber:x:data".
     *
     * @param senderRole  the role of the user that sent the data form.
     * @param formElement the element that contains the data form specification.
     * @throws ForbiddenException    if the user does not have enough privileges.
     * @throws ConflictException If the room was going to lose all of its owners.
     */
    private void handleDataFormElement(MUCRole senderRole, Element formElement)
            throws ForbiddenException, ConflictException {
165
        DataForm completedForm = new DataForm(formElement);
166

167 168
        switch(completedForm.getType()) {
        case cancel:
169 170 171 172 173
            // If the room was just created (i.e. is locked) and the owner cancels the configuration
            // form then destroy the room
            if (room.isLocked()) {
                room.destroyRoom(null, null);
            }
174 175 176
            break;
            
        case submit:
177
            // The owner is requesting an instant room
178
            if (completedForm.getFields().isEmpty()) {
179 180 181 182 183 184 185 186 187 188 189
                // Do nothing
            }
            // The owner is requesting a reserved room or is changing the current configuration
            else {
                processConfigurationForm(completedForm, senderRole);
            }
            // If the room was locked, unlock it and send to the owner the "room is now unlocked"
            // message
            if (room.isLocked() && !room.isManuallyLocked()) {
                room.unlock(senderRole);
            }
190 191 192 193
            if (!room.isDestroyed) {
                // Let other cluster nodes that the room has been updated
                CacheFactory.doClusterTask(new RoomUpdatedEvent(room));
            }
194 195 196 197 198
            break;
            
        default:
        	Log.warn("cannot handle data form element: " + formElement.asXML());
        	break;
199 200 201 202 203 204 205 206 207 208 209 210
        }
    }

    /**
     * Processes the completed form sent by an owner of the room. This will modify the room's
     * configuration as well as the list of owners and admins.
     *
     * @param completedForm the completed form sent by an owner of the room.
     * @param senderRole the role of the user that sent the completed form.
     * @throws ForbiddenException if the user does not have enough privileges.
     * @throws ConflictException If the room was going to lose all of its owners.
     */
211
    private void processConfigurationForm(DataForm completedForm, MUCRole senderRole)
212
            throws ForbiddenException, ConflictException {
213
        List<String> values;
214 215 216 217 218 219
        String booleanValue;
        FormField field;

        // Get the new list of admins
        field = completedForm.getField("muc#roomconfig_roomadmins");
        boolean adminsSent = field != null;
220
        List<JID> admins = new ArrayList<JID>();
221
        if (field != null) {
222 223 224
        	for (String value : field.getValues()) {
        		// XEP-0045: "Affiliations are granted, revoked, and 
        		// maintained based on the user's bare JID, (...)"
225
                if (value != null && value.trim().length() != 0) {
226 227
                	// could be a group jid
                    admins.add(GroupJID.fromString((value.trim())).asBareJID());
228
                }
229
        	}
230 231 232 233 234
        }

        // Get the new list of owners
        field = completedForm.getField("muc#roomconfig_roomowners");
        boolean ownersSent = field != null;
235
        List<JID> owners = new ArrayList<JID>(); 
236
        if (field != null) {
237 238 239
        	for(String value : field.getValues()) {
        		// XEP-0045: "Affiliations are granted, revoked, and 
        		// maintained based on the user's bare JID, (...)"
240
                if (value != null && value.trim().length() != 0) {
241 242
                	// could be a group jid
        		    owners.add(GroupJID.fromString((value.trim())).asBareJID());
243
                }
244
        	}
245 246
        }

247
        // Answer a conflict error if all the current owners will be removed
248 249 250 251 252
        if (ownersSent && owners.isEmpty()) {
            throw new ConflictException();
        }

        // Keep a registry of the updated presences
253
        List<Presence> presences = new ArrayList<Presence>(admins.size() + owners.size());
254

255 256
        field = completedForm.getField("muc#roomconfig_roomname");
        if (field != null) {
257 258
            final String value = field.getFirstValue();
            room.setNaturalLanguageName((value != null ? value : " "));
259
        }
260

261 262
        field = completedForm.getField("muc#roomconfig_roomdesc");
        if (field != null) {
263 264
            final String value = field.getFirstValue();
            room.setDescription((value != null ? value : " "));
265
        }
266

267 268
        field = completedForm.getField("muc#roomconfig_changesubject");
        if (field != null) {
269 270
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
271 272
            room.setCanOccupantsChangeSubject(("1".equals(booleanValue)));
        }
273

274 275
        field = completedForm.getField("muc#roomconfig_maxusers");
        if (field != null) {
276 277
            final String value = field.getFirstValue();
            room.setMaxUsers((value != null ? Integer.parseInt(value) : 30));
278
        }
279

280 281
        field = completedForm.getField("muc#roomconfig_presencebroadcast");
        if (field != null) {
282 283
            values = new ArrayList<String>(field.getValues());
            room.setRolesToBroadcastPresence(values);
284
        }
285

286 287
        field = completedForm.getField("muc#roomconfig_publicroom");
        if (field != null) {
288 289
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
290 291
            room.setPublicRoom(("1".equals(booleanValue)));
        }
292

293 294
        field = completedForm.getField("muc#roomconfig_persistentroom");
        if (field != null) {
295 296
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
297 298 299 300
            boolean isPersistent = ("1".equals(booleanValue));
            // Delete the room from the DB if it's no longer persistent
            if (room.isPersistent() && !isPersistent) {
                MUCPersistenceManager.deleteFromDB(room);
301
            }
302 303
            room.setPersistent(isPersistent);
        }
304

305 306
        field = completedForm.getField("muc#roomconfig_moderatedroom");
        if (field != null) {
307 308
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
309 310
            room.setModerated(("1".equals(booleanValue)));
        }
311

312 313
        field = completedForm.getField("muc#roomconfig_membersonly");
        if (field != null) {
314 315
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
316 317
            presences.addAll(room.setMembersOnly(("1".equals(booleanValue))));
        }
318

319 320
        field = completedForm.getField("muc#roomconfig_allowinvites");
        if (field != null) {
321 322
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
323 324
            room.setCanOccupantsInvite(("1".equals(booleanValue)));
        }
325

326 327
        field = completedForm.getField("muc#roomconfig_passwordprotectedroom");
        if (field != null) {
328 329
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
330 331 332 333 334
            boolean isPasswordProtected = "1".equals(booleanValue);
            if (isPasswordProtected) {
                // The room is password protected so set the new password
                field = completedForm.getField("muc#roomconfig_roomsecret");
                if (field != null) {
335 336
                    final String secret = completedForm.getField("muc#roomconfig_roomsecret").getFirstValue();
                    room.setPassword(secret);
337 338
                }
            }
339 340 341
            else {
                // The room is not password protected so remove any previous password
                room.setPassword(null);
342
            }
343
        }
344

345 346
        field = completedForm.getField("muc#roomconfig_whois");
        if (field != null) {
347 348
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
349 350
            room.setCanAnyoneDiscoverJID(("anyone".equals(booleanValue)));
        }
351

352 353
        field = completedForm.getField("muc#roomconfig_enablelogging");
        if (field != null) {
354 355
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
356 357
            room.setLogEnabled(("1".equals(booleanValue)));
        }
358

359 360
        field = completedForm.getField("x-muc#roomconfig_reservednick");
        if (field != null) {
361 362
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
363 364
            room.setLoginRestrictedToNickname(("1".equals(booleanValue)));
        }
365

366 367
        field = completedForm.getField("x-muc#roomconfig_canchangenick");
        if (field != null) {
368 369
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
370 371 372 373 374
            room.setChangeNickname(("1".equals(booleanValue)));
        }

        field = completedForm.getField("x-muc#roomconfig_registration");
        if (field != null) {
375 376
            final String value = field.getFirstValue();
            booleanValue = ((value != null ? value : "1"));
377 378
            room.setRegistrationEnabled(("1".equals(booleanValue)));
        }
379

380 381 382
        // Update the modification date to reflect the last time when the room's configuration
        // was modified
        room.setModificationDate(new Date());
383

384 385 386
        if (room.isPersistent()) {
            room.saveToDB();
        }
387

388 389 390
        // Set the new owners and admins of the room
        presences.addAll(room.addOwners(owners, senderRole));
        presences.addAll(room.addAdmins(admins, senderRole));
391

392 393 394
        if (ownersSent) {
            // Change the affiliation to "member" for the current owners that won't be neither
            // owner nor admin (if the form included the owners field)
395
            List<JID> ownersToRemove = new ArrayList<JID>(room.owners);
396 397
            ownersToRemove.removeAll(admins);
            ownersToRemove.removeAll(owners);
398
            for (JID jid : ownersToRemove) {
399 400 401 402
            	// ignore group jids
            	if (!GroupJID.isGroup(jid)) {
            		presences.addAll(room.addMember(jid, null, senderRole));
            	}
403
            }
404
        }
405

406 407 408
        if (adminsSent) {
            // Change the affiliation to "member" for the current admins that won't be neither
            // owner nor admin (if the form included the admins field)
409
            List<JID> adminsToRemove = new ArrayList<JID>(room.admins);
410 411
            adminsToRemove.removeAll(admins);
            adminsToRemove.removeAll(owners);
412
            for (JID jid : adminsToRemove) {
413 414 415 416
            	// ignore group jids
            	if (!GroupJID.isGroup(jid)) {
            		presences.addAll(room.addMember(jid, null, senderRole));
            	}
417 418
            }
        }
419 420 421 422 423

        // Destroy the room if the room is no longer persistent and there are no occupants in
        // the room
        if (!room.isPersistent() && room.getOccupantsCount() == 0) {
            room.destroyRoom(null, null);
424 425 426
        }

        // Send the updated presences to the room occupants
427 428
        for (Object presence : presences) {
            room.send((Presence) presence);
429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506
        }
    }

    private void refreshConfigurationFormValues() {
        room.lock.readLock().lock();
        try {
            FormField field = configurationForm.getField("muc#roomconfig_roomname");
            field.clearValues();
            field.addValue(room.getNaturalLanguageName());

            field = configurationForm.getField("muc#roomconfig_roomdesc");
            field.clearValues();
            field.addValue(room.getDescription());

            field = configurationForm.getField("muc#roomconfig_changesubject");
            field.clearValues();
            field.addValue((room.canOccupantsChangeSubject() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_maxusers");
            field.clearValues();
            field.addValue(Integer.toString(room.getMaxUsers()));

            field = configurationForm.getField("muc#roomconfig_presencebroadcast");
            field.clearValues();
            for (String roleToBroadcast : room.getRolesToBroadcastPresence()) {
                field.addValue(roleToBroadcast);
            }

            field = configurationForm.getField("muc#roomconfig_publicroom");
            field.clearValues();
            field.addValue((room.isPublicRoom() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_persistentroom");
            field.clearValues();
            field.addValue((room.isPersistent() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_moderatedroom");
            field.clearValues();
            field.addValue((room.isModerated() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_membersonly");
            field.clearValues();
            field.addValue((room.isMembersOnly() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_allowinvites");
            field.clearValues();
            field.addValue((room.canOccupantsInvite() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_passwordprotectedroom");
            field.clearValues();
            field.addValue((room.isPasswordProtected() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_roomsecret");
            field.clearValues();
            field.addValue(room.getPassword());

            field = configurationForm.getField("muc#roomconfig_whois");
            field.clearValues();
            field.addValue((room.canAnyoneDiscoverJID() ? "anyone" : "moderators"));

            field = configurationForm.getField("muc#roomconfig_enablelogging");
            field.clearValues();
            field.addValue((room.isLogEnabled() ? "1" : "0"));

            field = configurationForm.getField("x-muc#roomconfig_reservednick");
            field.clearValues();
            field.addValue((room.isLoginRestrictedToNickname() ? "1" : "0"));

            field = configurationForm.getField("x-muc#roomconfig_canchangenick");
            field.clearValues();
            field.addValue((room.canChangeNickname() ? "1" : "0"));

            field = configurationForm.getField("x-muc#roomconfig_registration");
            field.clearValues();
            field.addValue((room.isRegistrationEnabled() ? "1" : "0"));

            field = configurationForm.getField("muc#roomconfig_roomadmins");
            field.clearValues();
507
            for (JID jid : room.getAdmins()) {
508 509 510 511 512 513 514 515 516 517 518 519 520
            	if (GroupJID.isGroup(jid)) {
            		try {
                		// add each group member to the result (clients don't understand groups)
                		Group group = GroupManager.getInstance().getGroup(jid);
                		for (JID groupMember : group.getAll()) {
                            field.addValue(groupMember);
                		}
            		} catch (GroupNotFoundException gnfe) {
            			Log.warn("Invalid group JID in the member list: " + jid);
            		}
            	} else {
                    field.addValue(jid.toString());
            	}
521 522 523 524
            }

            field = configurationForm.getField("muc#roomconfig_roomowners");
            field.clearValues();
525
            for (JID jid : room.getOwners()) {
526 527 528 529 530 531 532 533 534 535 536 537 538
            	if (GroupJID.isGroup(jid)) {
            		try {
                		// add each group member to the result (clients don't understand groups)
                		Group group = GroupManager.getInstance().getGroup(jid);
                		for (JID groupMember : group.getAll()) {
                            field.addValue(groupMember);
                		}
            		} catch (GroupNotFoundException gnfe) {
            			Log.warn("Invalid group JID in the member list: " + jid);
            		}
            	} else {
                    field.addValue(jid.toString());
            	}
539 540 541 542 543
            }

            // Remove the old element
            probeResult.remove(probeResult.element(QName.get("x", "jabber:x:data")));
            // Add the new representation of configurationForm as an element 
544
            probeResult.add(configurationForm.getElement());
545 546 547 548 549 550 551 552 553 554 555

        }
        finally {
            room.lock.readLock().unlock();
        }
    }

    private void init() {
        Element element = DocumentHelper.createElement(QName.get("query",
                "http://jabber.org/protocol/muc#owner"));

556
        configurationForm = new DataForm(DataForm.Type.form);
557
        configurationForm.setTitle(LocaleUtils.getLocalizedString("muc.form.conf.title"));
558
        List<String> params = new ArrayList<String>();
559 560 561
        params.add(room.getName());
        configurationForm.addInstruction(LocaleUtils.getLocalizedString("muc.form.conf.instruction", params));

562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648
        configurationForm.addField("FORM_TYPE", null, Type.hidden)
				.addValue("http://jabber.org/protocol/muc#roomconfig");

        configurationForm.addField("muc#roomconfig_roomname", 
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_roomname"),
				Type.text_single);

        configurationForm.addField("muc#roomconfig_roomdesc",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_roomdesc"),
        		Type.text_single);

        configurationForm.addField("muc#roomconfig_changesubject",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_changesubject"),
        		Type.boolean_type);
        
        final FormField maxUsers = configurationForm.addField(
        		"muc#roomconfig_maxusers",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_maxusers"),
        		Type.list_single);
        maxUsers.addOption("10", "10");
        maxUsers.addOption("20", "20");
        maxUsers.addOption("30", "30");
        maxUsers.addOption("40", "40");
        maxUsers.addOption("50", "50");
        maxUsers.addOption(LocaleUtils.getLocalizedString("muc.form.conf.none"), "0");

        final FormField broadcast = configurationForm.addField(
        		"muc#roomconfig_presencebroadcast",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_presencebroadcast"),
        		Type.list_multi);
        broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.moderator"), "moderator");
        broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.participant"), "participant");
        broadcast.addOption(LocaleUtils.getLocalizedString("muc.form.conf.visitor"), "visitor");

        configurationForm.addField("muc#roomconfig_publicroom", 
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_publicroom"),
        		Type.boolean_type);

        configurationForm.addField("muc#roomconfig_persistentroom",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_persistentroom"),
        		Type.boolean_type);

        configurationForm.addField("muc#roomconfig_moderatedroom",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_moderatedroom"),
        		Type.boolean_type);

        configurationForm.addField("muc#roomconfig_membersonly",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_membersonly"),
        		Type.boolean_type);

        configurationForm.addField(null, null, Type.fixed)
        		.addValue(LocaleUtils.getLocalizedString("muc.form.conf.allowinvitesfixed"));

        configurationForm.addField("muc#roomconfig_allowinvites",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_allowinvites"),
        		Type.boolean_type);

        configurationForm.addField("muc#roomconfig_passwordprotectedroom",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_passwordprotectedroom"),
        		Type.boolean_type);

        configurationForm.addField(null, null, Type.fixed)
        		.addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomsecretfixed"));

        configurationForm.addField("muc#roomconfig_roomsecret",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_roomsecret"),
        		Type.text_private);
        
        final FormField whois = configurationForm.addField(
        		"muc#roomconfig_whois",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_whois"),
        		Type.list_single);
        whois.addOption(LocaleUtils.getLocalizedString("muc.form.conf.moderator"), "moderators");
        whois.addOption(LocaleUtils.getLocalizedString("muc.form.conf.anyone"), "anyone");

        configurationForm.addField("muc#roomconfig_enablelogging",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_enablelogging"),
        		Type.boolean_type);

        configurationForm.addField("x-muc#roomconfig_reservednick",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_reservednick"),
        		Type.boolean_type);

        configurationForm.addField("x-muc#roomconfig_canchangenick",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_canchangenick"),
        		Type.boolean_type);

guus's avatar
guus committed
649 650 651
        configurationForm.addField(null, null, Type.fixed)
                .addValue(LocaleUtils.getLocalizedString("muc.form.conf.owner_registration"));

652 653 654
        configurationForm.addField("x-muc#roomconfig_registration",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_registration"),
        		Type.boolean_type);
guus's avatar
guus committed
655

656
        configurationForm.addField(null, null, Type.fixed)
guus's avatar
guus committed
657 658
                .addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomadminsfixed"));

659 660 661 662 663 664 665 666 667 668
        configurationForm.addField("muc#roomconfig_roomadmins",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_roomadmins"),
        		Type.jid_multi);

        configurationForm.addField(null, null, Type.fixed)
				.addValue(LocaleUtils.getLocalizedString("muc.form.conf.roomownersfixed"));

        configurationForm.addField("muc#roomconfig_roomowners",
        		LocaleUtils.getLocalizedString("muc.form.conf.owner_roomowners"),
        		Type.jid_multi);
669 670 671

        // Create the probeResult and add the basic info together with the configuration form
        probeResult = element;
672
        probeResult.add(configurationForm.getElement());
673
    }
674
}