Exemplo n.º 1
0
 void inviteBuddies() {
   Rfc822Token[] recipients = Rfc822Tokenizer.tokenize(mAddressList.getText());
   try {
     IImConnection conn = mApp.getConnection(mProviderId);
     IContactList list = getContactList(conn);
     if (list == null) {
       Log.e(
           ImApp.LOG_TAG,
           "<AddContactActivity> can't find given contact list:" + getSelectedListName());
       finish();
     } else {
       boolean fail = false;
       for (Rfc822Token recipient : recipients) {
         String username = recipient.getAddress();
         if (mDefaultDomain != null && username.indexOf('@') == -1) {
           username = username + "@" + mDefaultDomain;
         }
         if (Log.isLoggable(ImApp.LOG_TAG, Log.DEBUG)) {
           log("addContact:" + username);
         }
         int res = list.addContact(username);
         if (res != ImErrorInfo.NO_ERROR) {
           fail = true;
           mHandler.showAlert(
               R.string.error, ErrorResUtils.getErrorRes(getResources(), res, username));
         }
       }
       // close the screen if there's no error.
       if (!fail) {
         finish();
       }
     }
   } catch (RemoteException ex) {
     Log.e(ImApp.LOG_TAG, "<AddContactActivity> inviteBuddies: caught " + ex);
   }
 }