Android xmpp MUC setting default configuration
Asked Answered
F

2

8

Am using the Xabber open source project and am able to create a new group, But it always says: This room is locked from entry until configuration is confirmed. I tried to set a default configuration but it throws me exception: 401 not authorized. Whats exactly the problem.

final MultiUserChat multiUserChat;
        try {
            multiUserChat = new MultiUserChat(xmppConnection, room);
            // CHANAKYA: set default config for the MUC
            // Send an empty room configuration form which indicates that we want
            // an instant room
            try {
                multiUserChat.sendConfigurationForm(new Form(Form.TYPE_SUBMIT));
            } catch (XMPPException e) {
                e.printStackTrace();
            }
Fasciate answered 31/5, 2013 at 13:17 Comment(0)
D
11

I was also facing the same error. Here I modified the code and it's work for me. Error 401 is not authorized error when we are calling the any getConfigurationForm(), without joining it.


multiUserChat.join(nickname, password);
setConfig(multiUserChat); // Here I am calling submit form

private void setConfig(MultiUserChat multiUserChat) {

    try {
        Form form = multiUserChat.getConfigurationForm();
        Form submitForm = form.createAnswerForm();
        for (Iterator<FormField> fields = submitForm.getFields(); fields
                .hasNext();) {
            FormField field = (FormField) fields.next();
            if (!FormField.Type.hidden.equals(field.getType())
                    && field.getVariable() != null) {
                submitForm.setDefaultAnswer(field.getVariable());
            }
        }
        submitForm.setAnswer("muc#roomconfig_publicroom", true);
        submitForm.setAnswer("muc#roomconfig_persistentroom", true);
        multiUserChat.sendConfigurationForm(submitForm);
    } catch (Exception e) {
        e.printStackTrace();
    }

}

And now I am able to successfully submit the form without any exception. Hope this will work for you.

Deepseated answered 7/6, 2013 at 11:37 Comment(1)
Hi @Deepseated , Can you tell me how we can update the group configuration?Jeep
W
0

You must have permissions to set the configuration. This can usually be changed in the server settings. If you have Openfire for example you should go to Group Chat>Group chat settings>Click your Group Chat service>Room Creation Permissions or Administrators.

You are probably unable to change this client side, it's only possible if you have access to the server you are trying to connect to.

Waft answered 4/6, 2013 at 15:50 Comment(1)
Hi koesie thanks for the reply, i tried changing the Room creation permission to everyone and also i added my jabber id to the Aminstrators list. But still when i create a new group i get the same error.Fasciate

© 2022 - 2024 — McMap. All rights reserved.