Java 类org.jivesoftware.smack.AccountManager 实例源码

项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 注册用户
 * @param xmppConnection
 * @param userName
 * @param password
 * @param attributes
 * @return
 */
public static boolean regist(XMPPConnection xmppConnection,String userName,String password,Map<String,String> attributes){
    AccountManager accountManager=xmppConnection.getAccountManager();
    try {
        if(attributes!=null){
            accountManager.createAccount(userName, password, attributes);
        }
        else{
            accountManager.createAccount(userName, password);
        }
        return true;
    } catch (XMPPException e) {
        e.printStackTrace();
        return false;
    }
}
项目:SmackStudy    文件:XMPPUtil.java   
/**
 * 注册用户
 * @param xmppConnection
 * @param userName
 * @param password
 * @param attributes
 * @return
 */
public static boolean regist(XMPPConnection xmppConnection, String userName, String password, Map<String, String> attributes) {
    AccountManager accountManager = xmppConnection.getAccountManager();
    try {
        if (attributes != null) {
            accountManager.createAccount(userName, password, attributes);
        } else {
            accountManager.createAccount(userName, password);
        }
        return true;
    } catch (XMPPException e) {
        Log.e("regist", e.getMessage());
        e.printStackTrace();
        return false;
    }
}
项目:dohko    文件:XMPPServiceImpl.java   
@Deprecated
@Override
public boolean createAccount(Account account)
{
    boolean created = false;
    AccountManager accountManager = this.session_.getConnection().getAccountManager();

    if (accountManager.supportsAccountCreation())
    {
        try
        {
            accountManager.createAccount(account.getId().getId(), account.getPassword());
            created = true;
        }
        catch (XMPPException ex)
        {
            LOG.error("Error in creating user's account: {}", ex.getMessage(), ex);
            throw new XMPPFailureException(ex.getMessage(), ex.getCause()).withStreamError(new StreamError(ex.getStreamError().getCode()));
        }
    }

    return created;
}
项目:msf-spaces-sdk-android    文件:ConnectionHandler.java   
private void createUser() throws UnsupportedOperationException,
        EntityExistsException {
    if (status == ConnectionStatus.ONLINE) {
            throw new EntityExistsException("The user " + userInfo.getUsername() + " already exists.");
    }
    AccountManager manager = connection.getAccountManager();
    if (!manager.supportsAccountCreation()){
        setConnectionStatus(ConnectionStatus.ERROR);
        throw new UnsupportedOperationException("The server doesn't support account creation.");
    }
    try {
        manager.createAccount(userInfo.getUsername(), password);
    } catch (XMPPException e) {
        setConnectionStatus(ConnectionStatus.ERROR);
        switch (e.getXMPPError().getCode()){
        case 409:
            throw new EntityExistsException("The user " + userInfo.getUsername() + " already exists.", e);
        case 406:
            throw new IllegalArgumentException("Not enough or malformed arguments to create user.", e);
        default:
            throw new UnsupportedOperationException("The user couldn't be created.", e);
        }
    }
}
项目:Beem    文件:CreateAccountFragment.java   
@Override
protected Boolean doInBackground(String... params) {
    Log.d(TAG, "Xmpp login task");
    jid = params[0];
    password = params[1];
    Log.d(TAG, "jid " + jid + " server  " + server);

    int port = -1;
    if (params.length > 2) {
    server = params[2];
    }
    if (params.length > 3) {
    if (!TextUtils.isEmpty(params[3])) {
        port = Integer.parseInt(params[3]);
    }
    }
    Connection connection = prepareConnection(jid, server, port);
    try {
    connection.connect();
    AccountManager accountManager = new AccountManager(connection);
    accountManager.createAccount(StringUtils.parseName(jid), password);
    } catch (XMPPException e) {
    Log.e(TAG, "Unable to create account", e);
    exception = e;
    return false;
    } finally {
    connection.disconnect();
    }
    return true;
}
项目:beem-fork-xmpp    文件:CreateAccountFragment.java   
@Override
protected Boolean doInBackground(String... params) {
    Log.d(TAG, "Xmpp login task");
    jid = params[0];
    password = params[1];
    Log.d(TAG, "jid " + jid + " server  " + server);

    int port = -1;
    if (params.length > 2) {
    server = params[2];
    }
    if (params.length > 3) {
    if (!TextUtils.isEmpty(params[3])) {
        port = Integer.parseInt(params[3]);
    }
    }
    Connection connection = prepareConnection(jid, server, port);
    try {
    connection.connect();
    AccountManager accountManager = new AccountManager(connection);
    accountManager.createAccount(StringUtils.parseName(jid), password);
    } catch (XMPPException e) {
    Log.e(TAG, "Unable to create account", e);
    exception = e;
    return false;
    } finally {
    connection.disconnect();
    }
    return true;
}