当前位置: 首页>>代码示例>>Java>>正文


Java FormField.setType方法代码示例

本文整理汇总了Java中org.jivesoftware.smackx.xdata.FormField.setType方法的典型用法代码示例。如果您正苦于以下问题:Java FormField.setType方法的具体用法?Java FormField.setType怎么用?Java FormField.setType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.jivesoftware.smackx.xdata.FormField的用法示例。


在下文中一共展示了FormField.setType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: prepareKeyPacket

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private Stanza prepareKeyPacket() {
    String privatekey = Base64.encodeToString(mPrivateKeyData, Base64.NO_WRAP);

    Registration iq = new Registration();
    iq.setType(IQ.Type.set);
    iq.setTo(getConnection().getServiceName());
    Form form = new Form(DataForm.Type.submit);

    // form type: register#privatekey
    FormField type = new FormField("FORM_TYPE");
    type.setType(FormField.Type.hidden);
    type.addValue("http://kontalk.org/protocol/register#privatekey");
    form.addField(type);

    // private key
    FormField fieldKey = new FormField("privatekey");
    fieldKey.setLabel("Private key");
    fieldKey.setType(FormField.Type.text_single);
    fieldKey.addValue(privatekey);
    form.addField(fieldKey);

    iq.addExtension(form.getDataFormToSend());
    return iq;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:25,代码来源:PrivateKeyUploadListener.java

示例2: createValidationForm

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private Stanza createValidationForm() throws IOException {
    Registration iq = new Registration();
    iq.setType(IQ.Type.set);
    iq.setTo(mConnector.getConnection().getServiceName());
    Form form = new Form(DataForm.Type.submit);

    FormField type = new FormField("FORM_TYPE");
    type.setType(FormField.Type.hidden);
    type.addValue("http://kontalk.org/protocol/register#code");
    form.addField(type);

    if (mValidationCode != null) {
        FormField code = new FormField("code");
        code.setLabel("Validation code");
        code.setType(FormField.Type.text_single);
        code.addValue(mValidationCode.toString());
        form.addField(code);
    }

    iq.addExtension(form.getDataFormToSend());
    return iq;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:23,代码来源:NumberValidator.java

示例3: createRegistrationForm

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private Packet createRegistrationForm() {
    Registration iq = new Registration();
    iq.setType(IQ.Type.SET);
    iq.setTo(mConnector.getConnection().getServiceName());
    Form form = new Form(Form.TYPE_SUBMIT);

    FormField type = new FormField("FORM_TYPE");
    type.setType(FormField.TYPE_HIDDEN);
    type.addValue("jabber:iq:register");
    form.addField(type);

    FormField phone = new FormField("phone");
    phone.setLabel("Phone number");
    phone.setType(FormField.TYPE_TEXT_SINGLE);
    phone.addValue(mPhone);
    form.addField(phone);

    iq.addExtension(form.getDataFormToSend());
    return iq;
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:21,代码来源:NumberValidator.java

示例4: requestVoice

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
/**
 * Sends a voice request to the MUC. The room moderators usually need to approve this request.
 *
 * @throws NotConnectedException
 * @see <a href="http://xmpp.org/extensions/xep-0045.html#requestvoice">XEP-45 § 7.13 Requesting
 *      Voice</a>
 * @since 4.1
 */
public void requestVoice() throws NotConnectedException {
    DataForm form = new DataForm(DataForm.Type.submit);
    FormField formTypeField = new FormField(FormField.FORM_TYPE);
    formTypeField.addValue(MUCInitialPresence.NAMESPACE + "#request");
    form.addField(formTypeField);
    FormField requestVoiceField = new FormField("muc#role");
    requestVoiceField.setType(FormField.Type.text_single);
    requestVoiceField.setLabel("Requested role");
    requestVoiceField.addValue("participant");
    form.addField(requestVoiceField);
    Message message = new Message(room);
    message.addExtension(form);
    connection.sendStanza(message);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:23,代码来源:MultiUserChat.java

示例5: addField

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private void addField(ConfigureNodeFields nodeField, FormField.Type type)
{
	String fieldName = nodeField.getFieldName();
	
	if (getField(fieldName) == null)
	{
		FormField field = new FormField(fieldName);
		field.setType(type);
		addField(field);
	}
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:ConfigureForm.java

示例6: addField

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private void addField(SubscribeOptionFields nodeField, FormField.Type type)
{
	String fieldName = nodeField.getFieldName();
	
	if (getField(fieldName) == null)
	{
		FormField field = new FormField(fieldName);
		field.setType(type);
		addField(field);
	}
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:SubscribeForm.java

示例7: createDefaultInitiationForm

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private 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;
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:12,代码来源:FileTransferNegotiator.java

示例8: testCheckConsistencyFormFieldOpenValidateElement

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
@Test
public void testCheckConsistencyFormFieldOpenValidateElement() {
    FormField field = new FormField("var");
    field.setType(FormField.Type.hidden);
    OpenValidateElement element = new OpenValidateElement(null);
    try {
        element.checkConsistency(field);
        fail("No correct check on consistency");
    }
    catch (ValidationConsistencyException e) {
        assertEquals("Field type 'hidden' is not consistent with validation method 'open'.", e.getMessage());
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:DataValidationHelperTest.java

示例9: testCheckConsistencyFormFieldRangeValidateElement

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
@Test
public void testCheckConsistencyFormFieldRangeValidateElement() {
    FormField field = new FormField("var");
    field.setType(FormField.Type.text_multi);
    RangeValidateElement element = new RangeValidateElement("xs:integer",null, "99");
    try {
        element.checkConsistency(field);
        fail("No correct check on consistency");
    }
    catch (ValidationConsistencyException e) {
        assertEquals("Field type 'text-multi' is not consistent with validation method 'range'.", e.getMessage());
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:DataValidationHelperTest.java

示例10: testCheckConsistencyFormFieldRegexValidateElement

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
@Test
public void testCheckConsistencyFormFieldRegexValidateElement() {
    FormField field = new FormField("var");
    field.setType(FormField.Type.list_multi);
    RegexValidateElement element = new RegexValidateElement(null, ".*");
    try {
        element.checkConsistency(field);
        fail("No correct check on consistency");
    }
    catch (ValidationConsistencyException e) {
        assertEquals("Field type 'list-multi' is not consistent with validation method 'regex'.", e.getMessage());
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:14,代码来源:DataValidationHelperTest.java

示例11: joinQueue

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
/**
 * <p>Joins the workgroup queue to wait to be routed to an agent. After joining
 * the queue, queue status events will be sent to indicate the user's position and
 * estimated time left in the queue. Once joining the queue, there are three ways
 * the user can leave the queue: <ul>
 * <p/>
 * <li>The user is routed to an agent, which triggers a GroupChat invitation.
 * <li>The user asks to leave the queue by calling the {@link #departQueue} method.
 * <li>A server error occurs, or an administrator explicitly removes the user
 * from the queue.
 * </ul>
 * <p/>
 * A user cannot request to join the queue again if already in the queue. Therefore,
 * this method will throw an IllegalStateException if the user is already in the queue.<p>
 * <p/>
 * Some servers may be configured to require certain meta-data in order to
 * join the queue.<p>
 * <p/>
 * The server tracks the conversations that a user has with agents over time. By
 * default, that tracking is done using the user's JID. However, this is not always
 * possible. For example, when the user is logged in anonymously using a web client.
 * In that case the user ID might be a randomly generated value put into a persistent
 * cookie or a username obtained via the session. When specified, that userID will
 * be used instead of the user's JID to track conversations. The server will ignore a
 * manually specified userID if the user's connection to the server is not anonymous.
 *
 * @param metadata metadata to create a dataform from.
 * @param userID   String that represents the ID of the user when using anonymous sessions
 *                 or <tt>null</tt> if a userID should not be used.
 * @throws XMPPException if an error occured joining the queue. An error may indicate
 *                       that a connection failure occured or that the server explicitly rejected the
 *                       request to join the queue.
 * @throws SmackException 
 */
public void joinQueue(Map<String,Object> metadata, String userID) throws XMPPException, SmackException {
    // If already in the queue ignore the join request.
    if (inQueue) {
        throw new IllegalStateException("Already in queue " + workgroupJID);
    }

    // Build dataform from metadata
    Form form = new Form(DataForm.Type.submit);
    Iterator<String> iter = metadata.keySet().iterator();
    while (iter.hasNext()) {
        String name = iter.next();
        String value = metadata.get(name).toString();

        FormField field = new FormField(name);
        field.setType(FormField.Type.text_single);
        form.addField(field);
        form.setAnswer(name, value);
    }
    joinQueue(form, userID);
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:55,代码来源:Workgroup.java

示例12: buildDataForm

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private static void buildDataForm(SimpleUserSearch search,
                String instructions, XmlPullParser parser)
                throws XmlPullParserException, IOException, SmackException {
    DataForm dataForm = new DataForm(DataForm.Type.form);
    boolean done = false;
    dataForm.setTitle("User Search");
    dataForm.addInstruction(instructions);
    while (!done) {
        int eventType = parser.next();

        if (eventType == XmlPullParser.START_TAG && !parser.getNamespace().equals("jabber:x:data")) {
            String name = parser.getName();
            FormField field = new FormField(name);

            // Handle hard coded values.
            if(name.equals("first")){
                field.setLabel("First Name");
            }
            else if(name.equals("last")){
                field.setLabel("Last Name");
            }
            else if(name.equals("email")){
                field.setLabel("Email Address");
            }
            else if(name.equals("nick")){
                field.setLabel("Nickname");
            }

            field.setType(FormField.Type.text_single);
            dataForm.addField(field);
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
        else if (eventType == XmlPullParser.START_TAG && parser.getNamespace().equals("jabber:x:data")) {
            PacketParserUtils.addExtensionElement(search, parser);
            done = true;
        }
    }
    if (search.getExtension("x", "jabber:x:data") == null) {
        search.addExtension(dataForm);
    }
}
 
开发者ID:TTalkIM,项目名称:Smack,代码行数:46,代码来源:UserSearch.java

示例13: prepareKeyPacket

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private Stanza prepareKeyPacket() {
    if (mKeyRing != null) {
        try {
            String publicKey = Base64.encodeToString(mKeyRing.publicKey.getEncoded(), Base64.NO_WRAP);

            Registration iq = new Registration();
            iq.setType(IQ.Type.set);
            iq.setTo(getConnection().getServiceName());
            Form form = new Form(DataForm.Type.submit);

            // form type: register#key
            FormField type = new FormField("FORM_TYPE");
            type.setType(FormField.Type.hidden);
            type.addValue("http://kontalk.org/protocol/register#key");
            form.addField(type);

            // new (to-be-signed) public key
            FormField fieldKey = new FormField("publickey");
            fieldKey.setLabel("Public key");
            fieldKey.setType(FormField.Type.text_single);
            fieldKey.addValue(publicKey);
            form.addField(fieldKey);

            // old (revoked) public key
            if (mRevoked != null) {
                String revokedKey = Base64.encodeToString(mRevoked.getEncoded(), Base64.NO_WRAP);

                FormField fieldRevoked = new FormField("revoked");
                fieldRevoked.setLabel("Revoked public key");
                fieldRevoked.setType(FormField.Type.text_single);
                fieldRevoked.addValue(revokedKey);
                form.addField(fieldRevoked);
            }

            iq.addExtension(form.getDataFormToSend());
            return iq;
        }
        catch (IOException e) {
            Log.v(MessageCenterService.TAG, "error encoding key", e);
        }
    }

    return null;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:45,代码来源:RegisterKeyPairListener.java

示例14: createRegistrationForm

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private Stanza createRegistrationForm() {
    Registration iq = new Registration();
    iq.setType(IQ.Type.set);
    iq.setTo(mConnector.getConnection().getServiceName());
    Form form = new Form(DataForm.Type.submit);

    FormField type = new FormField("FORM_TYPE");
    type.setType(FormField.Type.hidden);
    type.addValue(Registration.NAMESPACE);
    form.addField(type);

    FormField phone = new FormField("phone");
    phone.setLabel("Phone number");
    phone.setType(FormField.Type.text_single);
    phone.addValue(mPhone);
    form.addField(phone);

    if (mForce) {
        FormField force = new FormField("force");
        force.setLabel("Force registration");
        force.setType(FormField.Type.bool);
        force.addValue(String.valueOf(mForce));
        form.addField(force);
    }

    if (mFallback) {
        FormField fallback = new FormField("fallback");
        fallback.setLabel("Fallback");
        fallback.setType(FormField.Type.bool);
        fallback.addValue(String.valueOf(mFallback));
        form.addField(fallback);
    }
    else {
        // not falling back, ask for our preferred challenge
        FormField challenge = new FormField("challenge");
        challenge.setLabel("Challenge type");
        challenge.setType(FormField.Type.text_single);
        challenge.addValue(DEFAULT_CHALLENGE);
        form.addField(challenge);
    }

    iq.addExtension(form.getDataFormToSend());
    return iq;
}
 
开发者ID:kontalk,项目名称:androidclient,代码行数:45,代码来源:NumberValidator.java

示例15: prepareKeyPacket

import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的package包/类
private Packet prepareKeyPacket() {
    if (mKeyRing != null) {
        try {
            String publicKey = Base64.encodeToString(mKeyRing.publicKey.getEncoded(), Base64.NO_WRAP);

            Registration iq = new Registration();
            iq.setType(IQ.Type.SET);
            iq.setTo(getConnection().getServiceName());
            Form form = new Form(Form.TYPE_SUBMIT);

            // form type: register#key
            FormField type = new FormField("FORM_TYPE");
            type.setType(FormField.TYPE_HIDDEN);
            type.addValue("http://kontalk.org/protocol/register#key");
            form.addField(type);

            // new (to-be-signed) public key
            FormField fieldKey = new FormField("publickey");
            fieldKey.setLabel("Public key");
            fieldKey.setType(FormField.TYPE_TEXT_SINGLE);
            fieldKey.addValue(publicKey);
            form.addField(fieldKey);

            // old (revoked) public key
            if (mRevoked != null) {
                String revokedKey = Base64.encodeToString(mRevoked.getEncoded(), Base64.NO_WRAP);

                FormField fieldRevoked = new FormField("revoked");
                fieldRevoked.setLabel("Revoked public key");
                fieldRevoked.setType(FormField.TYPE_TEXT_SINGLE);
                fieldRevoked.addValue(revokedKey);
                form.addField(fieldRevoked);
            }

            iq.addExtension(form.getDataFormToSend());
            return iq;
        }
        catch (IOException e) {
            Log.v(MessageCenterService.TAG, "error encoding key", e);
        }
    }

    return null;
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:45,代码来源:RegisterKeyPairListener.java


注:本文中的org.jivesoftware.smackx.xdata.FormField.setType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。