public void addAttendees(String attendees, Rfc822Validator validator) { final LinkedHashSet<Rfc822Token> addresses = EditEventHelper.getAddressesFromList(attendees, validator); synchronized (this) { for (final Rfc822Token address : addresses) { final Attendee attendee = new Attendee(address.getName(), address.getAddress()); if (TextUtils.isEmpty(attendee.mName)) { attendee.mName = attendee.mEmail; } addAttendee(attendee); } } }
/** * Encode an address header, and perform folding if needed. * * @param sb The stringBuilder to write to * @param headerName The RFC 2822 header name * @param addresses the reformatted address substrings to encode. */ public void encodeHeaderAddresses( StringBuilder sb, String headerName, ArrayList<Rfc822Token> addresses) { /* TODO: Do we need to encode the addresses if they contain illegal characters? * This depends of the outcome of errata 4176. The current spec. states to use UTF-8 * where possible, but the RFCs states to use US-ASCII for the headers - hence encoding * would be needed to support non US-ASCII characters. But the MAP spec states not to * use any encoding... */ int partLength, lineLength = 0; lineLength += headerName.getBytes().length; sb.append(headerName); for (Rfc822Token address : addresses) { partLength = address.toString().getBytes().length + 1; // Add folding if needed if (lineLength + partLength >= 998) // max line length in RFC2822 { sb.append("\r\n "); // Append a FWS (folding whitespace) lineLength = 0; } sb.append(address.toString()).append(";"); lineLength += partLength; } sb.append("\r\n"); }
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); } }