Search in sources :

Example 36 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.

the class MamManager method addStart.

private static void addStart(Date start, DataForm dataForm) {
    if (start == null) {
        return;
    }
    FormField formField = new FormField("start");
    formField.addValue(XmppDateTime.formatXEP0082Date(start));
    dataForm.addField(formField);
}
Also used : FormField(org.jivesoftware.smackx.xdata.FormField)

Example 37 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.

the class FileTransferNegotiator method createDefaultInitiationForm.

private static DataForm createDefaultInitiationForm() {
    DataForm form = new DataForm(DataForm.Type.form);
    FormField field = new FormField(STREAM_DATA_FIELD_NAME);
    field.setType(FormField.Type.list_single);
    if (!IBB_ONLY) {
        field.addOption(new FormField.Option(Bytestream.NAMESPACE));
    }
    field.addOption(new FormField.Option(DataPacketExtension.NAMESPACE));
    form.addField(field);
    return form;
}
Also used : DataForm(org.jivesoftware.smackx.xdata.packet.DataForm) FormField(org.jivesoftware.smackx.xdata.FormField)

Example 38 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.

the class FileTransferNegotiator method selectStreamNegotiator.

/**
     * Selects an appropriate stream negotiator after examining the incoming file transfer request.
     *
     * @param request The related file transfer request.
     * @return The file transfer object that handles the transfer
     * @throws NoStreamMethodsOfferedException If there are either no stream methods contained in the packet, or
     *                       there is not an appropriate stream method.
     * @throws NotConnectedException 
     * @throws NoAcceptableTransferMechanisms 
     * @throws InterruptedException 
     */
public StreamNegotiator selectStreamNegotiator(FileTransferRequest request) throws NotConnectedException, NoStreamMethodsOfferedException, NoAcceptableTransferMechanisms, InterruptedException {
    StreamInitiation si = request.getStreamInitiation();
    FormField streamMethodField = getStreamMethodField(si.getFeatureNegotiationForm());
    if (streamMethodField == null) {
        String errorMessage = "No stream methods contained in stanza.";
        XMPPError.Builder error = XMPPError.from(XMPPError.Condition.bad_request, errorMessage);
        IQ iqPacket = IQ.createErrorResponse(si, error);
        connection().sendStanza(iqPacket);
        throw new FileTransferException.NoStreamMethodsOfferedException();
    }
    // select the appropriate protocol
    StreamNegotiator selectedStreamNegotiator;
    try {
        selectedStreamNegotiator = getNegotiator(streamMethodField);
    } catch (NoAcceptableTransferMechanisms e) {
        IQ iqPacket = IQ.createErrorResponse(si, XMPPError.from(XMPPError.Condition.bad_request, "No acceptable transfer mechanism"));
        connection().sendStanza(iqPacket);
        throw e;
    }
    return selectedStreamNegotiator;
}
Also used : StreamInitiation(org.jivesoftware.smackx.si.packet.StreamInitiation) NoStreamMethodsOfferedException(org.jivesoftware.smackx.filetransfer.FileTransferException.NoStreamMethodsOfferedException) IQ(org.jivesoftware.smack.packet.IQ) XMPPError(org.jivesoftware.smack.packet.XMPPError) NoAcceptableTransferMechanisms(org.jivesoftware.smackx.filetransfer.FileTransferException.NoAcceptableTransferMechanisms) FormField(org.jivesoftware.smackx.xdata.FormField)

Example 39 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project Smack by igniterealtime.

the class ServiceAdministrationManager method deleteUser.

public void deleteUser(Set<EntityBareJid> jidsToDelete) throws NoResponseException, XMPPErrorException, NotConnectedException, InterruptedException {
    RemoteCommand command = deleteUser();
    command.execute();
    Form answerForm = command.getForm().createAnswerForm();
    FormField accountJids = answerForm.getField("accountjids");
    accountJids.addValues(JidUtil.toStringList(jidsToDelete));
    command.next(answerForm);
    assert (command.isCompleted());
}
Also used : Form(org.jivesoftware.smackx.xdata.Form) RemoteCommand(org.jivesoftware.smackx.commands.RemoteCommand) FormField(org.jivesoftware.smackx.xdata.FormField)

Example 40 with FormField

use of org.jivesoftware.smackx.xdata.FormField in project xabber-android by redsolution.

the class Feature method getValue.

private String getValue(String name) {
    FormField field = getField(name);
    if (field == null)
        return null;
    List<String> values = field.getValues();
    if (!values.isEmpty()) {
        return null;
    }
    return values.get(0);
}
Also used : FormField(org.jivesoftware.smackx.xdata.FormField)

Aggregations

FormField (org.jivesoftware.smackx.xdata.FormField)46 DataForm (org.jivesoftware.smackx.xdata.packet.DataForm)18 Test (org.junit.Test)10 DiscoverInfo (org.jivesoftware.smackx.disco.packet.DiscoverInfo)6 ArrayList (java.util.ArrayList)4 TreeSet (java.util.TreeSet)3 Element (org.jivesoftware.smack.packet.Element)3 ExtensionElement (org.jivesoftware.smack.packet.ExtensionElement)3 Form (org.jivesoftware.smackx.xdata.Form)3 RangeValidateElement (org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement.RangeValidateElement)3 XmlPullParser (org.xmlpull.v1.XmlPullParser)3 LinkedList (java.util.LinkedList)2 IQ (org.jivesoftware.smack.packet.IQ)2 RemoteCommand (org.jivesoftware.smackx.commands.RemoteCommand)2 StreamInitiation (org.jivesoftware.smackx.si.packet.StreamInitiation)2 ValidateElement (org.jivesoftware.smackx.xdatavalidation.packet.ValidateElement)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 Method (java.lang.reflect.Method)1 MessageDigest (java.security.MessageDigest)1 HashMap (java.util.HashMap)1