private String getItemsToSearch() { StringBuilder buf = new StringBuilder(); if (form == null) { form = Form.getFormFrom(this); } if (form == null) { return ""; } for (FormField field : form.getFields()) { String name = field.getVariable(); String value = getSingleValue(field); if (value.trim().length() > 0) { buf.append('<').append(name).append('>').append(value).append("</").append(name).append('>'); } } return buf.toString(); }
/** * Returns the number of offline messages for the user of the connection. * * @return the number of offline messages for the user of the connection. * @throws XMPPErrorException If the user is not allowed to make this request or the server does * not support offline message retrieval. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ public int getMessageCount() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { DiscoverInfo info = ServiceDiscoveryManager.getInstanceFor(connection).discoverInfo(null, namespace); Form extendedInfo = Form.getFormFrom(info); if (extendedInfo != null) { String value = extendedInfo.getField("number_of_messages").getFirstValue(); return Integer.parseInt(value); } return 0; }
/** * Returns the form for all search fields supported by the search service. * * @param con the current XMPPConnection. * @param searchService the search service to use. (ex. search.jivesoftware.com) * @return the search form received by the server. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public Form getSearchForm(XMPPConnection con, DomainBareJid searchService) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { UserSearch search = new UserSearch(); search.setType(IQ.Type.get); search.setTo(searchService); IQ response = con.createStanzaCollectorAndSend(search).nextResultOrThrow(); return Form.getFormFrom(response); }
/** * Returns the Form to use for searching transcripts. It is unlikely that the server * will change the form (without a restart) so it is safe to keep the returned form * for future submissions. * * @param serviceJID the address of the workgroup service. * @return the Form to use for searching transcripts. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public Form getSearchForm(DomainBareJid serviceJID) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { TranscriptSearch search = new TranscriptSearch(); search.setType(IQ.Type.get); search.setTo(serviceJID); TranscriptSearch response = connection.createStanzaCollectorAndSend( search).nextResultOrThrow(); return Form.getFormFrom(response); }
/** * Returns the room's configuration form that the room's owner can use or <tt>null</tt> if * no configuration is possible. The configuration form allows to set the room's language, * enable logging, specify room's type, etc.. * * @return the Form that contains the fields to complete together with the instrucions or * <tt>null</tt> if no configuration is possible. * @throws XMPPErrorException if an error occurs asking the configuration form for the room. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ public Form getConfigurationForm() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { MUCOwner iq = new MUCOwner(); iq.setTo(room); iq.setType(IQ.Type.get); IQ answer = connection.createStanzaCollectorAndSend(iq).nextResultOrThrow(); return Form.getFormFrom(answer); }
/** * Returns the Form to use for all clients of a workgroup. It is unlikely that the server * will change the form (without a restart) so it is safe to keep the returned form * for future submissions. * * @return the Form to use for searching transcripts. * @throws XMPPErrorException * @throws NoResponseException * @throws NotConnectedException * @throws InterruptedException */ public Form getWorkgroupForm() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { WorkgroupForm workgroupForm = new WorkgroupForm(); workgroupForm.setType(IQ.Type.get); workgroupForm.setTo(workgroupJID); WorkgroupForm response = connection.createStanzaCollectorAndSend( workgroupForm).nextResultOrThrow(); return Form.getFormFrom(response); } }
/** * Returns the room's registration form that an unaffiliated user, can use to become a member * of the room or <tt>null</tt> if no registration is possible. Some rooms may restrict the * privilege to register members and allow only room admins to add new members.<p> * * If the user requesting registration requirements is not allowed to register with the room * (e.g. because that privilege has been restricted), the room will return a "Not Allowed" * error to the user (error code 405). * * @return the registration Form that contains the fields to complete together with the * instrucions or <tt>null</tt> if no registration is possible. * @throws XMPPErrorException if an error occurs asking the registration form for the room or a * 405 error if the user is not allowed to register with the room. * @throws NoResponseException if there was no response from the server. * @throws NotConnectedException * @throws InterruptedException */ public Form getRegistrationForm() throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException { Registration reg = new Registration(); reg.setType(IQ.Type.get); reg.setTo(room); IQ result = connection.createStanzaCollectorAndSend(reg).nextResultOrThrow(); return Form.getFormFrom(result); }
String pubsub = null; form = Form.getFormFrom(info); if (form != null) { FormField descField = form.getField("muc#roominfo_description");
assertNotNull("Message not found", msg2); Form formToRespond = Form.getFormFrom(msg2); assertNotNull(formToRespond); assertNotNull(formToRespond.getField("name")); assertNotNull("Message not found", msg3); completedForm = Form.getFormFrom(msg3); assertNotNull(completedForm); assertNotNull(completedForm.getField("name"));