public ContactListManagerAdapter(ImConnectionAdapter conn) { mAdaptee = conn.getAdaptee().getContactListManager(); mConn = conn; mContext = conn.getContext(); mResolver = mContext.getContentResolver(); mContactListListenerAdapter = new ContactListListenerAdapter(); mSubscriptionListenerAdapter = new SubscriptionRequestListenerAdapter(); mContactLists = new HashMap<Address, ContactListAdapter>(); mTemporaryContacts = new HashMap<String, Contact>(); mValidatedContacts = new HashSet<String>(); mValidatedContactLists = new HashSet<String>(); mValidatedBlockedContacts = new HashSet<String>(); mAdaptee.addContactListListener(mContactListListenerAdapter); mAdaptee.setSubscriptionRequestListener(mSubscriptionListenerAdapter); mAccountId = mConn.getAccountId(); mProviderId = mConn.getProviderId(); Uri.Builder builder = Imps.Avatars.CONTENT_URI_AVATARS_BY.buildUpon(); ContentUris.appendId(builder, mProviderId); ContentUris.appendId(builder, mAccountId); mAvatarUrl = builder.build(); builder = Imps.Contacts.CONTENT_URI_CONTACTS_BY.buildUpon(); ContentUris.appendId(builder, mProviderId); ContentUris.appendId(builder, mAccountId); mContactUrl = builder.build(); }
public boolean isBlocked(String address) { try { return mAdaptee.isBlocked(address); } catch (ImException e) { Log.e(TAG, e.getMessage()); return false; } }
public int blockContact(String address) { try { mAdaptee.blockContactAsync(address); } catch (ImException e) { return e.getImError().getCode(); } return ImErrorInfo.NO_ERROR; }
public int deleteContactList(String name) { try { mAdaptee.deleteContactListAsync(name); } catch (ImException e) { return e.getImError().getCode(); } return ImErrorInfo.NO_ERROR; }
public int createContactList(String name, List<Contact> contacts) { try { mAdaptee.createContactListAsync(name, contacts); } catch (ImException e) { return e.getImError().getCode(); } return ImErrorInfo.NO_ERROR; }
public Contact getContactByAddress(String address) { Contact c = mAdaptee.getContact(address); if (c == null) { synchronized (mTemporaryContacts) { return mTemporaryContacts.get(address); } } else { return c; } }
public int unBlockContact(String address) { try { mAdaptee.unblockContactAsync(address); } catch (ImException e) { Log.e(TAG, e.getMessage()); return e.getImError().getCode(); } return ImErrorInfo.NO_ERROR; }
void deleteContactFromDataBase(Contact contact, ContactList list) { String selection = Imps.Contacts.USERNAME + "=? AND " + Imps.Contacts.CONTACTLIST + "=?"; long listId = getContactListAdapter(list.getAddress()).getDataBaseId(); String username = contact.getAddress().getFullName(); String[] selectionArgs = {username, Long.toString(listId)}; mResolver.delete(mContactUrl, selection, selectionArgs); // clear the history message if the contact doesn't exist in any list // anymore. if (mAdaptee.getContact(contact.getAddress()) == null) { clearHistoryMessages(username); } }
public Contact createTemporaryContact(String address) { Contact c = mAdaptee.createTemporaryContact(address); insertTemporary(c); return c; }
public int getState() { return mAdaptee.getState(); }
public void loadContactLists() { if (mAdaptee.getState() == ContactListManager.LISTS_NOT_LOADED) { clearValidatedContactsAndLists(); mAdaptee.loadContactListsAsync(); } }
public void declineSubscription(String address) { mAdaptee.declineSubscriptionRequest(address); }
public void approveSubscription(String address) { mAdaptee.approveSubscriptionRequest(address); }