本文整理汇总了Java中org.jivesoftware.smackx.xdata.FormField.setLabel方法的典型用法代码示例。如果您正苦于以下问题:Java FormField.setLabel方法的具体用法?Java FormField.setLabel怎么用?Java FormField.setLabel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.jivesoftware.smackx.xdata.FormField
的用法示例。
在下文中一共展示了FormField.setLabel方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例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;
}
示例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);
}
示例5: 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);
}
}
示例6: 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;
}
示例7: 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;
}
示例8: 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;
}
示例9: createValidationForm
import org.jivesoftware.smackx.xdata.FormField; //导入方法依赖的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;
}