/** * Set if the room is members only. Rooms are not members only per default. * * @param isMembersOnly if the room should be members only. * @return a reference to this object. * @throws MucConfigurationNotSupportedException */ public MucConfigFormManager setMembersOnly(boolean isMembersOnly) throws MucConfigurationNotSupportedException { if (!supportsMembersOnly()) { throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_MEMBERSONLY); } answerForm.setAnswer(MUC_ROOMCONFIG_MEMBERSONLY, isMembersOnly); return this; }
/** * Sets a new boolean value to a given form's field. The field whose variable matches the * requested variable will be completed with the specified value. If no field could be found * for the specified variable then an exception will be raised. * * @param variable the variable name that was completed. * @param value the boolean value that was answered. * @throws IllegalStateException if the form is not of type "submit". * @throws IllegalArgumentException if the form does not include the specified variable or * if the answer type does not correspond with the field type. */ public void setAnswer(String variable, boolean value) { FormField field = getField(variable); if (field == null) { throw new IllegalArgumentException("Field not found for the specified variable name."); } if (field.getType() != FormField.Type.bool) { throw new IllegalArgumentException("This field is not of type boolean."); } setAnswer(field, Boolean.toString(value)); }
/** * Sets a new int value to a given form's field. The field whose variable matches the * requested variable will be completed with the specified value. If no field could be found * for the specified variable then an exception will be raised. * * @param variable the variable name that was completed. * @param value the int value that was answered. * @throws IllegalStateException if the form is not of type "submit". * @throws IllegalArgumentException if the form does not include the specified variable or * if the answer type does not correspond with the field type. */ public void setAnswer(String variable, int value) { FormField field = getField(variable); if (field == null) { throw new IllegalArgumentException("Field not found for the specified variable name."); } validateThatFieldIsText(field); setAnswer(field, value); }
/** * Sets a new long value to a given form's field. The field whose variable matches the * requested variable will be completed with the specified value. If no field could be found * for the specified variable then an exception will be raised. * * @param variable the variable name that was completed. * @param value the long value that was answered. * @throws IllegalStateException if the form is not of type "submit". * @throws IllegalArgumentException if the form does not include the specified variable or * if the answer type does not correspond with the field type. */ public void setAnswer(String variable, long value) { FormField field = getField(variable); if (field == null) { throw new IllegalArgumentException("Field not found for the specified variable name."); } validateThatFieldIsText(field); setAnswer(field, value); }
/** * Submit the configuration as {@link Form} to the room. * * @throws NoResponseException if there was no response from the room. * @throws XMPPErrorException * @throws NotConnectedException * @throws InterruptedException */ public void submitConfigurationForm() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { if (owners != null) { answerForm.setAnswer(MUC_ROOMCONFIG_ROOMOWNERS, JidUtil.toStringList(owners)); } multiUserChat.sendConfigurationForm(answerForm); } }
/** * Sets a new float value to a given form's field. The field whose variable matches the * requested variable will be completed with the specified value. If no field could be found * for the specified variable then an exception will be raised. * * @param variable the variable name that was completed. * @param value the float value that was answered. * @throws IllegalStateException if the form is not of type "submit". * @throws IllegalArgumentException if the form does not include the specified variable or * if the answer type does not correspond with the field type. */ public void setAnswer(String variable, float value) { FormField field = getField(variable); if (field == null) { throw new IllegalArgumentException("Field not found for the specified variable name."); } validateThatFieldIsText(field); setAnswer(field, value); }
/** * Sets a new double value to a given form's field. The field whose variable matches the * requested variable will be completed with the specified value. If no field could be found * for the specified variable then an exception will be raised. * * @param variable the variable name that was completed. * @param value the double value that was answered. * @throws IllegalStateException if the form is not of type "submit". * @throws IllegalArgumentException if the form does not include the specified variable or * if the answer type does not correspond with the field type. */ public void setAnswer(String variable, double value) { FormField field = getField(variable); if (field == null) { throw new IllegalArgumentException("Field not found for the specified variable name."); } validateThatFieldIsText(field); setAnswer(field, value); }
/** * Set if this room is password protected. Rooms are by default not password protected. * * @param isPasswordProtected * @return a reference to this object. * @throws MucConfigurationNotSupportedException */ public MucConfigFormManager setIsPasswordProtected(boolean isPasswordProtected) throws MucConfigurationNotSupportedException { if (!supportsMembersOnly()) { throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM); } answerForm.setAnswer(MUC_ROOMCONFIG_PASSWORDPROTECTEDROOM, isPasswordProtected); return this; }
/** * Set the room secret, aka the room password. If set and enabled, the password is required to * join the room. Note that this does only set it by does not enable password protection. Use * {@link #setAndEnablePassword(String)} to set a password and make the room protected. * * @param secret the secret/password. * @return a reference to this object. * @throws MucConfigurationNotSupportedException */ public MucConfigFormManager setRoomSecret(String secret) throws MucConfigurationNotSupportedException { if (!answerForm.hasField(MUC_ROOMCONFIG_ROOMSECRET)) { throw new MucConfigurationNotSupportedException(MUC_ROOMCONFIG_ROOMSECRET); } answerForm.setAnswer(MUC_ROOMCONFIG_ROOMSECRET, secret); return this; }
throw new IllegalArgumentException("This field is not of type String."); setAnswer(field, value);
field.setType(FormField.Type.text_single); form.addField(field); form.setAnswer(name, value);
form.setAnswer(field.getVariable(), values);
completedForm.setAnswer("name", true); fail("A boolean value was set to a field of type String"); completedForm.setAnswer("name", "Credit card number invalid"); completedForm.setAnswer( "description", "The ATM says that my credit card number is invalid. What's going on?"); completedForm.setAnswer("time", true); completedForm.setAnswer("age", 20);
muc.create(nickname); Form form = muc.getConfigurationForm().createAnswerForm(); form.setAnswer("muc#roomconfig_roomowners", owners); muc.sendConfigurationForm(form);
if( !chatRoom.isJoined() ){ chatRoom.createOrJoin("your nickname"); List<String> owners = new ArrayList<String>(); owners.add("currUser@"+MYSITE); Form form = chatRoom.getConfigurationForm().createAnswerForm(); form.setAnswer("muc#roomconfig_roomname", "your roomname"); form.setAnswer("muc#roomconfig_roomowners", owners); form.setAnswer("muc#roomconfig_persistentroom", true); form.setAnswer("muc#roomconfig_publicroom", true); chatRoom.sendConfigurationForm(form); }
erSearchManager search = new UserSearchManager(connection); Form searchForm = search.getSearchForm("search."+connection.getServiceName()); Form answerForm = searchForm.createAnswerForm(); answerForm.setAnswer("Username", true); answerForm.setAnswer("search", name);//Here username must be added name replace by "amith"
MultiUserChat chatRoom = new MultiUserChat(connection, "room786@conference.dishaserver"); chatRoom.create("nagarjuna"); Form form = chatRoom.getConfigurationForm().createAnswerForm(); form.setAnswer("muc#roomconfig_publicroom", true); form.setAnswer("muc#roomconfig_roomname", "room786"); form.setAnswer("muc#roomconfig_roomowners",owners); form.setAnswer("muc#roomconfig_persistentroom", true); chatRoom.sendConfigurationForm(form);
public Boolean checkIfUserExists(String user) throws XMPPException{ UserSearchManager search = new UserSearchManager(xmppConnection); Form searchForm = search.getSearchForm("search."+xmppConnection.getServiceName()); Form answerForm = searchForm.createAnswerForm(); answerForm.setAnswer("Username", true); answerForm.setAnswer("search", user); ReportedData data = search.getSearchResults(answerForm,"search."+xmppConnection.getServiceName()); if (data.getRows() != null) { Iterator<Row> it = data.getRows(); while (it.hasNext()) { Row row = it.next(); Iterator iterator = row.getValues("jid"); if (iterator.hasNext()) { String value = iterator.next().toString(); System.out.println("Iteartor values...... " + value); } } return true; } return false; }
UserSearchManager usm= new UserSearchManager(xmpp.getConnection()); Form searchForm = usm.getSearchForm("search." +xmpp.getConnection().getServiceName()); Form answerForm = searchForm.createAnswerForm(); answerForm.setAnswer("Username", true); answerForm.setAnswer("search", userName); ReportedData data = usm .getSearchResults(answerForm, "search." + xmpp.getConnection().getServiceName()); if (data.getRows() != null) { for (ReportedData.Row row: data.getRows()) { for (String jid:row.getValues("jid")) { System.out.println(jid); } } }
/** * Sends the Answer Form * @param answer <u>must be an answer-form</u> * @param chat */ private void sendAnswerForm(Form answer, MultiUserChat chat) { ChatRoom room = SparkManager.getChatManager().getChatRoom(chat.getRoom().toString()); for (String key : _map.keySet()) { String value = getValueFromComponent(key); answer.setAnswer(key, value); } try { chat.sendRegistrationForm(answer); String reg = Res.getString("message.groupchat.registered.member", chat.getRoom()); room.getTranscriptWindow().insertNotificationMessage(reg,ChatManager.NOTIFICATION_COLOR); } catch (XMPPException | SmackException | InterruptedException e) { room.getTranscriptWindow().insertNotificationMessage(e.getMessage(),ChatManager.ERROR_COLOR); } }