1
0
Fork 0
mirror of https://codeberg.org/Mercury-IM/Smack synced 2024-12-23 13:07:59 +01:00

Added support for registration instructions (SMACK-90)

git-svn-id: http://svn.igniterealtime.org/svn/repos/smack/trunk@2108 b35dd754-fafc-0310-a699-88a17e54d16e
This commit is contained in:
Matt Tucker 2003-09-27 17:26:53 +00:00 committed by mtucker
parent 1ba31fd633
commit ac2166a62f
2 changed files with 47 additions and 1 deletions

View file

@ -136,6 +136,25 @@ public class AccountManager {
return Collections.EMPTY_LIST.iterator(); return Collections.EMPTY_LIST.iterator();
} }
/**
* Returns the instructions for creating a new account, or <tt>null</tt> if there
* are no instructions. If present, instructions should be displayed to the end-user
* that will complete the registration process.
*
* @return the account creation instructions, or <tt>null</tt> if there are none.
*/
public String getAccountInstructions() {
try {
if (info == null) {
getRegistrationInfo();
}
return info.getInstructions();
}
catch (XMPPException xe) {
return null;
}
}
/** /**
* Creates a new account using the specified username and password. The server may * Creates a new account using the specified username and password. The server may
* require a number of extra account attributes such as an email address and phone * require a number of extra account attributes such as an email address and phone
@ -149,6 +168,9 @@ public class AccountManager {
* @throws XMPPException if an error occurs creating the account. * @throws XMPPException if an error occurs creating the account.
*/ */
public void createAccount(String username, String password) throws XMPPException { public void createAccount(String username, String password) throws XMPPException {
if (!supportsAccountCreation()) {
throw new XMPPException("Server does not support account creation.");
}
// Create a map for all the required attributes, but give them blank values. // Create a map for all the required attributes, but give them blank values.
Map attributes = new HashMap(); Map attributes = new HashMap();
for (Iterator i=getAccountAttributes(); i.hasNext(); ) { for (Iterator i=getAccountAttributes(); i.hasNext(); ) {

View file

@ -82,6 +82,7 @@ public class Registration extends IQ {
private String username = null; private String username = null;
private String password = null; private String password = null;
private String instructions = null;
private Map attributes = null; private Map attributes = null;
/** /**
@ -120,6 +121,26 @@ public class Registration extends IQ {
this.password = password; this.password = password;
} }
/**
* Returns the registration instructions, or <tt>null</tt> if no instructions
* have been set. If present, instructions should be displayed to the end-user
* that will complete the registration process.
*
* @return the registration instructions, or <tt>null</tt> if there are none.
*/
public String getInstructions() {
return instructions;
}
/**
* Sets the registration instructions.
*
* @param instructions the registration instructions.
*/
public void setInstructions(String instructions) {
this.instructions = instructions;
}
/** /**
* Returns the map of String key/value pairs of account attributes. * Returns the map of String key/value pairs of account attributes.
* *
@ -147,6 +168,9 @@ public class Registration extends IQ {
if (password != null) { if (password != null) {
buf.append("<password>").append(password).append("</password>"); buf.append("<password>").append(password).append("</password>");
} }
if (instructions != null) {
buf.append("<instructions>").append(instructions).append("</instructions>");
}
if (attributes != null && attributes.size() > 0) { if (attributes != null && attributes.size() > 0) {
Iterator fieldNames = attributes.keySet().iterator(); Iterator fieldNames = attributes.keySet().iterator();
while (fieldNames.hasNext()) { while (fieldNames.hasNext()) {