예제 #1
0
파일: Talk.java 프로젝트: neharob/fsnet
  /*
   * (non-Javadoc)
   *
   * @see
   * fr.univartois.ili.fsnet.commons.talk.ITalk#initConnexion(java.lang.String
   * , int, java.lang.String, java.lang.String, java.util.Map)
   */
  @Override
  public void initConnexion(
      String xmppServer, int port, String login, String pssword, Map<String, String> map)
      throws TalkException {
    config = new ConnectionConfiguration(xmppServer, port);

    connection = new XMPPConnection(config);
    try {
      if (!connection.isConnected()) {
        connection.connect();
      }

      accountManager = connection.getAccountManager();
      connection.login(login, pssword);

    } catch (XMPPException e) {
      if ((e.getLocalizedMessage().contains("authentication failed")
              || e.getLocalizedMessage().contains("SASL authentication"))
          && accountManager.supportsAccountCreation()) {
        createAccount(login, pssword, map);

      } else {
        Logger.getAnonymousLogger().log(Level.SEVERE, "", e);
      }
    }

    /* It is only at that moment where the Listener is correctly initialized */
    ChatStateManager.getInstance(connection);
  }
예제 #2
0
 /**
  * 删除当前用户
  *
  * @param connection
  * @return
  */
 public boolean deleteAccount() {
   if (connection == null) return false;
   try {
     connection.getAccountManager().deleteAccount();
     return true;
   } catch (Exception e) {
     return false;
   }
 }
예제 #3
0
 /**
  * 修改密码
  *
  * @param connection
  * @return
  */
 public boolean changePassword(String pwd) {
   if (connection == null) return false;
   try {
     connection.getAccountManager().changePassword(pwd);
     return true;
   } catch (Exception e) {
     return false;
   }
 }