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


Java Registration.addExtension方法代码示例

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


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

示例1: sendRegistrationForm

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
 * Sends the completed registration form to the server. After the user successfully submits
 * the form, the room may queue the request for review by the room admins or may immediately
 * add the user to the member list by changing the user's affiliation from "none" to "member.<p>
 *
 * If the desired room nickname is already reserved for that room, the room will return a
 * "Conflict" error to the user (error code 409). If the room does not support registration,
 * it will return a "Service Unavailable" error to the user (error code 503).
 *
 * @param form the completed registration form.
 * @throws XMPPException if an error occurs submitting the registration form. In particular, a
 *      409 error can occur if the desired room nickname is already reserved for that room;
 *      or a 503 error can occur if the room does not support registration.
 */
public void sendRegistrationForm(Form form) throws XMPPException {
    Registration reg = new Registration();
    reg.setType(IQ.Type.SET);
    reg.setTo(room);
    reg.addExtension(form.getDataFormToSend());

    PacketFilter filter =
        new AndFilter(new PacketIDFilter(reg.getPacketID()), new PacketTypeFilter(IQ.class));
    PacketCollector collector = connection.createPacketCollector(filter);
    connection.sendPacket(reg);
    IQ result = (IQ) collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (result == null) {
        throw new XMPPException("No response from server.");
    }
    else if (result.getType() == IQ.Type.ERROR) {
        throw new XMPPException(result.getError());
    }
}
 
开发者ID:ice-coffee,项目名称:EIM,代码行数:34,代码来源:MultiUserChat.java

示例2: createRegistrationForm

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的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

示例3: parseIQ

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
public IQ parseIQ(XmlPullParser parser) throws Exception {
    Registration reg = new Registration();
    String namespace = parser.getNamespace();
    boolean done = false;

    while (!done)
    {
        int eventType = parser.next();

        if (eventType == XmlPullParser.START_TAG)
        {
            PacketExtension ext = PacketParserUtils.parsePacketExtension(parser.getName(), namespace, parser);

            if (ext != null)
            {
                reg.addExtension(ext);
            }
        }
        else if (eventType == XmlPullParser.END_TAG)
        {
            if (parser.getName().equals("query"))
            {
                done = true;
            }
        }
    }
    return reg;
}
 
开发者ID:ShadiNachat,项目名称:Chatting-App-,代码行数:29,代码来源:RegistrationFormProvider.java

示例4: registerUser

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
 * Registers a user with a gateway.
 *
 * @param con           the XMPPConnection.
 * @param gatewayDomain the domain of the gateway (service name)
 * @param username      the username.
 * @param password      the password.
 * @param nickname      the nickname.
 * @throws XMPPException thrown if there was an issue registering with the gateway.
 */
public static void registerUser(XMPPConnection con, String gatewayDomain, String username, String password, String nickname) throws XMPPException {
    Registration registration = new Registration();
    registration.setType(IQ.Type.SET);
    registration.setTo(gatewayDomain);
    registration.addExtension(new GatewayRegisterExtension());

    Map<String, String> attributes = new HashMap<String, String>();
    if (username != null) {
        attributes.put("username", username);
    }
    if (password != null) {
        attributes.put("password", password);
    }
    if (nickname != null) {
        attributes.put("nick", nickname);
    }
    registration.setAttributes(attributes);

    PacketCollector collector = con.createPacketCollector(new PacketIDFilter(registration.getPacketID()));
    con.sendPacket(registration);

    IQ response = (IQ)collector.nextResult(SmackConfiguration.getPacketReplyTimeout());
    collector.cancel();
    if (response == null) {
        throw new XMPPException("Server timed out");
    }
    if (response.getType() == IQ.Type.ERROR) {
        throw new XMPPException("Error registering user", response.getError());
    }

}
 
开发者ID:visit,项目名称:spark-svn-mirror,代码行数:42,代码来源:TransportUtils.java

示例5: parseRegistration

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
private static Registration parseRegistration(XmlPullParser parser) throws Exception {
    Registration registration = new Registration();
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            // Any element that's in the jabber:iq:register namespace,
            // attempt to parse it if it's in the form <name>value</name>.
            if (parser.getNamespace().equals("jabber:iq:register")) {
                String name = parser.getName();
                String value = "";
                
                if (parser.next() == XmlPullParser.TEXT) {
                    value = parser.getText();
                    if(name.equals("instructions")){
                    	registration.setInstructions(value);
                    }
                    else{
                    	registration.addAttribute(name, value);
                    }
                }
                else if(name.equals("registered")){
                	registration.setRegistered(true);
                }
                else{
                	registration.addRequiredField(name);
                }
            }
            // Otherwise, it must be a packet extension.
            else {
                registration.addExtension(
                    PacketParserUtils.parsePacketExtension(
                        parser.getName(),
                        parser.getNamespace(),
                        parser));
            }
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }
    return registration;
}
 
