Search in sources :

Example 31 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class IQChatSearchHandler method init.

private void init() {
    // Configure the search form that will be sent to the agents
    this.searchForm = new DataForm(DataForm.Type.form);
    this.searchForm.setTitle("Chat search");
    this.searchForm.addInstruction("Fill out this form to search for chats");
    // Add starting date
    FormField field = this.searchForm.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Starting Date");
    field.setVariable("date/start");
    // Add ending date
    field = this.searchForm.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Ending Date");
    field.setVariable("date/end");
    // Add workgroup JID
    field = this.searchForm.addField();
    field.setType(FormField.Type.jid_multi);
    field.setLabel("Workgroup");
    field.setVariable("workgroups");
    // Add agent JID
    field = this.searchForm.addField();
    field.setType(FormField.Type.jid_single);
    field.setLabel("Agent");
    field.setVariable("agent");
    // Add query string
    field = this.searchForm.addField();
    field.setType(FormField.Type.text_single);
    field.setLabel("Search Terms");
    field.setVariable("queryString");
    field.setRequired(true);
    // Configure the form that will hold the search results
    this.resultForm = new DataForm(DataForm.Type.result);
    this.resultForm.addReportedField("workgroup", null, FormField.Type.jid_single);
    this.resultForm.addReportedField("sessionID", null, FormField.Type.text_single);
    this.resultForm.addReportedField("startDate", null, FormField.Type.text_single);
    this.resultForm.addReportedField("agentJIDs", null, FormField.Type.jid_multi);
    this.resultForm.addReportedField("relevance", null, FormField.Type.text_single);
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 32 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class IQRegisterHandler method initialize.

@Override
public void initialize(XMPPServer server) {
    super.initialize(server);
    userManager = server.getUserManager();
    rosterManager = server.getRosterManager();
    if (probeResult == null) {
        // Create the basic element of the probeResult which contains the basic registration
        // information (e.g. username, passoword and email)
        probeResult = DocumentHelper.createElement(QName.get("query", "jabber:iq:register"));
        probeResult.addElement("username");
        probeResult.addElement("password");
        probeResult.addElement("email");
        probeResult.addElement("name");
        // Create the registration form to include in the probeResult. The form will include
        // the basic information plus name and visibility of name and email.
        // TODO Future versions could allow plugin modules to add new fields to the form 
        final DataForm registrationForm = new DataForm(DataForm.Type.form);
        registrationForm.setTitle("XMPP Client Registration");
        registrationForm.addInstruction("Please provide the following information");
        final FormField fieldForm = registrationForm.addField();
        fieldForm.setVariable("FORM_TYPE");
        fieldForm.setType(FormField.Type.hidden);
        fieldForm.addValue("jabber:iq:register");
        final FormField fieldUser = registrationForm.addField();
        fieldUser.setVariable("username");
        fieldUser.setType(FormField.Type.text_single);
        fieldUser.setLabel("Username");
        fieldUser.setRequired(true);
        final FormField fieldName = registrationForm.addField();
        fieldName.setVariable("name");
        fieldName.setType(FormField.Type.text_single);
        fieldName.setLabel("Full name");
        if (UserManager.getUserProvider().isNameRequired()) {
            fieldName.setRequired(true);
        }
        final FormField fieldMail = registrationForm.addField();
        fieldMail.setVariable("email");
        fieldMail.setType(FormField.Type.text_single);
        fieldMail.setLabel("Email");
        if (UserManager.getUserProvider().isEmailRequired()) {
            fieldMail.setRequired(true);
        }
        final FormField fieldPwd = registrationForm.addField();
        fieldPwd.setVariable("password");
        fieldPwd.setType(FormField.Type.text_private);
        fieldPwd.setLabel("Password");
        fieldPwd.setRequired(true);
        // Add the registration form to the probe result.
        probeResult.add(registrationForm.getElement());
    }
    JiveGlobals.migrateProperty("register.inband");
    JiveGlobals.migrateProperty("register.password");
    // See if in-band registration should be enabled (default is true).
    registrationEnabled = JiveGlobals.getBooleanProperty("register.inband", true);
    // See if users can change their passwords (default is true).
    canChangePassword = JiveGlobals.getBooleanProperty("register.password", true);
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 33 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class IQOfflineMessagesHandler method getExtendedInfo.

@Override
public DataForm getExtendedInfo(String name, String node, JID senderJID) {
    // Mark that offline messages shouldn't be sent when the user becomes available
    stopOfflineFlooding(senderJID);
    final DataForm dataForm = new DataForm(DataForm.Type.result);
    final FormField field1 = dataForm.addField();
    field1.setVariable("FORM_TYPE");
    field1.setType(FormField.Type.hidden);
    field1.addValue(NAMESPACE);
    final FormField field2 = dataForm.addField();
    field2.setVariable("number_of_messages");
    field2.addValue(String.valueOf(messageStore.getMessages(senderJID.getNode(), false).size()));
    return dataForm;
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 34 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class IQPEPHandler method createSubscriptionToPEPService.

/**
     * Generates and processes an IQ stanza that subscribes to a PEP service.
     *
     * @param pepService the PEP service of the owner.
     * @param subscriber the JID of the entity that is subscribing to the PEP service.
     * @param owner      the JID of the owner of the PEP service.
     */
private void createSubscriptionToPEPService(PEPService pepService, JID subscriber, JID owner) {
    // If `owner` has a PEP service, generate and process a pubsub subscription packet
    // that is equivalent to: (where 'from' field is JID of subscriber and 'to' field is JID of owner)
    //
    //        <iq type='set'
    //            from='nurse@capulet.com/chamber'
    //            to='juliet@capulet.com
    //            id='collsub'>
    //          <pubsub xmlns='http://jabber.org/protocol/pubsub'>
    //            <subscribe jid='nurse@capulet.com'/>
    //            <options>
    //              <x xmlns='jabber:x:data'>
    //                <field var='FORM_TYPE' type='hidden'>
    //                  <value>http://jabber.org/protocol/pubsub#subscribe_options</value>
    //                </field>
    //                <field var='pubsub#subscription_type'>
    //                  <value>items</value>
    //                </field>
    //                <field var='pubsub#subscription_depth'>
    //                  <value>all</value>
    //                </field>
    //              </x>
    //           </options>
    //         </pubsub>
    //        </iq>
    IQ subscriptionPacket = new IQ(IQ.Type.set);
    subscriptionPacket.setFrom(subscriber);
    subscriptionPacket.setTo(owner.toBareJID());
    Element pubsubElement = subscriptionPacket.setChildElement("pubsub", "http://jabber.org/protocol/pubsub");
    Element subscribeElement = pubsubElement.addElement("subscribe");
    subscribeElement.addAttribute("jid", subscriber.toBareJID());
    Element optionsElement = pubsubElement.addElement("options");
    Element xElement = optionsElement.addElement(QName.get("x", "jabber:x:data"));
    DataForm dataForm = new DataForm(xElement);
    FormField formField = dataForm.addField();
    formField.setVariable("FORM_TYPE");
    formField.setType(FormField.Type.hidden);
    formField.addValue("http://jabber.org/protocol/pubsub#subscribe_options");
    formField = dataForm.addField();
    formField.setVariable("pubsub#subscription_type");
    formField.addValue("items");
    formField = dataForm.addField();
    formField.setVariable("pubsub#subscription_depth");
    formField.addValue("all");
    pepServiceManager.process(pepService, subscriptionPacket);
}
Also used : Element(org.dom4j.Element) IQ(org.xmpp.packet.IQ) DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Example 35 with DataForm

use of org.xmpp.forms.DataForm in project Openfire by igniterealtime.

the class Node method getConfigurationChangeForm.

/**
     * Returns a data form with the node configuration. The returned data form is used for
     * notifying node subscribers that the node configuration has changed. The data form is
     * ony going to be included if node is configure to include payloads in event
     * notifications.
     *
     * @return a data form with the node configuration.
     */
private DataForm getConfigurationChangeForm() {
    DataForm form = new DataForm(DataForm.Type.result);
    FormField formField = form.addField();
    formField.setVariable("FORM_TYPE");
    formField.setType(FormField.Type.hidden);
    formField.addValue("http://jabber.org/protocol/pubsub#node_config");
    // Add the form fields and configure them for notification
    // (i.e. no label or options are included)
    addFormFields(form, false);
    return form;
}
Also used : DataForm(org.xmpp.forms.DataForm) FormField(org.xmpp.forms.FormField)

Aggregations

DataForm (org.xmpp.forms.DataForm)81 FormField (org.xmpp.forms.FormField)67 Element (org.dom4j.Element)23 IQ (org.xmpp.packet.IQ)12 JID (org.xmpp.packet.JID)9 ArrayList (java.util.ArrayList)7 ClientSession (org.jivesoftware.openfire.session.ClientSession)6 HashMap (java.util.HashMap)4 List (java.util.List)4 Group (org.jivesoftware.openfire.group.Group)4 Date (java.util.Date)3 UnauthorizedException (org.jivesoftware.openfire.auth.UnauthorizedException)3 MUCRoom (org.jivesoftware.openfire.muc.MUCRoom)3 UserNotFoundException (org.jivesoftware.openfire.user.UserNotFoundException)3 XStream (com.thoughtworks.xstream.XStream)2 ParseException (java.text.ParseException)2 HashSet (java.util.HashSet)2 Iterator (java.util.Iterator)2 PacketException (org.jivesoftware.openfire.PacketException)2 GroupNotFoundException (org.jivesoftware.openfire.group.GroupNotFoundException)2