开发者ID:samuelhehe,项目名称:androidpn_enhanced_client,代码行数:46,代码来源:PacketParserUtils.java

示例6: parseRegistration

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
private static Registration parseRegistration(XmlPullParser parser) throws Exception {
    Registration registration = new Registration();
    Map<String, String> fields = null;
    boolean done = false;
    while (!done) {
        int eventType = parser.next();
        if (eventType == XmlPullParser.START_TAG) {
            // Any element that's in the jabber:iq:register namespace,
            // attempt to parse it if it's in the form <name>value</name>.
            if (parser.getNamespace().equals("jabber:iq:register")) {
                String name = parser.getName();
                String value = "";
                if (fields == null) {
                    fields = new HashMap<String, String>();
                }

                if (parser.next() == XmlPullParser.TEXT) {
                    value = parser.getText();
                }
                // Ignore instructions, but anything else should be added to the map.
                if (!name.equals("instructions")) {
                    fields.put(name, value);
                }
                else {
                    registration.setInstructions(value);
                }
            }
            // Otherwise, it must be a packet extension.
            else {
                registration.addExtension(
                    PacketParserUtils.parsePacketExtension(
                        parser.getName(),
                        parser.getNamespace(),
                        parser));
            }
        }
        else if (eventType == XmlPullParser.END_TAG) {
            if (parser.getName().equals("query")) {
                done = true;
            }
        }
    }
    registration.setAttributes(fields);
    return registration;
}
 
开发者ID:CJC-ivotten,项目名称:androidPN-client.,代码行数:46,代码来源:PacketParserUtils.java

示例7: sendRegistrationForm

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
/**
 * Sends the completed registration form to the server. After the user
 * successfully submits the form, the room may queue the request for review
 * by the room admins or may immediately add the user to the member list by
 * changing the user's affiliation from "none" to "member.
 * <p>
 * 
 * If the desired room nickname is already reserved for that room, the room
 * will return a "Conflict" error to the user (error code 409). If the room
 * does not support registration, it will return a "Service Unavailable"
 * error to the user (error code 503).
 * 
 * @param form
 *            the completed registration form.
 * @throws XMPPException
 *             if an error occurs submitting the registration form. In
 *             particular, a 409 error can occur if the desired room
 *             nickname is already reserved for that room; or a 503 error
 *             can occur if the room does not support registration.
 */
public void sendRegistrationForm(Form form) throws XMPPException {
	Registration reg = new Registration();
	reg.setType(IQ.Type.SET);
	reg.setTo(room);
	reg.addExtension(form.getDataFormToSend());

	PacketFilter filter = new AndFilter(new PacketIDFilter(
			reg.getPacketID()), new PacketTypeFilter(IQ.class));
	PacketCollector collector = connection.createPacketCollector(filter);
	connection.sendPacket(reg);
	IQ result = (IQ) collector.nextResult(SmackConfiguration
			.getPacketReplyTimeout());
	collector.cancel();
	if (result == null) {
		throw new XMPPException("No response from server.");
	} else if (result.getType() == IQ.Type.ERROR) {
		throw new XMPPException(result.getError());
	}
}
 
开发者ID:ikantech,项目名称:xmppsupport_v2,代码行数:40,代码来源:MultiUserChat.java

示例8: prepareKeyPacket

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的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

示例9: createValidationForm

import org.jivesoftware.smack.packet.Registration; //导入方法依赖的package包/类
private Packet createValidationForm() {
    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("http://kontalk.org/protocol/register#code");
    form.addField(type);

    FormField code = new FormField("code");
    code.setLabel("Validation code");
    code.setType(FormField.TYPE_TEXT_SINGLE);
    code.addValue(mValidationCode.toString());
    form.addField(code);

    if (mKey != null || (mImportedPrivateKey != null && mImportedPublicKey != null)) {
        String publicKey;
        try {
            if (mKey != null) {
                String userId = MessageUtils.sha1(mPhone);
                // TODO what in name and comment fields here?
                mKeyRing = mKey.storeNetwork(userId, mServer.getNetwork(),
                    mName, mPassphrase);
            }
            else {
                mKeyRing = PGPKeyPairRing.load(mImportedPrivateKey, mImportedPublicKey);
            }

            publicKey = Base64.encodeToString(mKeyRing.publicKey.getEncoded(), Base64.NO_WRAP);
        }
        catch (Exception e) {
            // TODO
            Log.v(TAG, "error saving key", e);
            publicKey = null;
        }

        if (publicKey != null) {
            FormField key = new FormField("publickey");
            key.setLabel("Public key");
            key.setType(FormField.TYPE_TEXT_SINGLE);
            key.addValue(publicKey);
            form.addField(key);
        }
    }

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


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